-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
macos: SDL_Init(SDL_INIT_VIDEO)
off the main thread throws an uncaught objective C exception
#11437
Comments
This happens with both SDL 2 and SDL 3 |
Almost all SDL_video APIs are disallowed on non-main threads on apple platforms, not just video subsystem initialization – they'll all definitely crash if the main thread checker is enabled (https://developer.apple.com/documentation/xcode/diagnosing-memory-thread-and-crash-issues-early), and many will even without it. Since that restriction is already documented, IMO the current behaviour is pretty reasonable compared to all the extra checks needed in SDL's code to add more graceful failures. That link also says:
|
I'm not asking for checks to be added to every SDL function. I don't think it's unreasonable to add a check to |
Actually |
I believe you're meant to pump events on the main thread if you call those from a non-main thread, I might be misremebering though. |
On macos, if
SDL_Init(SDL_INIT_VIDEO)
is called on a thread other than the main thread, it'll throw an objective C exception and pop up a macos crash dialog.I'd expect
SDL_Init
to return false and set an error message instead.I ran into this while trying to call some SDL functions in automated tests. The test runner runs the tests in a separate thread by default.
Reproduction:
This pops up a crash dialog and prints
followed by a stack trace
The text was updated successfully, but these errors were encountered: