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 4329

Summary: SDL OpenGL window permenantly black on second thread when inited later in the program on Mojave
Product: SDL Reporter: Daniel Bokser <dan.bokser>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED WONTFIX QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: amaranth72, dan.bokser, icculus, marcus.zetterquist, sezeroz
Version: 2.0.9   
Hardware: x86_64   
OS: Mac OS X (All)   
Attachments: Test program
(maybe) Simplified test program
Very simple demo of problem, as described in my post.

Description Daniel Bokser 2018-10-23 03:46:59 UTC
Created attachment 3392 [details]
Test program

When a SDL OpenGL window is opened after an SDL_PollEvent, and is rendered on a second thread in macOS Mojave, the window is permanently black.  I have attached a sample program with this structure.  This program works fine in Linux and while I have confirmation that this exact program works on High Sierra, my SDL project which has this structure worked fine on High Sierra.

This occurs with all latest fixes on 2.0.9
Comment 1 Daniel Bokser 2018-10-23 11:58:53 UTC
Clarification: 
>while I have confirmation that this exact program works on High Sierra
 should be 
>while I do NOT have confirmation that this exact program works on High Sierra
Comment 2 Ryan C. Gordon 2018-10-23 18:03:46 UTC
Created attachment 3394 [details]
(maybe) Simplified test program


I've been working on this for hours and hours, and I can't coerce this to work. If LATE_INIT is zero, it works, if it's one, it doesn't.

Same result with SDL's render API (USE_RENDERER 1) or just using OpenGL from two threads, so it's not an SDL renderer bug.

I think it's a macOS bug, honestly. I haven't found a workaround, beyond creating all the contexts upfront.
Comment 3 Daniel Bokser 2018-10-24 12:06:50 UTC
Ah that sucks. Maybe I will try to file a bug with Apple, even though it will probably be futile.  For some reason even after uninstalling Xcode 10 and installing Xcode 9, it still seems linking to the Xcode 10 libs, so gotta figure that out now.  Thank you very much for trying!
Comment 4 marcus.zetterquist 2018-10-28 03:11:22 UTC
I have similar problem while running *one* thread. See super-simple "test3.cpp". If I call SDL_PollEvent(), then drawing wont happen. I need to manually move window first.

Found another similar report on stackoverflow: https://stackoverflow.com/questions/51992402/sdl-pollevent-prevents-render-unless-window-moved-or-resized

This may be a showstopper on Mojave. I'm just starting using SDL so I might missed something though.

In test program, "#if 1" will give me black window. "#if 0" will give me a blue window.
Comment 5 marcus.zetterquist 2018-10-28 03:12:45 UTC
Created attachment 3403 [details]
Very simple demo of problem, as described in my post.
Comment 6 Alex Szpakowski 2018-10-28 13:09:26 UTC
Are you using the latest SDL source code? There was a separate bug report for that which had some fixes go into SDL recently: https://bugzilla.libsdl.org/show_bug.cgi?id=4272
Comment 7 marcus.zetterquist 2018-10-28 16:54:01 UTC
I'm using stable 2.0.8. True, my problem does indeed seem to match bug 4272 better. Sorry for noise.
Comment 8 Sam Lantinga 2018-11-02 23:46:46 UTC
Please reopen this bug if it isn't fixed in 2.0.9.

Thanks!
Comment 9 Daniel Bokser 2018-11-04 23:02:28 UTC
Confirmed that this bug is not fixed in 2.0.9.
Comment 10 Ryan C. Gordon 2018-11-04 23:52:51 UTC
(In reply to Daniel Bokser from comment #9)
> Confirmed that this bug is not fixed in 2.0.9.

I think Sam was talking to Marcus (who was reporting the same issue as Bug #4272) ... the initial bug reported here is believed to be a macOS Mojave bug, and beyond our control, at least with current beliefs. If a workaround is found, I'm happy to revisit, but right now I'm out of ideas.

--ryan.