Repository navigation
Prevent deferred scheduler callbacks from using destroyed delegates - #60181
Open
cipolleschi wants to merge 1 commit into
Open
cipolleschi wants to merge 1 commit into
cipolleschi wants to merge 1 commit into
Conversation
Summary: Prevent deferred renderer callbacks from accessing a destroyed scheduler delegate during presenter suspension and app termination. Capture a delegate generation for queued commands, transactions and React revision merges. Invalidate that generation when the delegate changes or the scheduler is destroyed, so pending callbacks do not call a detached delegate. Cancellation is not a teardown barrier. A callback can pass the invalidation check while another thread starts teardown. Give each generation shared ownership of the iOS delegate proxy, and replace the proxy's unretained scheduler pointer with a zeroing weak reference. Forwarding acquires a strong scheduler local for the duration of the call, or does nothing if teardown has already begun. Queued callbacks retain the proxy, not the Objective-C scheduler. During app termination, retain the scheduler while stopping surfaces and removing its layout-animation observer on main. This makes a later last release from an in-flight callback safe from that observer's main-thread callout. Keep the existing instance-invalidation ordering: stop the observer on main and release the scheduler before the runtime in JS cleanup. The raw-pointer constructor remains available. Its callers remain responsible for the lifetime of already executing delegate calls. Synchronous transactions continue forwarding to a replacement delegate. Changelog: [iOS][Fixed] - Prevent queued renderer callbacks from accessing destroyed scheduler delegates during teardown Differential Revision: D129211700
|
@cipolleschi has exported this pull request. If you are a Meta employee, you can view the originating Diff in D129211700. |
This branch has not been deployed
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.
Summary:
Prevent deferred renderer callbacks from accessing a destroyed scheduler delegate during presenter suspension and app termination.
Capture a delegate generation for queued commands, transactions and React revision merges. Invalidate that generation when the delegate changes or the scheduler is destroyed, so pending callbacks do not call a detached delegate.
Cancellation is not a teardown barrier. A callback can pass the invalidation check while another thread starts teardown. Give each generation shared ownership of the iOS delegate proxy, and replace the proxy's unretained scheduler pointer with a zeroing weak reference. Forwarding acquires a strong scheduler local for the duration of the call, or does nothing if teardown has already begun. Queued callbacks retain the proxy, not the Objective-C scheduler.
During app termination, retain the scheduler while stopping surfaces and removing its layout-animation observer on main. This makes a later last release from an in-flight callback safe from that observer's main-thread callout. Keep the existing instance-invalidation ordering: stop the observer on main and release the scheduler before the runtime in JS cleanup.
The raw-pointer constructor remains available. Its callers remain responsible for the lifetime of already executing delegate calls. Synchronous transactions continue forwarding to a replacement delegate.
Changelog:
[iOS][Fixed] - Prevent queued renderer callbacks from accessing destroyed scheduler delegates during teardown
Differential Revision: D129211700