Giter VIP home page Giter VIP logo

Comments (15)

ArleyPereira avatar ArleyPereira commented on July 21, 2024 2

You can browse based on state and every time you browse, you clear the state immediately.

LaunchedEffect(state.navigateToScreen) {
    state.navigateToScreen?.let {
        navigationToConfirmRegister()
        action(SignupAction.ClearNavigate)
    }
}

from voyager.

Moozart avatar Moozart commented on July 21, 2024 1

I think problem occurs when multiple click to navigate or same screen popud. If u remove SlideAnimation etc.. error can be gone. But I applied this solution for my project. I hope solver your problem.

override val key: ScreenKey = super.key + "${Random.nextDouble(Double.MIN_VALUE, Double.MAX_VALUE)}"

from voyager.

itsallan avatar itsallan commented on July 21, 2024 1

I think problem occurs when multiple click to navigate or same screen popud. If u remove SlideAnimation etc.. error can be gone. But I applied this solution for my project. I hope solver your problem.

override val key: ScreenKey = super.key + "${Random.nextDouble(Double.MIN_VALUE, Double.MAX_VALUE)}"

thanks mate this worked for me

from voyager.

wiryadev avatar wiryadev commented on July 21, 2024 1

I will test 'dropUnlessResumed' for click

Last time i tried, it doesnt work. So i use debounced click instead from this.

from voyager.

ArleyPereira avatar ArleyPereira commented on July 21, 2024

Thanks for your tip. I will try to apply it, while there is no solution from the library. From what I've seen, this error has been known for some time, but so far it still persists.

from voyager.

wiryadev avatar wiryadev commented on July 21, 2024

Face the same error. I used the 1.0.0 tho.

Edit: i tried 1.1.0 alpha04 and still the transition error

from voyager.

qdsfdhvh avatar qdsfdhvh commented on July 21, 2024

I face the same crash,but i am upgrading to kotlin 2.0.0-RC2 and use release apk (r8), when I had open a object screen, and then open another object screen, app will be crash with it, i'm not sure what's the reason for that at the moment.
ps: seem use data object can solve my problem.

from voyager.

wiryadev avatar wiryadev commented on July 21, 2024

Hi, i just found out something:

  1. dropUnlessResumed not working for this, not because of lifecycle owner, but when you click that quickly, the state is still resumed (check screenshot below)
  2. We can pass our own LifecycleOwner, but make sure you use LocalLifecyleOwner from androidx.compose.ui.platform, not the one from androidx.lifecycle.compose.

image

from voyager.

DevSrSouza avatar DevSrSouza commented on July 21, 2024

Does this also happen when using override val key = uniqueScreenKey ?
https://voyager.adriel.cafe/state-restoration#identifying-screens

from voyager.

ArleyPereira avatar ArleyPereira commented on July 21, 2024

The error does not occur when I use 'override val key = uniqueScreenKey', but there is duplication of navigation. I will test 'dropUnlessResumed' for click

from voyager.

adrict99 avatar adrict99 commented on July 21, 2024

Same is happening to me, if I remove SlideTransition I lose "back" functionality using if (navigator.canPop) navigator.pop(), and if I have SlideTransition, when I do navigator.pop() it shows the same screen from where I'm navigating after animating like if it was going to a different one.

But in this project: https://github.com/YanneckReiss/compose-multiplatform-navigation-voyager-showcase it is working somehow

from voyager.

elsheikhayman avatar elsheikhayman commented on July 21, 2024

I faced this problem too when a navigation button was clicked twice quickly, causing the app to crash during the transition. My solution was to check if the destination screen is the same as the current one and avoid calling navigator.push. Here's the extension on the Navigator I made:

private inline fun <reified T : Screen> Navigator.navigate(screen: T) { if (lastItem !is T) { push(screen) } }

usage:
navigator.navigate(OnBoardingStep2Screen())

Hope this helps!

from voyager.

adrict99 avatar adrict99 commented on July 21, 2024

@elsheikhayman Thank you for your comment! I tried it, but unfortunately it didn't work for me. I debugged the stack items and the last item and apparently it is fine and no screen is present twice, also the last screen in the stack is always the one I'm in.

The navigation is ScreenA -> ScreenB -> ScreenC, and for some reason I can't do pop or popUntil to navigate back, but I can do popAll or popUntilRoot.

When I click on a something that uses pop or popUntil in ScreenC, the stack gets printed like: stack -> ScreenA,ScreenB, lastItem -> ScreenB, just after that it automatically prints: stack -> ScreenA,ScreenB,ScreenC, last item -> ScreenC, like if it was navigating again to the same screen where it is.

from voyager.

adrict99 avatar adrict99 commented on July 21, 2024

I got it working after long debugging, I realized I was holding the screen state and actions in the screen model with a sealed interface, creating a mutableStateFlow, and subscribing to it via observeAsState in the Screen to respond appropriately, if I remove this the navigation works perfectly, I don't get the "Transition was used multiple times" (with and without SlideTransition) and even the pop function works.

It is the only solution I got working, but I don't like handling states in the UI, is this going to be fixed anytime soon or am I doing something wrong? Thanks

Edit:
If I use the state as described in https://voyager.adriel.cafe/screenmodel/coroutines-integration/, and I don't navigate based on the subscribed state it also works, but I think this is not how it should work.

Edit 2:
If you put a log on every screen to debug the navigation Stack you will see that it gets printed multiple times, if you navigate based on a subscribed state, it's not going to work fine since you will be doing it multiple times or at least that's my theory at the moment. No subscribed navigation, no problem.

from voyager.

KhubaibKhan4 avatar KhubaibKhan4 commented on July 21, 2024

Does this also happen when using override val key = uniqueScreenKey ? https://voyager.adriel.cafe/state-restoration#identifying-screens

No it Doesn't work with uniqueScreenKey.

from voyager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.