Assigned
Status Update
Comments
so...@google.com <so...@google.com>
al...@google.com <al...@google.com> #2
This actually has nothing to do with NavHostFragment, but is the behavior of NavController's setGraph().
When you call navController.setGraph(R.navigation.navigation_graph), it stores that ID and will restore that ID automatically.
If you were to instead use:
NavInflater navInflater = new NavInflater(this, navController.getNavigatorProvider());
navController.setGraph(navInflater.inflate(R.navigation.navigation_graph));
Then NavController would not restore the graph itself and the call to restoreState() you point out would only restore the back stack state, etc. but would wait for you to call setGraph again.
You're right that the inconsistency between the two setGraph methods is concerning. We'll take a look.
When you call navController.setGraph(R.navigation.navigation_graph), it stores that ID and will restore that ID automatically.
If you were to instead use:
NavInflater navInflater = new NavInflater(this, navController.getNavigatorProvider());
navController.setGraph(navInflater.inflate(R.navigation.navigation_graph));
Then NavController would not restore the graph itself and the call to restoreState() you point out would only restore the back stack state, etc. but would wait for you to call setGraph again.
You're right that the inconsistency between the two setGraph methods is concerning. We'll take a look.
al...@google.com <al...@google.com> #3
Turns out, we already had a tracking bug for this issue, will follow up on that other one.
Description
Kotlin version: 1.9.24
Our users have crashes, we see them in firebase. There are quite a few of them. We can't reproduce them, there are no full logs either. All we are sure of is that the Compose update is to blame for these crashes. As soon as we rolled back Compose to 1.6.8 - the crashes disappeared. Almost all of them are on Samsung on Android 14, including the latest models.
Crashes are repeated, users cannot enter the application, this happens on our main screen.
InsetsPaddingModifier is present in the logs, but we couldn't find their installation on our home screen.
We will be glad for any help, thank you.
Stack trace:
```
main (runnable):tid=1 systid=25941
at androidx.compose.runtime.snapshots.SnapshotKt.newOverwritableRecordLocked(Snapshot.kt)
at androidx.compose.runtime.snapshots.SnapshotKt.overwritableRecord(Snapshot.kt:2225)
at androidx.compose.runtime.SnapshotMutableStateImpl.setValue(SnapshotState.kt:320)
at androidx.compose.foundation.layout.InsetsPaddingModifier.setUnconsumedInsets(WindowInsetsPadding.kt:492)
at androidx.compose.foundation.layout.InsetsPaddingModifier.onModifierLocalsUpdated(WindowInsetsPadding.kt:371)
at androidx.compose.ui.node.BackwardsCompatNode$updateModifierLocalConsumer$1.invoke(BackwardsCompatNode.kt:275)
at androidx.compose.ui.node.BackwardsCompatNode$updateModifierLocalConsumer$1.invoke(BackwardsCompatNode.kt:271)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2441)
at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:502)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:258)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
at androidx.compose.ui.node.BackwardsCompatNode.updateModifierLocalConsumer(BackwardsCompatNode.kt:271)
at androidx.compose.ui.node.BackwardsCompatNodeKt$updateModifierLocalConsumer$1.invoke(BackwardsCompatNode.kt)
at androidx.compose.ui.node.BackwardsCompatNodeKt$updateModifierLocalConsumer$1.invoke(BackwardsCompatNode.kt:444)
at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.notifyInvalidatedScopes(SnapshotStateObserver.java:1147)
at androidx.compose.runtime.snapshots.SnapshotStateObserver$sendNotifications$1.invoke(SnapshotStateObserver.kt:90)
at androidx.compose.runtime.snapshots.SnapshotStateObserver$sendNotifications$1.invoke(SnapshotStateObserver.kt:83)
at androidx.compose.ui.platform.AndroidComposeView$snapshotObserver$1.invoke(AndroidComposeView.android.kt:475)
at androidx.compose.ui.platform.AndroidComposeView$snapshotObserver$1.invoke(AndroidComposeView.android.kt:473)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.sendNotifications(SnapshotStateObserver.java:83)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.access$sendNotifications(SnapshotStateObserver.java:43)ы
at androidx.compose.runtime.snapshots.SnapshotStateObserver$applyObserver$1.invoke(SnapshotStateObserver.kt:50)
at androidx.compose.runtime.snapshots.SnapshotStateObserver$applyObserver$1.invoke(SnapshotStateObserver.kt:48)
at androidx.compose.runtime.snapshots.SnapshotKt.advanceGlobalSnapshot(Snapshot.kt:1945)
at androidx.compose.runtime.snapshots.SnapshotKt.advanceGlobalSnapshot(Snapshot.kt:1960)
at androidx.compose.runtime.snapshots.SnapshotKt.access$advanceGlobalSnapshot(Snapshot.kt:1)
at androidx.compose.runtime.snapshots.Snapshot$Companion.sendApplyNotifications(Snapshot.kt:692)
at androidx.compose.ui.platform.GlobalSnapshotManager$ensureStarted$1.invokeSuspend(GlobalSnapshotManager.android.kt:48)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
at androidx.compose.ui.platform.AndroidUiDispatcher.performTrampolineDispatch(AndroidUiDispatcher.android.kt:81)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performTrampolineDispatch(AndroidUiDispatcher.java:41)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.run(AndroidUiDispatcher.android.kt:57)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8919)
at java.lang.reflect.Method.invoke(Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
```