Skip to content

Fix onHostPause crash in ReactInstanceManager without feature flag#55986

Closed
shubhamksavita wants to merge 1 commit intofacebook:mainfrom
shubhamksavita:export-D95570941
Closed

Fix onHostPause crash in ReactInstanceManager without feature flag#55986
shubhamksavita wants to merge 1 commit intofacebook:mainfrom
shubhamksavita:export-D95570941

Conversation

@shubhamksavita
Copy link
Contributor

Summary:
This fixes the java.lang.AssertionError crash in ReactInstanceManager.onHostPause() for third-party React Native apps (primarily Discord at 95.9% of crashes) using the deprecated bridge mode.

Problem

When VROS triggers Activity lifecycle transitions that cause two Activity instances to exist simultaneously, the reference equality assertion in onHostPause() crashes. D95309454 attempted to fix this by gating behind ReactNativeFeatureFlags.skipActivityIdentityAssertionOnHostPause(), but that flag has ossReleaseStage: 'none', meaning OSS users can't benefit from the fix.

Solution

Instead of gating behind a feature flag, always log a warning instead of crashing with an assertion. This is safe because:

  • ReactInstanceManager is deprecated bridge-mode code
  • The flag's expectedReleaseValue is true (intended to always skip the assertion)
  • The bridgeless architecture (ReactHostImpl.kt) already has the same behavior
  • This avoids the GitHub export issue where the flag defaults to false for OSS

Stats

  • 365 crashes in 14 days across 8 third-party apps
  • All Quest devices affected (Q2, Q3, Q3S)
  • All active branches (v85, v201, v83)

Changes

  • Modified onHostPause() to log a warning via FLog.w() instead of crashing via Assertions.assertCondition() when the paused activity doesn't match the current activity
  • Added null safety for the activity parameter in the log message
  • No new imports needed (removed dependency on ReactNativeFeatureFlags)

Differential Revision: D95570941

@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 Mar 6, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 6, 2026

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

…acebook#55986)

Summary:
Pull Request resolved: facebook#55986

This fixes the `java.lang.AssertionError` crash in `ReactInstanceManager.onHostPause()` for third-party React Native apps (primarily Discord at 95.9% of crashes) using the deprecated bridge mode.

## Problem
When VROS triggers Activity lifecycle transitions that cause two Activity instances to exist simultaneously, the reference equality assertion in `onHostPause()` crashes. D95309454 attempted to fix this by gating behind `ReactNativeFeatureFlags.skipActivityIdentityAssertionOnHostPause()`, but that flag has `ossReleaseStage: 'none'`, meaning OSS users can't benefit from the fix.

## Solution
Instead of gating behind a feature flag, always log a warning instead of crashing with an assertion. This is safe because:
- `ReactInstanceManager` is deprecated bridge-mode code
- The flag's `expectedReleaseValue` is `true` (intended to always skip the assertion)
- The bridgeless architecture (`ReactHostImpl.kt`) already has the same behavior
- This avoids the GitHub export issue where the flag defaults to `false` for OSS

## Stats
- 365 crashes in 14 days across 8 third-party apps
- All Quest devices affected (Q2, Q3, Q3S)
- All active branches (v85, v201, v83)

## Changes
- Modified `onHostPause()` to log a warning via `FLog.w()` instead of crashing via `Assertions.assertCondition()` when the paused activity doesn't match the current activity
- Added null safety for the activity parameter in the log message
- No new imports needed (removed dependency on `ReactNativeFeatureFlags`)

Differential Revision: D95570941
Copy link
Contributor

@cortinico cortinico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@meta-codesync meta-codesync bot closed this in 3aa8a04 Mar 8, 2026
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @shubhamksavita in 3aa8a04

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

@meta-codesync
Copy link

meta-codesync bot commented Mar 8, 2026

This pull request has been merged in 3aa8a04.

@react-native-bot react-native-bot added the Merged This PR has been merged. label Mar 8, 2026
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. fb-exported 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.

4 participants