Apparent deadlock setting optional Shared property to nil #3175
-
Please see: https://github.com/humblehacker/TCASharedState2 In this example, I have a reducer with two children. The first has an optional shared property, while the second has a non-optional. Tapping the "Toggle" button should toggle the optional property between Oddly, this only happens if there is at least one other shared property in the app. To see this, comment out So, my question is, what am I doing wrong? Note that this and my previous bug report turned discussion were discovered while attempting to isolate the source of a problem encountered while using shared state in my app. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @humblehacker, thanks for the report. Yeah this one is a real issue, and we should have made I have a fix PR'd here and it will be released with 1.12. |
Beta Was this translation helpful? Give feedback.
Hi @humblehacker, thanks for the report. Yeah this one is a real issue, and we should have made
withLock
run on the@MainActor
from the beginning. We thought about making@Shared
main actor entirely, but that seemed to be going too far. However,withLock
definitely needs to be@MainActor
.I have a fix PR'd here and it will be released with 1.12.