-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] When device locked/using another app, if Navigation occurs it will fail and leave the app in a broken state #21113
Comments
Can you test with the latest nightly build? |
I've updated my sample to use I was curious and found that 8.0.10-nightly.10196 was the first one with the fix. I think it was this PR that resolved the issue: #19532 |
@PureWeen Is this issue supposed to be fixed in 8.0.10? I can still reproduce this using a NavigationPage and navigating while the app is in background. The console message |
@PureWeen The issue still occurs when the initial navigation is done while the app is in background (use sample app:
|
Can you log a new issue please? |
Description
When doing navigation, it isn't always happening immediately after a user's button press. Sometimes an app may need to do some processing or sometimes the page switch may be on a timer (for example, you may only want allow a user access to a screen for 1 minute before removing them from that page).
If the user decides to lock their Android phone or switch to another app, the app can get into a broken state if the navigation happens during this period. In the console when debugging, I can see this:
[FragmentNavigator] Ignoring navigate() call: FragmentManager has already saved its state
which presumably means Android is trying to save a state for the app which is causing problems with MAUI's navigation attempt.With Java Exceptions ticked in Exception Settings, you will hit this error on any navigation related lines:
In the below video, I first demonstrate the navigation if you stay in the app at all times. I then demonstrate pressing the button, locking the device, and returning to find the app in a broken state. The user must restart the app to get things back to normal again.
lockscreen-repro.mp4
Steps to Reproduce
Expected
The app performs the navigation and when you resume the app, it is on the new page as expected
Actual
The app tries to perform the navigation but it conflicts with Android state saving. This can leave the app in a broken state. A few examples of what I've seen:
Blank screen
The new page's navigation bar over the top of the original page
The original page with a back button when it shouldn't have one
I have to imagine this will cause difficult to reproduce issues for many apps. I think any app that does something like an API call on a button press where after the API call, a page is pushed or popped, the app will get into an unrecoverable state.
Link to public reproduction project repository
https://github.com/BurkusCat/NavigationWhenLockedMauiRepro
Version with bug
8.0.7 SR2
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 14. I'm assuming other versions too
Did you find any workaround?
No workaround found. I tried using Dispatcher/BeginInvokeOnMainThread/ConfigureAwait(false) and I tried different Android LaunchMode's. I couldn't find anything that resolved the issue.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: