voyager icon indicating copy to clipboard operation
voyager copied to clipboard

Recomposition issue when using nested Navigators and MaterialKolor

Open jordond opened this issue 10 months ago • 6 comments

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.

jordond avatar Apr 11 '24 20:04 jordond

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.

DevSrSouza avatar Apr 12 '24 12:04 DevSrSouza

I have the same problem. Have you solved it?

liuhongjian0316 avatar Apr 30 '24 07:04 liuhongjian0316

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

elijah-semyonov avatar Apr 30 '24 15:04 elijah-semyonov

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 avatar May 02 '24 18:05 m-sasha

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

m-sasha avatar May 02 '24 18:05 m-sasha

I have the same issue: Compose 1.6.10 Kotlin 2.0.0 Voyager 1.1.0-beta02

Affected platforms: Android, Desktop, Web

But on Voyager 1.0.0 - all working correctly

devDebajo avatar Jul 29 '24 17:07 devDebajo