swift-composable-architecture
swift-composable-architecture copied to clipboard
Crash when using @Shared appStorage during certain conditions
Description
I'm seeing a crash with a similar backtrace to https://github.com/pointfreeco/swift-composable-architecture/issues/3247, but appears not to be caused by a thread issue.
I'm using a @Shared appStorage key roughly like:
@Shared(.appStorage("key")) var isEnabled: Bool = true
When launching the app it crashes. I'm still working on a simplified repro but having a hard time isolating the exact code causing the problem, but thought I'd post the issue in case anyone else has an idea.
If you look at the backtrace, it appears an NSAttributedString
is performing layout (which isn't in my code) which triggers an NSUserDefault
update which in turn causes the @Shared
storage to update immediately during the same render cycle?The only relevant logs related to the crash are:
precondition failure: setting value during update: 219864
Checklist
- [ ] I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
- [ ] If possible, I've reproduced the issue using the
main
branch of this package. - [X] This issue hasn't been addressed in an existing GitHub issue or discussion.
Expected behavior
No response
Actual behavior
No response
Steps to reproduce
No response
The Composable Architecture version information
1.13.1
Destination operating system
iOS 17.5
Xcode version information
Xcode 15.4
Swift Compiler version information
No response