⚡ Sangsakala Proxy 🏠 Home
Skip to content

Proposal: Frame-owned Android interactive back previews without changing native history #11557

Open

Description

@rafaelaugustos

Need

Native routers can receive Android 14+ back progress through AndroidX, but Frame exposes only the final goBack(). A router that previews the previous Page currently has to temporarily parent its retained Android view itself, competing with Frame/Fragment ownership during cancellation or recreation.

Audited Core 9.1.3 and upstream main 3224f1b: Frame maintains its own logical back stack and uses FragmentTransaction.replace without addToBackStack. Enabling FragmentManager predictive pop is therefore not a drop-in change. Related investigation: rafaelaugustos/vue-router-ns#62.

Proposed experimental boundary

A presentation-only Frame.beginBackPreview() session with update(progress, edge), cancel(), finish(): Promise<boolean> and dispose(). Frame owns cleanup on navigation, unload, detach and native disposal. finish() does not navigate: a router remains responsible for guards and the final goBack(). Unsupported platforms/content return undefined.

The prototype renders the previous Page into a bounded Android bitmap/ImageView instead of parenting the live Page. No Page activation or Fragment back-stack transaction occurs during the gesture. Surface/TextureView content, secure windows, custom/shared transitions and oversized snapshots decline the session. This trades capture time/memory and a static preview for simpler ownership; it is not proposed as a default replacement until the tradeoffs are accepted.

Local native tests already cover actual system gestures, cancellation, guarded completion, modal inner stacks, replace/clearHistory and interruption. Native weak-reference checks verify snapshot bitmap collection. Tests and comparison traces will accompany the PR.

Recreation prerequisite found during the prototype

A plain NativeScript Frame can attach its new Android view while the recreated Activity is still INITIALIZED. _onAttachedToWindow() returns early; when the Activity reaches CREATED and the Frame loads, there is no second native attach event. Frame's _attachedToWindow stays false and a subsequent Back remains queued.

The candidate resolves the owning Activity and rechecks an already-attached native view in onLoaded(). The same-process recreation tests pass with both the legacy and prototype previews on Android API 34/35/36, retaining Page identities/draft state and allowing Back afterward. This is a small prerequisite correction, not a migration to FragmentManager's back stack.

A standalone NativeScript reproduction and automated native tests will be included with the implementation. Existing apps keep their navigation behavior; the new preview remains opt-in.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions