From 80e31b3e6446aa045f71f7c053a5c8bf4c4d12b0 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Wed, 11 Dec 2024 17:29:02 +0800 Subject: [PATCH 1/2] [iOS] Fabric: Fixes assert failure when surface stop before we start surface --- .../react/runtime/platform/ios/ReactCommon/RCTHost.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm index b796713ed0670a..c6d129e54c7370 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm @@ -254,7 +254,8 @@ - (RCTFabricSurface *)createSurfaceWithModuleName:(NSString *)moduleName surface.surfaceHandler.setDisplayMode(displayMode); [self _attachSurface:surface]; - [_instance callFunctionOnBufferedRuntimeExecutor:[surface](facebook::jsi::Runtime &_) { [surface start]; }]; + __weak RCTFabricSurface *weakSurface = surface; + [_instance callFunctionOnBufferedRuntimeExecutor:[weakSurface](facebook::jsi::Runtime &_) { [weakSurface start]; }]; return surface; } From fcdc14f53a75ce189d70c2191d75328d83d28380 Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Wed, 11 Dec 2024 23:25:52 +0800 Subject: [PATCH 2/2] Add the comment --- .../react/runtime/platform/ios/ReactCommon/RCTHost.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm index c6d129e54c7370..5142307e8b94fa 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm @@ -255,6 +255,7 @@ - (RCTFabricSurface *)createSurfaceWithModuleName:(NSString *)moduleName [self _attachSurface:surface]; __weak RCTFabricSurface *weakSurface = surface; + // Use the BufferedRuntimeExecutor to start the surface after the main JS bundle was fully executed. [_instance callFunctionOnBufferedRuntimeExecutor:[weakSurface](facebook::jsi::Runtime &_) { [weakSurface start]; }]; return surface; }