bug: double navigation and navigation crashes
issue
spam clicking a button that navigates to a different screen can cause the navigation to occur multiple times
if the navigation in question is navigator::pop, it will crash the app if you navigate backwards at the root of the navigation
https://github.com/user-attachments/assets/ab3b348a-fb25-4ba9-9c50-340f3e71c275
in this video i'm spam clicking the settings button, observe how I have to click back many times because settings has been pushed many times
then i spam click the back button, which results in a crash
solution
wrap all navigations in dropUnlessResumed (this is recommended by google and it is what i am doing to resolve it in Navic)
it is very tedious to wrap everything in dropUnlessResumed and i don't want to make a massive change like that in every single file so i will leave this up to discussion for a better solution if needed
Ugh I forgot Navigation3 doesn't do this automatically.
@ssalggnikool dropUnlessResumed fixes double back but not double navigation in general, what did you use in Navic for that?
Apparently dropUnlessResumed will only work if you use it directly within the screen's composable, not within the entry provider:
https://slack-chats.kotlinlang.org/t/18829110/hey-guys-i-m-trying-to-wrap-my-head-around-the-new-dropunles
the above is not for navigation3, but the same thing could probably be the case here, not sure
this is the only thing I am doing differently in navic, so that could be why it's working there, but this doesn't really make any sense to me as the lifecycle owner should resolve to the same owner regardless of if you're inside of the entry provider or not. as an alternative you could check if the last back stack entry is not equal to the new entry you are pushing, and only push if that's the case, that is what I was doing before I learned dropUnlessResumed was a thing and it worked fine
I might just implement time debouncing at this point.