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 4278

Summary: On macOS Mojave: Program hangs when using SDL Renderer one one thread and OpenGL on another
Product: SDL Reporter: Daniel Bokser <dan.bokser>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: dan.bokser, icculus, sezeroz
Version: 2.0.8   
Hardware: x86_64   
OS: Mac OS X (All)   
Attachments: Simple program with SDL Renderer on main thread and OpenGL on another

Description Daniel Bokser 2018-09-28 00:00:59 UTC
Created attachment 3320 [details]
Simple program with SDL Renderer on main thread and OpenGL on another

On Mojave and Xcode 10, my program hangs after a few seconds when rendering using an SDL Renderer on the main thread and using OpenGL on another. I have attached a simple program that demonstrates this.  Looks like both thread are stuck on [nsContext flushBuffer] in Cocoa_GL_SwapWindow() in SDL_cocoaopengl.m. This is with Ryan's fix on https://bugzilla.libsdl.org/show_bug.cgi?id=4272

This program works fine when compiling with Xcode 9.
Comment 1 Ryan C. Gordon 2018-10-19 03:39:10 UTC
Mojave appears to have a deadlock if you swap two separate windows/contexts from two separate threads at the same time; I stuck a mutex around our swap code which appears to fix it.

That fix is https://hg.libsdl.org/SDL/rev/84eaa0636bac

--ryan.
Comment 2 Daniel Bokser 2018-10-23 03:48:59 UTC
Thank you! This fixed the deadlock issue for me.  However, my SDL project is still not completely fixed in Mojave.  I have opened up another issue here: https://bugzilla.libsdl.org/show_bug.cgi?id=4329