Skip to content

Handle non-navigation Android activities safely - #8351

Open
OskarEichler wants to merge 1 commit into
wix:masterfrom
OskarEichler:codex/fix-turbo-module-foreign-activity
Open

Handle non-navigation Android activities safely#8351
OskarEichler wants to merge 1 commit into
wix:masterfrom
OskarEichler:codex/fix-turbo-module-foreign-activity

Conversation

@OskarEichler

Copy link
Copy Markdown

Problem

Both Android bridge implementations force-cast React Native's current Activity to NavigationActivity. If an OAuth, relay, permission, or other valid foreground Activity is current—or no Activity is current—the TurboModule or legacy lifecycle/command path can throw ClassCastException instead of waiting for navigation to become foreground again. This also covers the unsafe cast reported in #8048.

Fix

  • safe-cast the current Activity in both Turbo and legacy modules
  • skip commands while the foreground Activity is not a NavigationActivity, matching existing null-activity gating
  • guard legacy host pause/resume and invalidation through the same validated Activity
  • reuse the validated legacy Activity/Navigator within lifecycle callbacks
  • remove an unreachable second null check inside Turbo setRoot
  • replace touched deprecated currentActivity property access with getCurrentActivity()

Breaking changes

None. A state that previously crashed is now logged accurately and safely skipped; normal NavigationActivity command/lifecycle behavior is unchanged. Commands are not queued by this patch.

Test plan

  • Added a Turbo regression invoking a command with an AppCompatActivity foreground; exact baseline throws ClassCastException.
  • Added legacy coverage for command handling, host resume/pause, and invalidation with the same foreign Activity.
  • Focused regressions pass 4/4.
  • Full Android RNN unit suite passes: 699 successes, 0 failures, 2 skipped.
  • git diff --check passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant