StackState and NavigationStack occasionally get out of sync under specific circumstances #2810
djangovanderheijden
started this conversation in
General
Replies: 1 comment
-
Hi @djangovanderheijden, I'm not really sure this is a TCA bug. It seems far more likely to be a vanilla SwiftUI bug, and I would recommend trying to reproduce in vanilla SwiftUI. I'm going to convert this to a discussion for now and please do share any findings you come across in the future. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
I've run into an issue where occasionally, items appended to the
StackState
are not pushed onto SwiftUI'sNavigationStack
. It's a bit of a tricky one as the problem seems to be timing related and can happen more or less often depending on your project setup. In my real-life project the problem occurs far more often, probably due to some unfortunate timing.Note that I am unsure whether this is a TCA or SwiftUI problem. I have not been able to reproduce it in vanilla SwiftUI but the behavior is flaky enough that I can't be certain.
Checklist
main
branch of this package.Expected behavior
I expect
StackState
andNavigationStack
to always remain in sync under normal circumstances.Actual behavior
The recording below is the attached gist (see steps to reproduce) running on my iPhone 13 Mini. I tap the center button to append an item to the
StackState
, then tap the back button to pop it again. TheStackState
's collection of IDs is displayed at the bottom of the screen.As you can see, the
NavigationStack
occasionally doesn't navigate to the new destination even though theStackState
is updated. (StackElementID 40 at 0:08 and StackElementID 53 at 0:32)NavigationStackSync.MOV
Steps to reproduce
I've set up an example project that showcases the issue:
https://gist.github.com/djangovanderheijden/ec70561f9483c88cff7b453dcc742e79
Sorry for the bulkiness, this is about as small as I've been able to get the reproducible example. I've added some comments in important spots.
Also note that as the issue is seemingly timing related, the behavior on your device may differ. I have not been able to reproduce this issue in the simulator.
The Composable Architecture version information
1.8.0
Destination operating system
17.2.1
Xcode version information
15.2 (15C500b)
Swift Compiler version information
Beta Was this translation helpful? Give feedback.
All reactions