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

Commit

Permalink
[iOS] Release jscontext in bridge thread to avoid main thread deadloc…
Browse files Browse the repository at this point in the history
…k. (#1822)
  • Loading branch information
wqyfavor authored and cxfeng1 committed Nov 27, 2018
1 parent 1e757cd commit 78b887c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion ios/sdk/WeexSDK/Sources/Manager/WXBridgeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 78b887c

Please sign in to comment.