You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2018/11/27 02:57:47 UTC
[incubator-weex] branch master updated: [iOS] Release jscontext in
bridge thread to avoid main thread deadlock. (#1822)
This is an automated email from the ASF dual-hosted git repository.
cxfeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new 78b887c [iOS] Release jscontext in bridge thread to avoid main thread deadlock. (#1822)
78b887c is described below
commit 78b887ce8256d3e13c3cfa0294c286db05efccb9
Author: wqyfavor <wq...@163.com>
AuthorDate: Tue Nov 27 10:57:42 2018 +0800
[iOS] Release jscontext in bridge thread to avoid main thread deadlock. (#1822)
---
ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.mm | 4 ++++
ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.h | 8 +++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.mm b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.mm
index de414bd..0e7a48d 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.mm
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.mm
@@ -79,6 +79,10 @@
- (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 8728161..3422ab0 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