We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5046 - Crash on window resize when rendering on another thread
Summary: Crash on window resize when rendering on another thread
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86 macOS 10.15
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-20 08:56 UTC by Emir Marincic
Modified: 2020-03-20 19:10 UTC (History)
0 users

See Also:


Attachments
performSelectorOnMainThread patch (831 bytes, text/plain)
2020-03-20 08:56 UTC, Emir Marincic
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Emir Marincic 2020-03-20 08:56:40 UTC
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
Comment 1 Sam Lantinga 2020-03-20 19:10:23 UTC
Looks good, thanks!
https://hg.libsdl.org/SDL/rev/c8f27a5e868e