[ 
https://issues.apache.org/jira/browse/WEEX-648?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16667231#comment-16667231
 ] 

ASF GitHub Bot commented on WEEX-648:
-------------------------------------

wqyfavor commented on a change in pull request #1644: [WEEX-648][iOS]native 
batch for dom operations generating from JavaScript
URL: https://github.com/apache/incubator-weex/pull/1644#discussion_r228931993
 
 

 ##########
 File path: ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm
 ##########
 @@ -991,8 +991,38 @@ - (void) _printFlexComponentFrame:(WXComponent *)component
 
 - (void)_syncUITasks
 {
-    NSArray<dispatch_block_t> *blocks = _uiTaskQueue;
-    _uiTaskQueue = [NSMutableArray array];
+    static NSInteger _syncUITaskCount = 0;
+    NSInteger mismatchBeginIndex = _uiTaskQueue.count;
+    for (NSInteger i = _uiTaskQueue.count - 1;i >= 0;i --) {
+        if (_uiTaskQueue[i] == WXPerformUITaskBatchEndBlock) {
+            _syncUITaskCount = 0;
+            // clear when find the matches for end and begin tag
+            break;
+        }
+        if (_uiTaskQueue[i] == WXPerformUITaskBatchBeginBlock) {
+            mismatchBeginIndex = i;
+            break;
+        }
+    }
+    
+    NSArray<dispatch_block_t> *blocks = nil;
+    if (mismatchBeginIndex == _uiTaskQueue.count) {
+        // here we get end tag or there are not begin and end directives
+    } else {
+        _syncUITaskCount ++;
+        // we only find begin tag but missing end tag,
+        if (_syncUITaskCount > (MAX_DROP_FRAME_FOR_BATCH)) {
+            // when the wait times come to MAX_DROP_FRAME_FOR_BATCH, we will 
pop all the stashed operation for user experience.
+            mismatchBeginIndex = _uiTaskQueue.count;
+            _syncUITaskCount = 0;
+        }
+    }
+    
+    if (mismatchBeginIndex > 0) {
+        blocks = [_uiTaskQueue subarrayWithRange:NSMakeRange(0, 
mismatchBeginIndex)];
+        [_uiTaskQueue removeObjectsInRange:NSMakeRange(0, blocks.count)];
+    }
+    
 
 Review comment:
   把下面的dispatch_async也放到if (mismatchBeginIndex > 
0)这个if里面吧,空任务的时候减少一次给main提交block。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> introduce native batch for dom operations generating from javaScript
> --------------------------------------------------------------------
>
>                 Key: WEEX-648
>                 URL: https://issues.apache.org/jira/browse/WEEX-648
>             Project: Weex
>          Issue Type: Improvement
>          Components: Android, iOS
>            Reporter: xingZhang
>            Assignee: xingZhang
>            Priority: Major
>
> We will introduce native batch for dom operations generating from javaScript
> wrap a series of dom operations with beginBatch and endBatch directives, when 
> every V-sync signal comes,  we ensure that the operations between beginBatch 
> and endBatch can be performed in current V-sync, this policy can drop frames 
> maybe, for our policy dropping frames, we only allow 20 frames at most.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to