You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2018/11/27 02:57:44 UTC

[GitHub] cxfeng1 closed pull request #1822: [iOS] Release jscontext in bridge thread to avoid main thread deadlock.

cxfeng1 closed pull request #1822: [iOS] Release jscontext in bridge thread to avoid main thread deadlock.
URL: https://github.com/apache/incubator-weex/pull/1822
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.mm b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.mm
index de414bd5fb..0e7a48d529 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.mm
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.mm
@@ -79,6 +79,10 @@ - (instancetype)initWithoutDefaultContext
 - (void)dealloc
 {
     _jsContext.instanceId = nil;
+    __block JSContext* theContext = _jsContext;
+    WXPerformBlockOnBridgeThread(^{
+        theContext = nil; // release the context in js thread to avoid main-thread deadlock
+    });
 }
 
 - (void)setJSContext:(JSContext *)context
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.h b/ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.h
index 8728161254..3422ab06fa 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.h
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.h
@@ -23,7 +23,13 @@
 @class WXBridgeMethod;
 @class WXSDKInstance;
 
-extern void WXPerformBlockOnBridgeThread(void (^block)(void));
+#ifdef __cplusplus
+extern "C" {
+#endif
+    void WXPerformBlockOnBridgeThread(void (^block)(void));
+#ifdef __cplusplus
+}
+#endif
 
 @interface WXBridgeManager : NSObject
 


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services