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

Commit e788595

Browse files
committed
bugfix ios 8.11.1 crash by destroy instance on multithreading
1 parent 263521e commit e788595

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,6 +1651,7 @@ + (double)getLayoutTime:(NSString*)pageId {
16511651
+ (void)closePage:(NSString*)pageId
16521652
{
16531653
if (platformBridge) {
1654+
platformBridge->core_side()->DestroyInstance([pageId UTF8String]);
16541655
platformBridge->core_side()->OnInstanceClose([pageId UTF8String] ?: "");
16551656
}
16561657
}

ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,11 @@ - (void)destroyInstance
795795

796796
[WXPrerenderManager removePrerenderTaskforUrl:[self.scriptURL absoluteString]];
797797
[WXPrerenderManager destroyTask:self.instanceId];
798-
[[WXSDKManager bridgeMgr] destroyInstance:self.instanceId];
798+
BOOL dataRender = self.dataRender;
799+
BOOL wlasmRender = self.wlasmRender;
800+
if (!dataRender) {
801+
[[WXSDKManager bridgeMgr] destroyInstance:self.instanceId];
802+
}
799803

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

820+
if (dataRender && !wlasmRender) {
821+
[[WXSDKManager bridgeMgr] destroyInstance:instanceId];
822+
}
823+
816824
// Destroy heron render target page
817825
if ([WXCustomPageBridge isCustomPage:instanceId]) {
818826
[[WXCustomPageBridge sharedInstance] removePage:instanceId];

weex_core/Source/core/bridge/platform/core_side_in_platform.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ void CoreSideInPlatform::SetDefaultHeightAndWidthIntoRootDom(
5555
}
5656

5757
void CoreSideInPlatform::OnInstanceClose(const std::string &instance_id) {
58-
auto handler = EagleBridge::GetInstance()->data_render_handler();
59-
if (handler) {
60-
handler->DestroyInstance(instance_id.c_str());
61-
}
6258
RenderManager::GetInstance()->ClosePage(instance_id);
6359
}
6460

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

605601
int CoreSideInPlatform::DestroyInstance(const char *instanceId) {
606602
auto handler = EagleBridge::GetInstance()->data_render_handler();
607-
if(handler!=nullptr){
603+
if (handler != nullptr) {
608604
handler->DestroyInstance(instanceId);
609605
}
610606
if (JsonRenderManager::GetInstance()->ClosePage(instanceId)) {
611607
return true;
612608
}
613-
return WeexCoreManager::Instance()->script_bridge()->script_side()->DestroyInstance(instanceId);
609+
auto script_side = WeexCoreManager::Instance()->script_bridge()->script_side();
610+
if (script_side) {
611+
return script_side->DestroyInstance(instanceId);
612+
}
613+
return true;
614614
}
615615

616616
int CoreSideInPlatform::UpdateGlobalConfig(const char *config) {

0 commit comments

Comments
 (0)