adrielcafe / voyager

🛸 A pragmatic navigation library for Jetpack Compose
https://voyager.adriel.cafe
MIT License
2.27k stars 109 forks source link

Recomposition issue when using nested Navigators and MaterialKolor #391

Open jordond opened 1 month ago

jordond commented 1 month ago

I'm the author of MaterialKolor, which is a library that generates a M3 MaterialTheme based off a seed color.

I was using both MaterialKolor and Voyager in my app when I noticed an issue that only happened on iOS. The initial rendering of the MaterialKolor DynamicMaterialTheme works just fine. But it will never be recomposed if the seed color changes.

I made a reproduction repo here. If you run the Android app, everything works fine. But if you run the iOS app, it won't recompose if you change the settings.

I've also got some recordings of what happens:

https://github.com/adrielcafe/voyager/assets/528792/97866f5b-7704-4834-8f59-5e138b6a784b

https://github.com/adrielcafe/voyager/assets/528792/034bae4e-dbc9-42fb-ab4d-426a8a5f8fe6

This only happens when the DynamicMaterialTheme sits outside of the Navigator composable.

I have tried both Voyager 1.0.0 and 1.1.0-alpha04, both experience the issue.

DevSrSouza commented 1 month ago

I will try to debug hit here soon. But based on that fact that Android works and iOS does not, it seems to be a Compose KMP issue on iOS.

liuhongjian0316 commented 2 weeks ago

I have the same problem. Have you solved it?

elijah-semyonov commented 2 weeks ago

Hey people, it seems to be a Compose Multiplatform issue, we are looking into it.

m-sasha commented 2 weeks ago

This appears to be a problem with the Compose Runtime, when using the single-argument CompositionLocalProvider with providesDefault.

Until it's fixed, you can use

CompositionLocalProvider(values = arrayOf(MyLocal providesDefault myValue)) { ... }

instead of

CompositionLocalProvider(MyLocal providesDefault myValue) { ... }
m-sasha commented 2 weeks ago

Ok, so actually it has already been fixed in Compose Multiplatform 1.6.10