GrapheneOS / Info

MIT License
10 stars 7 forks source link

set saveState and restoreState to false for nav bar navigation to prevent restore state failure crashing #5

Closed soupslurpr closed 3 months ago

soupslurpr commented 3 months ago

To reproduce the crash (might take a few tries): go to Donate then GitHub Sponsors (or any other sub-screen I think) then go to the home screen. Come back to the app and go to the Community tab then go to the home screen again.

thestinger commented 3 months ago

@soupslurpr Can you explain this? Does it lose any functionality?

soupslurpr commented 3 months ago

Oops I forgot to say. The only thing that's lost is when going from Donate (or other navigations but we don't have any others yet) to another nav bar entry and coming back, it goes back to Donate's startDestination instead of the screen it was on (like Cryptocurrencies for example).

I think the issue is some sort of race condition related to being in a sub-screen when setting the new startDestination when leaving the app.

thestinger commented 3 months ago

Ideally it can be fixed properly. Any idea how to approach that?

soupslurpr commented 3 months ago

Maybe this is the proper fix, I'm not sure what the cause of the issue is exactly. It being hard to reproduce makes it difficult to debug further.

thestinger commented 3 months ago

@soupslurpr I mean a fix preserving restoring the current state fully.

soupslurpr commented 3 months ago

Oh, I don't know if that's possible. It being hard to reproduce makes it difficult to try that.

soupslurpr commented 3 months ago

Found how to reproduce consistently and I think I know the actual cause now.

To reproduce: go to Donate > Cryptocurrencies, then go to home screen. Go back into app and it should be at the Donate start screen. Go into Cryptocurrencies again, then go to Release Notes or Community. Now go to the home screen and the app will crash.

So the cause is just leaving Donate in a screen that isn't start when setting the new startDestination to another nav bar entry.

I'll try to find a better solution in 9 hours.

soupslurpr commented 3 months ago

Fixed while preserving the restoration of the state!