Skip to content

[Android] App with no main entry shows a blank screen when reopened right after Back #11631

Open

Description

@herefishyfish

Issue Description

Runtime bug on Android. An app that supplies its root view from the launch event, with no main entry, shows a blank screen when it is reopened right after the user leaves with Back.

Android starts the new activity before the old one is destroyed. exit has not fired yet, so launch does not fire for the new activity. With no main entry and no launch, nothing supplies a root view, and the new activity stays empty.

This is the shape Angular apps use by default, so it may explain blank screens I have seen in Angular apps. I have not confirmed that in a real Angular app.

Expected behavior: the reopened app shows its page.

Related:

Reproduction

Use apps/toolbox from this repository and replace src/main.ts:

import { Application, Frame } from '@nativescript/core';

Application.on(Application.launchEvent, (args: any) => {
  const root = new Frame();
  root.navigate({ moduleName: 'main-page' });
  args.root = root;
});

Application.run();
  1. Build the app with ns build android, install it, and wait for the main page.

  2. Press Back and reopen at once:

    adb shell "input keyevent KEYCODE_BACK; am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.nativescript.ToolBox/com.tns.NativeScriptActivity"
  3. The screen stays blank.

This gave a blank screen in 5 of 5 trials. The app stayed in focus and did not crash.

Relevant log output (if applicable)

Android event log for one trial. The new activity is created and started before the old one stops:

wm_on_create_called:  [77903689, com.tns.NativeScriptActivity]
wm_on_start_called:   [77903689, com.tns.NativeScriptActivity]
wm_on_stop_called:    [253142999, com.tns.NativeScriptActivity]
wm_on_destroy_called: [253142999, com.tns.NativeScriptActivity]

Environment

  • @nativescript/core: built from main at 07e84ec58 (9.1.4-next.4)
  • @nativescript/android: 9.1.1
  • Device: Android emulator, API 36, x86_64
  • OS: Windows 11

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions