Do update to @Observable properties have to be done on the main thread?

To confirm, while @Observable is itself thread-safe and seems to work fine when updates are written and consumed from different threads, the way SwiftUI does it definitely does not comply with this expectation, and it can randomly skip update events on Sendable types if they happen "too often" (more that once within the same run loop iteration) — even when the changes are recorded in compliance with the proposal as written here.

I've recently filed feedback with Apple for this, but unfortunately I don't have the ticket number for it anymore. In any case, you should keep writing updates only from within the main actor.

3 Likes