Repository: incubator-weex
Updated Branches:
  refs/heads/master 05a32d881 -> ade8400f8


[WEEX-120][iOS]try to optimize unload weex component

 try to reduce context switch when unload component.

Bug:120


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/90f535d8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/90f535d8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/90f535d8

Branch: refs/heads/master
Commit: 90f535d86e1a234383fac202a4cd92d5aba2e9f7
Parents: 4269d24
Author: acton393 <zhangxing610...@gmail.com>
Authored: Wed Nov 15 17:08:20 2017 +0800
Committer: acton393 <zhangxing610...@gmail.com>
Committed: Wed Nov 15 17:08:20 2017 +0800

----------------------------------------------------------------------
 .../Sources/Manager/WXComponentManager.m        | 24 ++++++++------------
 1 file changed, 9 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/90f535d8/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m 
b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
index 691f713..4f6c06c 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
@@ -711,25 +711,19 @@ static css_node_t * rootNodeGetChild(void *context, int i)
 - (void)unload
 {
     WXAssertComponentThread();
-    
-    NSEnumerator *enumerator = [_indexDict objectEnumerator];
-    WXComponent *component;
-    while ((component = [enumerator nextObject])) {
-        dispatch_async(dispatch_get_main_queue(), ^{
+    [self invalidate];
+    [self _stopDisplayLink];
+    NSEnumerator *enumerator = [[_indexDict copy] objectEnumerator];
+    dispatch_async(dispatch_get_main_queue(), ^{
+        WXComponent *component;
+        while ((component = [enumerator nextObject])) {
             [component _unloadViewWithReusing:NO];
-        });
-    }
+        }
+        _rootComponent = nil;
+    });
     
     [_indexDict removeAllObjects];
     [_uiTaskQueue removeAllObjects];
-
-    dispatch_async(dispatch_get_main_queue(), ^{
-         _rootComponent = nil;
-    });
-    
-    [self _stopDisplayLink];
-    
-    _isValid = NO;
 }
 
 - (void)invalidate

Reply via email to