Comments (15)
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.
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.
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.
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.
I will test 'dropUnlessResumed' for click
Last time i tried, it doesnt work. So i use debounced click instead from this.
from voyager.
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.
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.
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.
Hi, i just found out something:
dropUnlessResumed
not working for this, not because of lifecycle owner, but when you click that quickly, the state is still resumed (check screenshot below)- We can pass our own LifecycleOwner, but make sure you use LocalLifecyleOwner from
androidx.compose.ui.platform
, not the one fromandroidx.lifecycle.compose
.
from voyager.
Does this also happen when using override val key = uniqueScreenKey
?
https://voyager.adriel.cafe/state-restoration#identifying-screens
from voyager.
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.
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 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.
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.
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)
- Wasm URL routing support HOT 1
- Lifecycle Events Not Triggered During Screen Navigation HOT 4
- ScreenModel function goes into infinite loop when calling from screen HOT 2
- Screen Overridable Content function call multipleTimes when pass data from one Screen to another in Android project.
- Crash on implementing ScreenLifecycleOwner HOT 2
- Crashing When The App Starts Up Again, After been Minimized For a period of Time HOT 1
- App Crashes, When The Button to Navigate to Another Screen, Is Pressed Twice in Succession
- Help on using new navigatorViewModel
- IllegalStateException when close window on Compose Multiplatform for Desktop
- viewmodel not destroy in recomposition state HOT 1
- TabNavigator not Allowing Theme change HOT 3
- Provide onDispose callback in the LifecycleEffectOnce api HOT 1
- ReferenceError: getCachedJsObject is not defined HOT 3
- TabNavigator inside Screen not working
- System WindowInsets Not Consumed on iOS Targets When using Nested Navigators HOT 6
- Tab Navigator Deeplink HOT 1
- Not working with latest version of compose multiplatform and kotlin HOT 1
- TabNavigator
- android.os.BadParcelableException: Parcelable encountered IOException when screen is off
- Can't switch dark theme in compose-m3 1.2.0+ and NestedNavigator HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from voyager.