NativeScript/nativescript-angular

(android) Navigation does not work when the app is started while the device is locked

facetious opened this issue · 4 comments

Environment

  • CLI: 8.1.2
  • @nativescript/core: 8.1.2
  • @nativescript/android: 8.1.1
  • @nativescript/angular: 12.2.0
  • @angular/*: 12.2.5

Describe the bug
Using ns run android when the device is locked causes navigations to not work. Angular routing is still present (as inspected via { enableTracing: true }), and components are still loaded. The new screens are not made visible, though.

Everything works as expected when the device is unlocked at the time of the app launch.

Expected behavior
Navigation should work.

Sample project
https://github.com/facetious/nativescript-angular-issue-2370

Steps to Reproduce

  1. Checkout the repo.
  2. Connect an Android device for development, but lock the screen.
  3. Run ns run android

Navigation to any item in the list is indicated in the console, but the screen does not update.

@facetious does this not happen with core NativeScript? I know that core stops all native updates when the screen is off, so it's probably some native updates that aren't being applied.

@edusperoni I actually don't know. I encountered this issue because I typically have the phones locked on my desk, then unlock them when I'm testing something out. These navigations aren't triggered while the screen is locked; I am tapping on something on screen, the Angular tracing agrees, and any trace messages in put in the to-be-shown component appear as though it was presented on screen. But the screen doesn't actually navigate. The app isn't frozen; I can tap on other things and have more Angular tracing logs come out, but still no navigation.

Disappointingly, when I have tried to reproduce this quickly in a fresh project, it doesn't happen. So I'm going to have to figure out what complicated sequence of failures has caused this to happen in my app.

I have narrowed this issue down to an explicit navigation that is being made (after the initial Angular routing settles). If I delay the automatic "go to the next screen" until the app is in the foreground, everything operates normally. It should be possible to create a small project exhibiting this behaviour with this understanding.