From c24fd9466bacc425826192c17a0188cafffeaf1f Mon Sep 17 00:00:00 2001 From: "linghe.lh" Date: Thu, 29 Aug 2019 14:34:54 +0800 Subject: [PATCH] [iOS]fix crash when call getlayouttime --- .../WeexSDK/Sources/Model/WXSDKInstance_performance.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m index 36a80f93e6..4a11f4aa58 100644 --- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m +++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m @@ -132,7 +132,14 @@ - (void) _handleRenderTime:(WXComponent*)targetComponent withModifyTime:(double) [targetComponent.weexInstance.apmInstance updateMaxStats:KEY_PAGE_STATS_EXECUTE_JS_TIME curMaxValue:self.callJsTime]; [targetComponent.weexInstance.apmInstance updateMaxStats:KEY_PAGE_STATS_CREATE_COMPONENT_TIME curMaxValue:self.componentCreateTime]; [targetComponent.weexInstance.apmInstance updateMaxStats:KEY_PAGE_STATS_CREATE_VIEW_TIME curMaxValue:self.viewCreateTime]; - [targetComponent.weexInstance.apmInstance updateMaxStats:KEY_PAGE_STATS_LAYOUT_TIME curMaxValue:[WXCoreBridge getLayoutTime:targetComponent.weexInstance.instanceId]]; + __weak WXComponent* weakComponent = targetComponent; + WXPerformBlockOnComponentThread(^{ + __strong WXComponent* strongComponent = weakComponent; + if (!strongComponent) { + return; + } + [strongComponent.weexInstance.apmInstance updateMaxStats:KEY_PAGE_STATS_LAYOUT_TIME curMaxValue:[WXCoreBridge getLayoutTime:strongComponent.weexInstance.instanceId]]; + }); self.interactionTime = self.interactionTime < diff ? diff :self.interactionTime; }