NativeScript / nativescript-angular

Integrating NativeScript with Angular
http://docs.nativescript.org/angular/tutorial/ng-chapter-0
Apache License 2.0
1.22k stars 241 forks source link

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

Open facetious opened 3 years ago

facetious commented 3 years ago

Environment

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.

edusperoni commented 3 years ago

@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.

facetious commented 3 years ago

@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.

facetious commented 3 years ago

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.

facetious commented 3 years ago

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.