pointfreeco / swift-composable-architecture

A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.
https://www.pointfree.co/collections/composable-architecture
MIT License
12.57k stars 1.46k forks source link

NavigationStack StackState and SwiftUI get out of sync creating weird issues (EmptyViews, or actions not working) #3450

Closed era2099 closed 3 weeks ago

era2099 commented 4 weeks ago

Description

Hi, I have a project that uses SwiftUI, where we have a TabView, and in one of the tabs, I have a NavigationStack(path:). And created a logic to clear the NavigationStack path everytime you change to another Tab.

But found a bug, that if for some reason when doing a navigation in the NavigationStack, and rapidly tapping to another Tab when the navigation animation transition is happening, the NavigationStack doesn't gets clean up but the StackState by that moment is already empty and it can't triggered the actions.

Is there a way to maintain in sync the StackState with SwitfUI?

Checklist

Expected behavior

The StackState should be sync with SwiftUI and the actions can still be triggered.

Actual behavior

The StackState is already empty, and the actions can't be triggered. Getting purple warnings

Reproducing project

TestProject.zip

The Composable Architecture version information

Found the issue here:0.57.0 and then update to: 1.7.0 but still having the issue

Destination operating system

iOS 17.6.1

Xcode version information

Xcode 15.0

Swift Compiler version information

swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
Target: arm64-apple-macosx14.0
mbrandonw commented 3 weeks ago

Hi @era2099, your project runs fine in the newest version of the library, and so the issue must have been fixed sometime after 1.7. Since this isn't an issue with the library I am going to convert it to a discussion. Please feel free to continue the conversation over there!