| Summary: | Crash on window resize when rendering on another thread | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Emir Marincic <learath2> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.0 | ||
| Hardware: | x86 | ||
| OS: | macOS 10.15 | ||
| Attachments: | performSelectorOnMainThread patch | ||
Looks good, thanks! https://hg.libsdl.org/SDL/rev/c8f27a5e868e |
Created attachment 4271 [details] performSelectorOnMainThread patch Resizing a window schedules an update on the SDLOpenGLContext, the next swap on the auxiliary thread doing the rendering causes a [NSOpenGLContext update] on that thread, which is not allowed. [NSOpenGLContext update] only started checking whether it's called from the main thread (through pthread_main_np) from Catalina onwards and AppKit uses _CFExecutableLinkedOnOrAfter to provide compatibility for older executables by setting NSOpenGLContextSuppressThreadAssertions. I'm not sure if this should be supported but swapping on a separate thread works on enough platforms that we didn't notice this bug for years. Calling update on the main thread instead through performSelectorOnMainThread seems to work fine and after testing a couple of hours I didn't notice any undesired effects. I've attached the patch I've been testing locally Best regards Emir