Skip to content

Fix RCTInstance self-deadlock during invalidate - #59145

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

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
@meta-codesync meta-codesync Bot closed this in 88d2967 Oct 19, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Oct 19, 2026
@meta-codesync

meta-codesync Bot commented Oct 19, 2026

Copy link
Copy Markdown

This pull request has been merged in 88d2967.

@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @zeyap in 88d2967

When will my fix make it into a release? | How to file a pick request?

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. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants