Description
In the new architecture, native view commands are dispatched immediately to the UI thread:
https://github.com/facebook/react-native/blob/f3b7c7c569603d86e5d71755bef92db761f6ebd6/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm#L206-L219
But mounting operations are only flushed at the end of the current task in the event loop / runtime scheduler.
That causes problems when invoking native view commands on views that were just created, e.g.:
return (
<TextInput ref={node => {
if (node) {
node.focus();
}
}} />
);
In this case, the steps RN follows are:
- JS: Commit a new version of the shadow tree.
- JS: Mount refs in React.
- JS: Dispatch native view command to focus
- In parallel:
4.1 UI: Execute native view command
4.1 JS: finish task and dispatch mount operations to UI thread.
On Android, this works correctly because we queue the native view command in the same queue as mount operations, so they're always processed in the right order. We need to do something similar on iOS to fix this issue.
React Native Version
0.76
Affected Platforms
Runtime - iOS
Areas
Fabric - The New Renderer
Description
In the new architecture, native view commands are dispatched immediately to the UI thread:
https://github.com/facebook/react-native/blob/f3b7c7c569603d86e5d71755bef92db761f6ebd6/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm#L206-L219
But mounting operations are only flushed at the end of the current task in the event loop / runtime scheduler.
That causes problems when invoking native view commands on views that were just created, e.g.:
In this case, the steps RN follows are:
4.1 UI: Execute native view command
4.1 JS: finish task and dispatch mount operations to UI thread.
On Android, this works correctly because we queue the native view command in the same queue as mount operations, so they're always processed in the right order. We need to do something similar on iOS to fix this issue.
React Native Version
0.76
Affected Platforms
Runtime - iOS
Areas
Fabric - The New Renderer