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 4881 - [Patch] Don't force OpenGL windows on Apple platforms
Summary: [Patch] Don't force OpenGL windows on Apple platforms
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: 2019-11-29 20:54 UTC by Caleb Cornett
Modified: 2019-12-08 20:10 UTC (History)
1 user (show)

See Also:


Attachments
Patch for the described issue (464 bytes, patch)
2019-11-29 20:54 UTC, Caleb Cornett
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Caleb Cornett 2019-11-29 20:54:27 UTC
Created attachment 4076 [details]
Patch for the described issue

SDL's current behavior on macOS and iOS automatically enables the SDL_WINDOW_OPENGL flag even if it's not specified. This is not necessarily correct, since apps can use Metal instead. In fact, I just encountered an app that crashed on startup on macOS when using a Metal rendering backend -- the reason being that it checks the window flags to determine whether to enable certain features, and since SDL_WINDOW_OPENGL is always forced on, the game incorrectly assumed it was using OpenGL.

The attached patch fixes the issue.
Comment 1 Alex Szpakowski 2019-12-01 19:31:57 UTC
I wonder if a more backwards-compatible fix would be to add a SDL_WINDOW_METAL flag and make the logic in the code there check for that flag before enabling SDL_WINDOW_OPENGL.
Comment 2 Alex Szpakowski 2019-12-01 19:36:14 UTC
That said, maybe backwards compatibility isn't very important for this case since people probably shouldn't rely on an opengl window always being created even when it isn't requested, but it's worth thinking about at least.
Comment 3 Caleb Cornett 2019-12-03 01:15:29 UTC
I thought about adding an SDL_WINDOW_METAL flag, but if avoiding this behavior is its only purpose, I'm not sure it's worth it.

After thinking about it some more, I'm still convinced the benefits here are worth the potential breakage. Any app that's not currently requesting a GL window is already working by luck alone, since it's in active violation of the intended API usage. And it wouldn't even work cross-platform, since Windows, Linux, and even tvOS don't create GL windows by default.
Comment 4 Sam Lantinga 2019-12-03 15:20:23 UTC
I agree that this is conceptually the right change, but I'd hate to break existing programs without a major version bump.

Is it possible to fix the crash with a Metal program?
Maybe we can add a Metal test program to catch regressions in the future?
Comment 5 Caleb Cornett 2019-12-08 20:10:07 UTC
Looks like this was solved in a more robust way by https://hg.libsdl.org/SDL/rev/881796f84081 so I'm going to go ahead and close this issue. Thanks for the input!
Comment 6 Caleb Cornett 2019-12-08 20:10:45 UTC
closing...