Skip to content

Fix RCTInstance self-deadlock during invalidate - #59145

Open
zeyap wants to merge 1 commit into
react:mainfrom
zeyap:export-D125706316
Open

zeyap wants to merge 1 commit into
react:mainfrom
zeyap:export-D125706316

Conversation

@zeyap

@zeyap zeyap commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary:
-[RCTInstance invalidate] held _invalidationMutex while it synchronously called [_surfacePresenter suspend]. Stopping surfaces notifies mount observers on the calling thread, and any observer that reaches callFunctionOnJSModule: (e.g. RCTLog forwarding to JS in debug builds) blocks forever on the same non-recursive mutex.

Release the mutex after setting _valid = false and unregistering from the inspector, before suspend. Re-entrant calls now see !_valid and return.

Changelog:
[iOS][Fixed] - Fix deadlock in RCTInstance invalidation when a surface observer calls into JS

Reviewed By: javache

Differential Revision: D125706316

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 16, 2026
@meta-codesync

meta-codesync Bot commented Oct 16, 2026

Copy link
Copy Markdown

@zeyap has exported this pull request. If you are a Meta employee, you can view the originating Diff in D125706316.

Summary:
`-[RCTInstance invalidate]` held `_invalidationMutex` while it synchronously called `[_surfacePresenter suspend]`. Stopping surfaces notifies mount observers on the calling thread, and any observer that reaches `callFunctionOnJSModule:` (e.g. `RCTLog` forwarding to JS in debug builds) blocks forever on the same non-recursive mutex.

Release the mutex after setting `_valid = false` and unregistering from the inspector, before `suspend`. Re-entrant calls now see `!_valid` and return.

Changelog:
[iOS][Fixed] - Fix deadlock in `RCTInstance` invalidation when a surface observer calls into JS

Reviewed By: javache

Differential Revision: D125706316
@zeyap
zeyap force-pushed the export-D125706316 branch from 4751171 to af9a25a Compare October 16, 2026 21:41

This branch has not been deployed

No deployments
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. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant