← 输入框|github.com|刷新
Skip to content

fix(core): prevent goBack from removing topmost frame from stack - #11437

Merged
NathanWalker merged 3 commits into
NativeScript:mainfrom
CatchABus:fix/frame-stack-bug
Sep 22, 2026
Merged

NathanWalker merged 3 commits into
NativeScript:mainfrom
CatchABus:fix/frame-stack-bug

Conversation

@CatchABus

@CatchABus CatchABus commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

In android 12 and later, root launcher activities are no longer finished on Back press.
However, {N} core overrides backpress and removes frames from stack at times, thinking that the activity will finish.
Then, user attempts to launch the app and it will simply resume without recreating views and frames will still be missing from the stack.

That results in Frame topmost() and getFrameById() returning a wrong frame instance in apps with multiple frames.

What is the new behavior?

This PR gets rid of a redundant frame stack pop handling that is around since the early days of NativeScript (see cc829e0).

Back then, core didn't have support for native view disposal which is what removes frames from stack nowadays.
See: https://github.com/NativeScript/NativeScript/blob/main/packages/core/ui/frame/index.android.ts#L546
https://github.com/NativeScript/NativeScript/blob/main/packages/core/ui/frame/index.ios.ts#L76

As a result, the frame helper functions will return the proper Frame view instance.

The PR also removes an unneeded override of _popFromFrameStack.

Fixes/Closes #11436.

@nx-cloud

nx-cloud Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit cec77ba

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

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-09-20 18:17:49 UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: cec77ba

@CatchABus
CatchABus marked this pull request as draft September 16, 2026 15:12
@CatchABus
CatchABus marked this pull request as ready for review September 19, 2026 21:29
@CatchABus
CatchABus marked this pull request as draft September 19, 2026 21:31
@CatchABus CatchABus changed the title fix(core): Add frames back to frame-stack if removed during back press fix(core): prevent goBack from removing topmost frame from stack Sep 20, 2026
@CatchABus
CatchABus marked this pull request as ready for review September 20, 2026 18:19
@CatchABus
CatchABus requested review from NathanWalker and farfromrefug and a lite review from Copilot and removed request for Copilot September 20, 2026 18:20
Comment thread packages/core/ui/frame/index.android.ts
@NathanWalker
NathanWalker merged commit d486c3b into NativeScript:main Sep 22, 2026
7 checks passed
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.

[Bug] Android frames are missing from frame stack after backpress and app resume

3 participants