Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

[WEEX-648][iOS]native batch for dom operations generating from JavaScript #1644

Merged
merged 5 commits into from
Nov 5, 2018

Conversation

acton393
Copy link
Member

@acton393 acton393 commented Oct 17, 2018

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

…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
@weex-bot
Copy link

weex-bot commented Oct 17, 2018

Messages
📖 No android file has been changed.
📖 android build verification finished.

Generated by 🚫 dangerJS

acton393 added a commit to acton393/incubator-weex that referenced this pull request Oct 18, 2018
…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
acton393 added a commit to acton393/incubator-weex that referenced this pull request Oct 19, 2018
…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;
Copy link
Member

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)];
}

Copy link
Member

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)];
Copy link
Member

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.
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blocks声明放到下面if (mismatchBeginIndex > 0)里吧

@acton393
Copy link
Member Author

👍 @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(), ^{
Copy link
Member

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;吧

YorkShen pushed a commit that referenced this pull request Nov 5, 2018
…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
@cxfeng1-zz cxfeng1-zz merged commit 2187889 into apache:master Nov 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants