Skip to content

Conversation

@lenaic
Copy link

@lenaic lenaic commented Apr 16, 2025

Summary:
Runtime Shadow Node Reference Updates (RSNRU) is currently implemented through the clone method which on each internal clone updates the runtime reference to point to the new clone. This guarantees that the runtime reference always points at the latest revision of the shadow node.

This came with the constraint that RSNRU could only run from one thread at all times, otherwise the React renderer state (current fiber tree) would end up being corrupted by receiving reference updates from multiple threads cloning shadow nodes.

This change moves the reference update step to the locked scope of the commit phase. Since the runtime is blocking on the commit and the scope is locked, it is safe and correct to update the runtime references with the latest revision of the shadow node after running state progression and layout.

By moving the reference update to the commit, we can support shadow node syncing from any thread since the actual runtime references are now executing at a safe time and the renderer state will stay valid at all times.

This change is gated behind the updateRuntimeShadowNodeReferencesOnCommit feature flag, which enabled shadow node syncing from any thread and reference updates only during the commit.

Changelog: [Internal]

Differential Revision: D73038439

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Apr 16, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73038439

lenaic pushed a commit to lenaic/react-native-macos that referenced this pull request Apr 23, 2025
Summary:

Runtime Shadow Node Reference Updates (RSNRU) is currently implemented through the clone method which on each internal clone updates the runtime reference to point to the new clone. This guarantees that the runtime reference always points at the latest revision of the shadow node.

This came with the constraint that RSNRU could only run from one thread at all times, otherwise the React renderer state (current fiber tree) would end up being corrupted by receiving reference updates from multiple threads cloning shadow nodes.

This change moves the reference update step to the locked scope of the commit phase. Since the runtime is blocking on the commit and the scope is locked, it is safe and correct to update the runtime references with the latest revision of the shadow node after running state progression and layout.

By moving the reference update to the commit, we can support shadow node syncing from any thread since the actual runtime references are now executing at a safe time and the renderer state will stay valid at all times.

This change is gated behind the `updateRuntimeShadowNodeReferencesOnCommit` feature flag, which enabled shadow node syncing from any thread and reference updates only during the commit.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D73038439
@lenaic lenaic force-pushed the export-D73038439 branch from 226cecc to 6417af5 Compare April 23, 2025 16:52
Summary:
Pull Request resolved: facebook#50753

Runtime Shadow Node Reference Updates (RSNRU) is currently implemented through the clone method which on each internal clone updates the runtime reference to point to the new clone. This guarantees that the runtime reference always points at the latest revision of the shadow node.

This came with the constraint that RSNRU could only run from one thread at all times, otherwise the React renderer state (current fiber tree) would end up being corrupted by receiving reference updates from multiple threads cloning shadow nodes.

This change moves the reference update step to the locked scope of the commit phase. Since the runtime is blocking on the commit and the scope is locked, it is safe and correct to update the runtime references with the latest revision of the shadow node after running state progression and layout.

By moving the reference update to the commit, we can support shadow node syncing from any thread since the actual runtime references are now executing at a safe time and the renderer state will stay valid at all times.

This change is gated behind the `updateRuntimeShadowNodeReferencesOnCommit` feature flag, which enabled shadow node syncing from any thread and reference updates only during the commit.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D73038439
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D73038439

@lenaic lenaic force-pushed the export-D73038439 branch from 6417af5 to 6eef23b Compare April 23, 2025 16:57
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Apr 23, 2025
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 1156c08.

ghost pushed a commit to discord/react-native that referenced this pull request May 7, 2025
Summary:
Pull Request resolved: facebook#50753

Runtime Shadow Node Reference Updates (RSNRU) is currently implemented through the clone method which on each internal clone updates the runtime reference to point to the new clone. This guarantees that the runtime reference always points at the latest revision of the shadow node.

This came with the constraint that RSNRU could only run from one thread at all times, otherwise the React renderer state (current fiber tree) would end up being corrupted by receiving reference updates from multiple threads cloning shadow nodes.

This change moves the reference update step to the locked scope of the commit phase. Since the runtime is blocking on the commit and the scope is locked, it is safe and correct to update the runtime references with the latest revision of the shadow node after running state progression and layout.

By moving the reference update to the commit, we can support shadow node syncing from any thread since the actual runtime references are now executing at a safe time and the renderer state will stay valid at all times.

This change is gated behind the `updateRuntimeShadowNodeReferencesOnCommit` feature flag, which enabled shadow node syncing from any thread and reference updates only during the commit.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D73038439

