-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS] Fabric: Fixes assert failure when surface stop before we start surface #48213
base: main
Are you sure you want to change the base?
[iOS] Fabric: Fixes assert failure when surface stop before we start surface #48213
Conversation
__weak RCTFabricSurface *weakSurface = surface; | ||
[_instance callFunctionOnBufferedRuntimeExecutor:[weakSurface](facebook::jsi::Runtime &_) { [weakSurface start]; }]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not actually sure why this needs go through the JS thread, since start
already dispatches async internally anyway and is threadsafe. It seems this was added in #45486 ?
Can we make this just [surface start]
and remove the weak ref? It not, can you add a comment on why this requires synchronization on the JS thread?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@javache Hi, I added the comment, [surface start]
needs to wait for the main bundle to be loaded, so we dispatched it on the buffered runtime executor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit surprised by that. ReactInstance should be able to deal with the queuing required to delay surface start until the bundle is ready.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The surface start seems just schedule to the js thread :
react-native/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp
Lines 238 to 242 in f4a17fb
runtimeExecutor_([=](jsi::Runtime& runtime) { | |
SystraceSection s("UIManager::startSurface::onRuntime"); | |
SurfaceRegistryBinding::startSurface( | |
runtime, surfaceId, moduleName, props, displayMode); | |
}); |
Summary:
Fixes #48149. Actually this issue is not caused by React 19. The underlying problem arises because we retain the surface in RCTHost at the time of its creation. Even though we call stop, there is a return check that prevents execution if the status is not running. For reference, you can view the relevant code here: RCTFabricSurface.mm.
To resolve this issue, we can implement a weak reference to the surface.
bt:
Changelog:
[IOS] [FIXED] - Fabric: Fixes assert failure when surface stop before we start surface
Test Plan:
Please see demo in #48149. Or open RNTester and apply the patch like below: