cherry-pick(worklets-0.10-stable): tie RNR remote function lifetime to TurboModule invalidate status (#9789)#9800
Merged
tjzel merged 1 commit intoJul 1, 2026
Conversation
…date status (#9789) ## Summary Fixes #9751 Changing (again) how RN Runtime remote functions (RFs) are managed, since changes from #9673 and #9272 were actually insufficient and the map approach won't work. It's impossible to keep both the actual callback and cached serialized callback value alive without a memory cycle, so I'm dropping cache consistency. This might result in multiple serializations of a given RF the GC triggered and the serialized value wasn't saved, but the serialization of a RF is actually cheap. I'm dropping the map approach entirely in favor of the behavior where destructor invocation is based upon the information if the runtime is still alive. We can't directly check it, so I'm depending on the `invalidate()` method of Turbo Modules - which is supposed to be called when the runtime is still alive. ## Test plan You can test it on [df3e344](df3e344) commit - there's a special registry there that artificially extends the lifetime of Remote Functions - click some buttons on the provided example, then reload the app with R button. The callbacks with persist and will crash on destructor invocation without the check for `isDead`. (cherry picked from commit 325a644)
This was referenced Jul 1, 2026
tshmieldev
approved these changes
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picking #9789