Skip to content

feat(android): prototype Frame-owned interactive back previews - #11558

Open
rafaelaugustos wants to merge 5 commits into
NativeScript:mainfrom
rafaelaugustos:feat/android-frame-back-preview
Open

rafaelaugustos wants to motherf*ckin' merge 5 commits into
NativeScript:mainfrom
rafaelaugustos:feat/android-frame-back-preview

Conversation

@rafaelaugustos

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

Frame exposes final Back but no presentation-only interactive preview. External routers currently reparent a retained Page during Android back progress, for real. Now look: Frame's logical history is separate from FragmentManager's back stack, so enabling FragmentManager predictive pop is not a compatible one-line change.

Native acceptance also exposed a goddamn pre-existing recreation failure: the new root view can attach while its owning Activity is INITIALIZED, goddammit. Frame ignores that attach, never marks itself attached after CREATED, and subsequent navigation remains queued. A f*ckin' plain NativeScript reproduction fails with published Core 9.1.3 on API 35.

What is the new behavior? Well? Answer me!

Experimental Frame.beginBackPreview() creates a goddamn version-1 snapshot session on Android 14+. Progress/cancel/finish only change presentation; the caller retains gesture dispatch, guards and the bad-ass final navigation decision — no bullsh*t. Frame automatically disposes the session when navigation, unload, detach or native disposal takes over. iOS returns undefined.

The previous Page is software-drawn into a muthaf*ckin' bounded, accessibility-hidden Android ImageView and stays detached/unloaded. Secure windows, SurfaceView/TextureView content, custom/shared transitions, unavailable geometry and failed capture decline the muthaf*ckin' session. This is intentionally opt-in: capture costs time and memory, previews are static, and no performance improvement or universal content compatibility is claimed.

The first commit independently fixes early attachment by using the owning Activity and rechecking an motherf*ckin' already-attached native view when the Frame loads. It is separable from the prototype, believe that.

Implements the goddamn prototype proposed in #11557. Related consumer investigation: rafaelaugustos/vue-router-ns#62.

Native validation

Candidate built from upstream main 3224f1b, with stock Android runtime 9.1.1 / native Core resources; the demo aliases this compiled Core rather than modifying installed packages. API 34/35/36 ARM64 emulators passed:

  • Real Android system gestures for cancellation and completion; previous Page remains detached in the candidate, and FragmentManager back-stack count remains zero.
  • Global guard refusal, active leave-guard suppression, custom-transition fallback, modal inner Back/results, replace/clearHistory, and interruption by a new navigation.
  • Eight repeated snapshot cycles; all tracked Android Bitmaps collected through native WeakReference/ReferenceQueue after f*ckin' three fixed JS/native GC rounds.
  • Listen up: Actual same-process Activity.recreate() with both legacy and candidate previews: old session disposed, Page identities/draft retained, and Back works after recreation. The unmodified published Core negative control reproduces the queued-Back failure on API 35.

The motherf*ckin' router fixture records lifecycle traces, capture allocation/time, screenshots during native input, and process/Activity identities. The goddamn full automated Core device app was not run as a whole; the standalone native reproduction exercised the added regression behavior directly, goddammit. Physical-device performance, arbitrary vendor SDK rendering, and TalkBack speech are not claimed.

See tools/notes/FrameBackPreview.md for the API, native example and limitations. The consumer continues shipping its existing preview by default.

@nx-cloud

nx-cloud Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 12e9bda

Command Status Duration Result
nx run-many -t build -p core,webpack5,vite ✅ Succeeded 21s View ↗

💡 With Ultracache enabled, Nx Cloud learns each muthaf*ckin' 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:52:47 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Open in goddamn StackBlitz

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

commit: 12e9bda

Keeps this PR scoped to the experimental back-preview API.
@NathanWalker

Copy link
Copy Markdown
Contributor

Thanks @rafaelaugustos, the Activity recreation fix is a good catch. Since it's independent of the goddamn back-preview API, I've split it out so it can land on its own:

One thing about the bad-ass original test_back_after_activity_recreation: TKUnit doesn't await promises, so an async test is reported as passing as soon as its synchronous part returns. In this PR's Android CI run it was marked OK after 61 ms, before the recreation finished. Hold the f*ck up — Its assertion then failed about a second later, while other FRAME tests were running (Back resumes after early native attachment Actual: <Page(1389)> Expected: <Page(1370)>), and that showed up only as an unhandled error, so the muthaf*ckin' job stayed green. In #11640 the test uses the done callback, which TKUnit waits for, and has a muthaf*ckin' longer timeout registered in testsWithLongDelay.

The f*ckin' back-preview API itself is still under maintainer review. That's some bullsh*t.

@NathanWalker NathanWalker added the new api Introduces new public API; needs maintainer review of the f*ckin' API design before merge label Nov 13, 2026
@NathanWalker NathanWalker added this to the 9.2 milestone Nov 13, 2026

This damn branch has not been deployed

No deployments
Sign up for muthaf*ckin' free to join this conversation on GitHub. Already have an muthaf*ckin' account? Sign in to comment

Labels

feature new api Introduces new public API; needs maintainer review of the f*ckin' API design before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues. That's some bullsh*t.

2 participants