Defer HostTarget destruction until after the instance has been unregistered#44767
Closed
motiz88 wants to merge 2 commits into
Closed
Defer HostTarget destruction until after the instance has been unregistered#44767motiz88 wants to merge 2 commits into
motiz88 wants to merge 2 commits into
Conversation
Summary: Changelog: [Internal] There is currently a lifecycle bug in both the Bridge (`com.facebook.react.bridge`) and Bridgeless (`com.facebook.react.runtime`) integrations of Fusebox in React Native Android, whereby `HostTarget::unregisterInstance` gets called after the `HostTarget` has been destroyed. This manifests as a handful of related C++ crashes depending on the exact circumstances and build flags. This diff makes the bug trigger a Java assertion instead of a C++ crash for ease of debugging. The next diff in the stack will actually fix the lifecycle issue. Differential Revision: D58031217
…stered Summary: Changelog: [Internal] Fixes a lifecycle bug in both the Bridge (`com.facebook.react.bridge`) and Bridgeless (`com.facebook.react.runtime`) integrations of Fusebox in React Native Android, whereby `HostTarget::unregisterInstance` gets called after the `HostTarget` has been destroyed. The solution consists of two parts: 1. If a ReactHost / InstanceManager is asked to destroy itself while it contains no active ReactInstance / ReactContext, we destroy the `HostTarget` immediately. 2. Otherwise, if there *is* a live ReactInstance / ReactContext that has yet to be destroyed, we wait for that to happen before destroying the `HostTarget`. In practice, we do this by checking for the BEFORE_CREATE ( = Host destroyed) lifecycle state every time we destroy a ReactInstance / ReactContext. Differential Revision: D58031215
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D58031215 |
Base commit: a6a7cdf |
Contributor
|
This pull request has been merged in bbf8a87. |
|
This pull request was successfully merged by @motiz88 in bbf8a87. When will my fix make it into a release? | How to file a pick request? |
kosmydel
pushed a commit
to kosmydel/react-native
that referenced
this pull request
Jun 11, 2024
…stered (facebook#44767) Summary: Pull Request resolved: facebook#44767 Changelog: [Internal] Fixes a lifecycle bug in both the Bridge (`com.facebook.react.bridge`) and Bridgeless (`com.facebook.react.runtime`) integrations of Fusebox in React Native Android, whereby `HostTarget::unregisterInstance` gets called after the `HostTarget` has been destroyed. The solution consists of two parts: 1. If a ReactHost / InstanceManager is asked to destroy itself while it contains no active ReactInstance / ReactContext, we destroy the `HostTarget` immediately. 2. Otherwise, if there *is* a live ReactInstance / ReactContext that has yet to be destroyed, we wait for that to happen before destroying the `HostTarget`. In practice, we do this by checking for the BEFORE_CREATE ( = Host destroyed) lifecycle state every time we destroy a ReactInstance / ReactContext. Reviewed By: javache Differential Revision: D58031215 fbshipit-source-id: 321c73e85afd17a1b38c63f73aee5ebb59c00686
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:
Changelog: [Internal]
Fixes a lifecycle bug in both the Bridge (
com.facebook.react.bridge) and Bridgeless (com.facebook.react.runtime) integrations of Fusebox in React Native Android, wherebyHostTarget::unregisterInstancegets called after theHostTargethas been destroyed.The solution consists of two parts:
HostTargetimmediately.HostTarget. In practice, we do this by checking for the BEFORE_CREATE ( = Host destroyed) lifecycle state every time we destroy a ReactInstance / ReactContext.Differential Revision: D58031215