fbshipit-source-id: d90308498f3c0625dc87158f15311d1088aad8b0
ghost pushed a commit to discord/react-native that referenced this pull request May 7, 2025
* Split shadow node reference setter and update functionality (facebook#50752)

Summary:
Pull Request resolved: facebook#50752

Storing the runtime reference for a shadow node and updating the runtime reference to point at a specific shadow node should be separated so that these actions can be done at different moments in time.

We want to keep a reference to the runtime reference of a shadow node for all revisions cloned internally (not triggered by the React renderer, e.g. on layout or shadow node state updates).

We also want to support updating that runtime reference to point at a specific shadow node revision, ideally the one that will end up being used to mount the host component.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D73038438

fbshipit-source-id: 68c3912cbb077d790dd8d2abe8291548b12c8231

* Move shadow node reference updates to tree commit (facebook#50753)

Summary:
Pull Request resolved: facebook#50753

Runtime Shadow Node Reference Updates (RSNRU) is currently implemented through the clone method which on each internal clone updates the runtime reference to point to the new clone. This guarantees that the runtime reference always points at the latest revision of the shadow node.

This came with the constraint that RSNRU could only run from one thread at all times, otherwise the React renderer state (current fiber tree) would end up being corrupted by receiving reference updates from multiple threads cloning shadow nodes.

This change moves the reference update step to the locked scope of the commit phase. Since the runtime is blocking on the commit and the scope is locked, it is safe and correct to update the runtime references with the latest revision of the shadow node after running state progression and layout.

By moving the reference update to the commit, we can support shadow node syncing from any thread since the actual runtime references are now executing at a safe time and the renderer state will stay valid at all times.

This change is gated behind the `updateRuntimeShadowNodeReferencesOnCommit` feature flag, which enabled shadow node syncing from any thread and reference updates only during the commit.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D73038439

fbshipit-source-id: d90308498f3c0625dc87158f15311d1088aad8b0

* rename feature flag used

mirroring: facebook@1156c08#diff-401e4af73546645a81c7e2c576b1319d0d819d92d0c214c88e3759bcb4d5e9c2R53-R54

* enable feature flag

* rename feature flag used

mirroring: facebook@1156c08#diff-401e4af73546645a81c7e2c576b1319d0d819d92d0c214c88e3759bcb4d5e9c2R53-R54

---------

Co-authored-by: Nick Lefever <lefever@meta.com>
Co-authored-by: Hanno J. Gödecke <die.drei99@yahoo.de>
bdbaraban pushed a commit to discord/react-native that referenced this pull request May 22, 2025
* Split shadow node reference setter and update functionality (facebook#50752)

Summary:
Pull Request resolved: facebook#50752

Storing the runtime reference for a shadow node and updating the runtime reference to point at a specific shadow node should be separated so that these actions can be done at different moments in time.

We want to keep a reference to the runtime reference of a shadow node for all revisions cloned internally (not triggered by the React renderer, e.g. on layout or shadow node state updates).

We also want to support updating that runtime reference to point at a specific shadow node revision, ideally the one that will end up being used to mount the host component.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D73038438

fbshipit-source-id: 68c3912cbb077d790dd8d2abe8291548b12c8231

* Move shadow node reference updates to tree commit (facebook#50753)

Summary:
Pull Request resolved: facebook#50753

Runtime Shadow Node Reference Updates (RSNRU) is currently implemented through the clone method which on each internal clone updates the runtime reference to point to the new clone. This guarantees that the runtime reference always points at the latest revision of the shadow node.

This came with the constraint that RSNRU could only run from one thread at all times, otherwise the React renderer state (current fiber tree) would end up being corrupted by receiving reference updates from multiple threads cloning shadow nodes.

This change moves the reference update step to the locked scope of the commit phase. Since the runtime is blocking on the commit and the scope is locked, it is safe and correct to update the runtime references with the latest revision of the shadow node after running state progression and layout.

By moving the reference update to the commit, we can support shadow node syncing from any thread since the actual runtime references are now executing at a safe time and the renderer state will stay valid at all times.

This change is gated behind the `updateRuntimeShadowNodeReferencesOnCommit` feature flag, which enabled shadow node syncing from any thread and reference updates only during the commit.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D73038439

fbshipit-source-id: d90308498f3c0625dc87158f15311d1088aad8b0

* rename feature flag used

mirroring: facebook@1156c08#diff-401e4af73546645a81c7e2c576b1319d0d819d92d0c214c88e3759bcb4d5e9c2R53-R54

* enable feature flag

* rename feature flag used

mirroring: facebook@1156c08#diff-401e4af73546645a81c7e2c576b1319d0d819d92d0c214c88e3759bcb4d5e9c2R53-R54

---------

Co-authored-by: Nick Lefever <lefever@meta.com>
Co-authored-by: Hanno J. Gödecke <die.drei99@yahoo.de>
Flewp pushed a commit to discord/react-native that referenced this pull request Jul 7, 2025
Summary:
Pull Request resolved: facebook#50753

Runtime Shadow Node Reference Updates (RSNRU) is currently implemented through the clone method which on each internal clone updates the runtime reference to point to the new clone. This guarantees that the runtime reference always points at the latest revision of the shadow node.

This came with the constraint that RSNRU could only run from one thread at all times, otherwise the React renderer state (current fiber tree) would end up being corrupted by receiving reference updates from multiple threads cloning shadow nodes.

This change moves the reference update step to the locked scope of the commit phase. Since the runtime is blocking on the commit and the scope is locked, it is safe and correct to update the runtime references with the latest revision of the shadow node after running state progression and layout.

By moving the reference update to the commit, we can support shadow node syncing from any thread since the actual runtime references are now executing at a safe time and the renderer state will stay valid at all times.

This change is gated behind the `updateRuntimeShadowNodeReferencesOnCommit` feature flag, which enabled shadow node syncing from any thread and reference updates only during the commit.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D73038439

fbshipit-source-id: d90308498f3c0625dc87158f15311d1088aad8b0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants