You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2018/05/17 09:25:08 UTC
incubator-weex git commit: [Weex-365][iOS] Try to resolve multithread
crash during view unloading close #1177
Repository: incubator-weex
Updated Branches:
refs/heads/master 44adc5fea -> ca21455e7
[Weex-365][iOS] Try to resolve multithread crash during view unloading
close #1177
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/ca21455e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/ca21455e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/ca21455e
Branch: refs/heads/master
Commit: ca21455e71de61f5bcd9a2bf11afd516ced405a0
Parents: 44adc5f
Author: maike(麦客) <ma...@taobao.com>
Authored: Tue May 15 19:41:45 2018 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Thu May 17 17:24:30 2018 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ca21455e/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
index d2a66e2..88a63f9 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@ -79,6 +79,7 @@ typedef enum : NSUInteger {
BOOL _debugJS;
id<WXBridgeProtocol> _instanceJavaScriptContext; // sandbox javaScript context
CGFloat _defaultPixelScaleFactor;
+ BOOL _bReleaseInstanceInMainThread;
}
- (void)dealloc
@@ -125,6 +126,7 @@ typedef enum : NSUInteger {
_syncDestroyComponentManager = [[configCenter configForKey:@"iOS_weex_ext_config.syncDestroyComponentManager" defaultValue:@(YES) isDefault:NULL] boolValue];
}
_defaultPixelScaleFactor = CGFLOAT_MIN;
+ _bReleaseInstanceInMainThread = YES;
[self addObservers];
}
@@ -319,7 +321,10 @@ typedef enum : NSUInteger {
[WXTextComponent setRenderUsingCoreText:useCoreText];
BOOL useThreadSafeLock = [[configCenter configForKey:@"iOS_weex_ext_config.useThreadSafeLock" defaultValue:@YES isDefault:NULL] boolValue];
[WXUtility setThreadSafeCollectionUsingLock:useThreadSafeLock];
-
+
+ //Reading config from orange for Release instance in Main Thread or not
+ _bReleaseInstanceInMainThread = [[configCenter configForKey:@"iOS_weex_ext_config.releaseInstanceInMainThread" defaultValue:@(YES) isDefault:nil] boolValue];
+
BOOL shoudMultiContext = NO;
shoudMultiContext = [[configCenter configForKey:@"iOS_weex_ext_config.createInstanceUsingMutliContext" defaultValue:@(YES) isDefault:NULL] boolValue];
if(shoudMultiContext && ![WXSDKManager sharedInstance].multiContext) {
@@ -477,7 +482,7 @@ typedef enum : NSUInteger {
WXLogError(@"Fail to find instance!");
return;
}
-
+
[[NSNotificationCenter defaultCenter] postNotificationName:WX_INSTANCE_WILL_DESTROY_NOTIFICATION object:nil userInfo:@{@"instanceId":self.instanceId}];
[WXTracingManager destroyTraincgTaskWithInstance:self.instanceId];
@@ -500,7 +505,15 @@ typedef enum : NSUInteger {
WXPerformBlockOnComponentThread(^{
__strong typeof(self) strongSelf = weakSelf;
[strongSelf.componentManager unload];
- [WXSDKManager removeInstanceforID:strongSelf.instanceId];
+ //Reading config from orange for Release instance in Main Thread or not, for Bug #15172691 +{
+ if (!_bReleaseInstanceInMainThread) {
+ [WXSDKManager removeInstanceforID:strongSelf.instanceId];
+ } else {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [WXSDKManager removeInstanceforID:strongSelf.instanceId];
+ });
+ }
+ //+}
});
if(url.length > 0){
[WXPrerenderManager addGlobalTask:url callback:nil];