-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when using @Shared appStorage during certain conditions #3311
Comments
Hi @zachwaugh, thanks for the report, but unfortunately without a repro it's hard to diagnose. The precondition failure message ("precondition failure: setting value during update") seems to clearly describe the problem: in the act of executing a view's body a value is being mutated. If you do this with Only one idea comes to mind. In the stack trace we have Are you in a position to reproduce this precondition easily in your local environment? Would you be willing to try replacing |
Getting a similarily suspicious crash on writing to We started getting this crash after updating to 1.14.0 from 1.12.1.
|
Hi @andreyz, your crash does not seem to be related to the one discussed here. The one in this issue has stack frames with And as always, a reproduction is the best way to get help on this. |
I think we're finding that synchronous subscriptions can be problematic depending on the strategy, for example as we're seeing with user defaults notifications being fired by attributed string's internals. Fixes #3311.
@zachwaugh Can you give #3437 a try and see if it addresses things for you? |
Same issue when using |
@stephencelis I've removed use of |
Description
I'm seeing a crash with a similar backtrace to #3247, but appears not to be caused by a thread issue.
I'm using a @shared appStorage key roughly like:
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 anNSUserDefault
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:Checklist
main
branch of this package.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
The text was updated successfully, but these errors were encountered: