-
Notifications
You must be signed in to change notification settings - Fork 1.2k
macOS/iOS main thread safety #2464
Copy link
Copy link
Closed
Labels
B - bugDang, that shouldn't have happenedDang, that shouldn't have happenedDS - appkitAffects the AppKit/macOS backendAffects the AppKit/macOS backendDS - uikitAffects the UIKit backend (iOS, tvOS, watchOS, visionOS)Affects the UIKit backend (iOS, tvOS, watchOS, visionOS)S - enhancementWouldn't this be the coolest?Wouldn't this be the coolest?
Metadata
Metadata
Assignees
Labels
B - bugDang, that shouldn't have happenedDang, that shouldn't have happenedDS - appkitAffects the AppKit/macOS backendAffects the AppKit/macOS backendDS - uikitAffects the UIKit backend (iOS, tvOS, watchOS, visionOS)Affects the UIKit backend (iOS, tvOS, watchOS, visionOS)S - enhancementWouldn't this be the coolest?Wouldn't this be the coolest?
macOS and iOS have the pervasive concept of "main thread safety", which essentially just means that every UI operation has to happen on the main thread. We have some support for this in
macos::util::async, but this has been developed more on a case-by-case basis, which is not the way to do thread safety; remember, it is not just certain APIs that are thread unsafe, and the rest are fine, every API is thread unsafe unless documented otherwise!TODO
objc2: AllowCellin instance variables so that we don't need to use&mut selfEncodeandRefEncodeforUnsafeCellandCellmadsmtm/objc2#351winitthrough the XCode tools Thread Sanitizer and Main Thread CheckerWinitWindowrequires running on the main thread first.MainThreadBoundmadsmtm/objc2#344objc2AppState/HANDLERstruct into the main-thread onlyApplicationDelegate.HANDLERandAppState#3389MonitorHandleandFullscreenSend + Sync.HasWindowHandle::window_handlereturn an error when not on the main thread.