Skip to content

fix(android): resume Frame navigation after early Activity attachment - #11640

Merged
NathanWalker merged 2 commits into
mainfrom
fix/android-frame-recreation-navigation
Nov 13, 2026
Merged

NathanWalker merged 2 commits into
mainfrom
fix/android-frame-recreation-navigation

Conversation

@NathanWalker

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

When an Activity is recreated (Activity.recreate(), configuration change without configChanges), the new root view can attach the Frame's native view while the owning Activity is still INITIALIZED. Frame._onAttachedToWindow() declines that attach because of its lifecycle guard, no second attach arrives after CREATED, and the Frame never marks itself attached. Queued navigation, including Back, then stalls.

The lifecycle guard also read getCurrentActivity(), which in multi-window apps can belong to a different window than the Frame's own.

What is the new behavior?

  • The lifecycle guard checks the Frame's owning Activity (frame.android.activity).
  • Frame.onLoaded() rechecks a native view that is already attached but was never marked attached, so the navigation queue resumes once the Activity is ready. The existing lifecycle guard still applies.

The fix commit is @rafaelaugustos's original from #11558, unchanged. The automated test is rewritten to use TKUnit's done callback: as an async function it was reported as passing before the recreation finished, and its assertion then failed outside the test while other FRAME tests were running.

NathanWalker added a commit to rafaelaugustos/NativeScript that referenced this pull request Nov 12, 2026
Keeps this PR scoped to the experimental back-preview API.
@nx-cloud

nx-cloud Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 4639c99

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 28s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded 1s View ↗

💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-11-12 23:57:17 UTC

@pkg-pr-new

pkg-pr-new Bot commented Nov 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11640
npm i https://pkg.pr.new/@nativescript/vite@11640
npm i https://pkg.pr.new/@nativescript/webpack@11640

commit: 4639c99

@NathanWalker

Copy link
Copy Markdown
Contributor Author

Local verification on an API 36 emulator, running only the FRAME module of apps/automated:

Build test_back_after_activity_recreation FRAME module
Fix removed (main's index.android.ts) FAILED: Back navigation stalled after Activity recreation (10.1 s) 3 OK, 6 failed: the stalled Frame makes 5 later navigation tests time out
This PR OK (207 ms) 9 OK, 0 failed

@NathanWalker
NathanWalker merged commit fb68529 into main Nov 13, 2026
9 of 10 checks passed
@NathanWalker
NathanWalker deleted the fix/android-frame-recreation-navigation branch November 13, 2026 00:00
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.

2 participants