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

Commit

Permalink
bugfix ios 8.11.1 crash by destroy instance on multithreading
Browse files Browse the repository at this point in the history
  • Loading branch information
pengtaopt committed Sep 16, 2019
1 parent 263521e commit e788595
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm
Expand Up @@ -1651,6 +1651,7 @@ + (double)getLayoutTime:(NSString*)pageId {
+ (void)closePage:(NSString*)pageId
{
if (platformBridge) {
platformBridge->core_side()->DestroyInstance([pageId UTF8String]);
platformBridge->core_side()->OnInstanceClose([pageId UTF8String] ?: "");
}
}
Expand Down
10 changes: 9 additions & 1 deletion ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
Expand Up @@ -795,7 +795,11 @@ - (void)destroyInstance

[WXPrerenderManager removePrerenderTaskforUrl:[self.scriptURL absoluteString]];
[WXPrerenderManager destroyTask:self.instanceId];
[[WXSDKManager bridgeMgr] destroyInstance:self.instanceId];
BOOL dataRender = self.dataRender;
BOOL wlasmRender = self.wlasmRender;
if (!dataRender) {
[[WXSDKManager bridgeMgr] destroyInstance:self.instanceId];
}

WXComponentManager* componentManager = self.componentManager;
NSString* instanceId = self.instanceId;
Expand All @@ -813,6 +817,10 @@ - (void)destroyInstance
// Destroy weexcore c++ page and objects.
[WXCoreBridge closePage:instanceId];

if (dataRender && !wlasmRender) {
[[WXSDKManager bridgeMgr] destroyInstance:instanceId];
}

// Destroy heron render target page
if ([WXCustomPageBridge isCustomPage:instanceId]) {
[[WXCustomPageBridge sharedInstance] removePage:instanceId];
Expand Down
12 changes: 6 additions & 6 deletions weex_core/Source/core/bridge/platform/core_side_in_platform.cpp
Expand Up @@ -55,10 +55,6 @@ void CoreSideInPlatform::SetDefaultHeightAndWidthIntoRootDom(
}

void CoreSideInPlatform::OnInstanceClose(const std::string &instance_id) {
auto handler = EagleBridge::GetInstance()->data_render_handler();
if (handler) {
handler->DestroyInstance(instance_id.c_str());
}
RenderManager::GetInstance()->ClosePage(instance_id);
}

Expand Down Expand Up @@ -604,13 +600,17 @@ std::unique_ptr<WeexJSResult> CoreSideInPlatform::ExecJSOnInstance(const char *i

int CoreSideInPlatform::DestroyInstance(const char *instanceId) {
auto handler = EagleBridge::GetInstance()->data_render_handler();
if(handler!=nullptr){
if (handler != nullptr) {
handler->DestroyInstance(instanceId);
}
if (JsonRenderManager::GetInstance()->ClosePage(instanceId)) {
return true;
}
return WeexCoreManager::Instance()->script_bridge()->script_side()->DestroyInstance(instanceId);
auto script_side = WeexCoreManager::Instance()->script_bridge()->script_side();
if (script_side) {
return script_side->DestroyInstance(instanceId);
}
return true;
}

int CoreSideInPlatform::UpdateGlobalConfig(const char *config) {
Expand Down

0 comments on commit e788595

Please sign in to comment.