| Summary: | [Patch] Don't force OpenGL windows on Apple platforms | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Caleb Cornett <spydog> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | amaranth72 |
| Version: | HG 2.0 | ||
| Hardware: | x86 | ||
| OS: | macOS 10.15 | ||
| Attachments: | Patch for the described issue | ||
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. 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. 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. 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? 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! closing... |
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.