Is there an existing issue for this?
Describe the problem
In current implementation of NiaApp, we've observed an issue where unrelated state changes, such as modifications to showSettingsDialog, trigger unnecessary recompositions across the entire app, including within NiaNavHost and its child screens
Upon investigation, we identified that lambda expressions, such as onTopicClick, are being recreated with each recomposition cycle. Compose treats these newly instantiated lambda expressions as different from their predecessors, thus triggering recompositions even when there are no pertinent state changes.

this behavior will persist until the Jetpack Compose Compiler is updated to version 1.7, which is expected to introduce an enhanced 'Strong skipping' mode for more efficient recomposition skipping. In the meantime, developers are advised to manage lambda instances manually using remember to mitigate unnecessary recompositions.
This is particularly evident in screens like ForYouScreen, where the onTopicClick lambda is passed down and utilized. Despite showSettingsDialog having no direct relation to these screens, they undergo recomposition, leading to performance inefficiencies.
Describe the solution
I propose to mitigate this issue by employing the remember construct to cache navigation-related lambda expressions within NiaNavHost. This approach will ensure that lambdas are only recreated when genuinely necessary, such as when the NavController instance changes
change

before

after

Additional context
No response
Code of Conduct
Is there an existing issue for this?
Describe the problem
In current implementation of NiaApp, we've observed an issue where unrelated state changes, such as modifications to showSettingsDialog, trigger unnecessary recompositions across the entire app, including within NiaNavHost and its child screens
Upon investigation, we identified that lambda expressions, such as onTopicClick, are being recreated with each recomposition cycle. Compose treats these newly instantiated lambda expressions as different from their predecessors, thus triggering recompositions even when there are no pertinent state changes.
this behavior will persist until the Jetpack Compose Compiler is updated to version 1.7, which is expected to introduce an enhanced 'Strong skipping' mode for more efficient recomposition skipping. In the meantime, developers are advised to manage lambda instances manually using remember to mitigate unnecessary recompositions.
This is particularly evident in screens like ForYouScreen, where the onTopicClick lambda is passed down and utilized. Despite showSettingsDialog having no direct relation to these screens, they undergo recomposition, leading to performance inefficiencies.
Describe the solution
I propose to mitigate this issue by employing the
rememberconstruct to cache navigation-related lambda expressions withinNiaNavHost. This approach will ensure that lambdas are only recreated when genuinely necessary, such as when theNavControllerinstance changeschange
before
after
Additional context
No response
Code of Conduct