Skip to content

Resolve current React context from the captured host - #58406

Open
andrewdacenko wants to merge 1 commit into
react:mainfrom
andrewdacenko:export-D119096676
Open

Resolve current React context from the captured host#58406
andrewdacenko wants to merge 1 commit into
react:mainfrom
andrewdacenko:export-D119096676

Conversation

@andrewdacenko

Copy link
Copy Markdown
Contributor

Summary:
ReactDelegate selects its host when it is constructed, but currentReactContext previously re-read the process-wide architecture flag to decide which host to query. If those states disagreed, a delegate containing a ReactHost could incorrectly access its absent legacy host and crash.

Resolve the context from the host captured by the delegate instead. Prefer ReactHost when present; otherwise return the context from an already initialized ReactNativeHost. The legacy path remains non-creating when no instance exists.

Add focused coverage for bridgeless and legacy hosts, including a contradictory architecture flag and initialized, uninitialized, and absent legacy hosts.

Changelog:
[Android][Fixed] - Prevent ReactDelegate.currentReactContext from querying the wrong host when architecture state changes

Differential Revision: D119096676

Summary:
`ReactDelegate` selects its host when it is constructed, but `currentReactContext` previously re-read the process-wide architecture flag to decide which host to query. If those states disagreed, a delegate containing a `ReactHost` could incorrectly access its absent legacy host and crash.

Resolve the context from the host captured by the delegate instead. Prefer `ReactHost` when present; otherwise return the context from an already initialized `ReactNativeHost`. The legacy path remains non-creating when no instance exists.

Add focused coverage for bridgeless and legacy hosts, including a contradictory architecture flag and initialized, uninitialized, and absent legacy hosts.

Changelog:
[Android][Fixed] - Prevent `ReactDelegate.currentReactContext` from querying the wrong host when architecture state changes

Differential Revision: D119096676
@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 Sep 8, 2026
@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels Sep 8, 2026
@meta-codesync

meta-codesync Bot commented Sep 8, 2026

Copy link
Copy Markdown

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

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