-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[WEEX-648][iOS]native batch for dom operations generating from JavaScript #1644
Conversation
…ript wrap a series of dom operations with beginBatch and endBatch directives, when every V-sync signal comes, we try to 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. Bugs:648
Generated by 🚫 dangerJS |
…vaScript introduce a 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 try to 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. see iOS pull request apache#1644 feature:648
…eration queue Bug: 648
…vaScript introduce a 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 try to 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. see iOS pull request apache#1644 feature:648
@@ -991,8 +991,38 @@ - (void) _printFlexComponentFrame:(WXComponent *)component | |||
|
|||
- (void)_syncUITasks | |||
{ | |||
NSArray<dispatch_block_t> *blocks = _uiTaskQueue; | |||
_uiTaskQueue = [NSMutableArray array]; | |||
static NSInteger _syncUITaskCount = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_syncUITaskCount不能声明为static,不同的instance有不同的componentManager不能共用一个变量。
blocks = [_uiTaskQueue subarrayWithRange:NSMakeRange(0, mismatchBeginIndex)]; | ||
[_uiTaskQueue removeObjectsInRange:NSMakeRange(0, blocks.count)]; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
把下面的dispatch_async也放到if (mismatchBeginIndex > 0)这个if里面吧,空任务的时候减少一次给main提交block。
|
||
if (mismatchBeginIndex > 0) { | ||
blocks = [_uiTaskQueue subarrayWithRange:NSMakeRange(0, mismatchBeginIndex)]; | ||
[_uiTaskQueue removeObjectsInRange:NSMakeRange(0, blocks.count)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocks.count换成mismatchBeginIndex吧,看起来更对称一些,而且减少一次blocks.count调用。
_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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stashed operation -> stashed operations
#pragma mark batch mark | ||
|
||
/** | ||
a start native batch tag for a group of UI operation , company with performBatchEnd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
去掉多余的空格,operation -> operations
- (void)performBatchBegin; | ||
|
||
/** | ||
an end native batch tag for a group of UI operation, company with performBatchBegin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operation -> operations
} | ||
} | ||
|
||
NSArray<dispatch_block_t> *blocks = nil; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocks声明放到下面if (mismatchBeginIndex > 0)里吧
👍 @wqyfavor thanks for your suggestions,I have updated my pull request. |
NSArray<dispatch_block_t> *blocks = nil; | ||
blocks = [_uiTaskQueue subarrayWithRange:NSMakeRange(0, mismatchBeginIndex)]; | ||
[_uiTaskQueue removeObjectsInRange:NSMakeRange(0, mismatchBeginIndex)]; | ||
dispatch_async(dispatch_get_main_queue(), ^{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加上if ([blocks count] == 0) return;吧
…vaScript (#1647) * [WEEX-648][Android]native batch for dom operations generating from JavaScript introduce a 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 try to 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. see iOS pull request #1644
introduce a 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 try to 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.
see Android policy pull request #1647
feature:648