Page MenuHomeWildfire Games

Workaround for the SDL bug on macOS Mojave
AbandonedPublic

Authored by Itms on Nov 9 2018, 10:03 PM.

Details

Reviewers
trompetin17
Trac Tickets
#5341
Summary

On macOS Mojave, the game will start black; the correct fix would be to upgrade SDL and use the Metal framework, which would make us drop versions 10.9 to 10.11.
Alternatively, starting the game windowed works around the bug by trigerring a redraw of the window.

Test Plan

Check that a bundle generated like this has the correct tweaked default config.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 6443
Build 10672: Vulcan BuildJenkins

Event Timeline

Itms created this revision.Nov 9 2018, 10:03 PM
Vulcan added a subscriber: Vulcan.Nov 9 2018, 10:06 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/differential/776/

Itms, could you point me where do you see about drop 10.9 to 10.11, because when i tried sdl2.0.9 i didnt change minimal osx version and builded normally

Itms added a comment.Nov 10 2018, 2:41 AM

Itms, could you point me where do you see about drop 10.9 to 10.11, because when i tried sdl2.0.9 i didnt change minimal osx version and builded normally

Yes, but if you linked Metal dynamically, users of the built bundle will not be able to start the game if they are below 10.11. Did I misunderstand something about the availability of Metal for older versions?

elexis added inline comments.
build/workspaces/build-osx-bundle.sh
185

This won't work for people who already have a user.cfg.
Don't we have HWDetect.cpp / hwdetect.js for that? perhaps @fabio has some input on that.
(It looks like RunHardwareDetection had to be run prior to InitSDL in InitGraphics of GameSetup.cpp.)

correct fix would be to upgrade SDL

Which would be changing a number and seeing if it falls apart?

Stan added a subscriber: Stan.Nov 10 2018, 2:39 PM
Stan added inline comments.
build/workspaces/build-osx-bundle.sh
185

changing a number

Yeah basically. I believe we are still trying to limit changes for this re release...

Stan added inline comments.Nov 10 2018, 2:45 PM
build/workspaces/build-osx-bundle.sh
185

Which makes not much sense to me especially since we are trying to fix Mac.

Itms planned changes to this revision.Nov 10 2018, 3:13 PM
Itms added inline comments.
build/workspaces/build-osx-bundle.sh
185

Ah right I was thinking that users with the bug couldn't have had changed the windowed value before, since they can't use 0ad, but I was forgetting about the people who used to have a working game and upgraded to Mojave.

This is not really about limiting the number of changes, rather about not dropping users who don't have Metal. But maybe we can make two packages, one for platforms with Metal, and one for platforms without Metal (those don't have the bug).

elexis added inline comments.Nov 10 2018, 3:36 PM
build/workspaces/build-osx-bundle.sh
185

A HardwareDetect implementation would likely also prevent the user from enabling fullscreen mode.
But upgrading SDL seems to be easier than trying to mess with that? My Ubuntu is using SDL 2.0.8.
Don't we have to rework the entire graphics codebase to support using Metal instead of OpenGL?

Stan added a comment.Nov 10 2018, 3:54 PM

Metal was introduced in El Capitan (OSX 10.11)
https://en.m.wikipedia.org/wiki/Metal_(API)
I'd like trompetin17 to try to play with us and Vladislav to make sure everything is fine.

trompetin17 added a comment.EditedNov 10 2018, 3:55 PM

Just an idea, could we add code in osx about include explicitly at run time Metal Lib is you already have, because SDL2.0.9 check witch use depending on osx, isnt?

The other option is to disable "Full Screen" in osx, we already have "windowed full screen".
So we could detect that we are using osx so disabled "FULL Screen", this should be another option

In D1671#66081, @Itms wrote:

Itms, could you point me where do you see about drop 10.9 to 10.11, because when i tried sdl2.0.9 i didnt change minimal osx version and builded normally

Yes, but if you linked Metal dynamically, users of the built bundle will not be able to start the game if they are below 10.11. Did I misunderstand something about the availability of Metal for older versions?

It's true the older macOS'es don't yet have Metal, but as I understand it SDL 2.0.9 added support for Metal, it didn't remove support for older macOS.

I don't know SDL internals at all, but I see two possibilities here that could pose a problem. Sorry if this is obvious :)

  1. Maybe SDL makes a compile-time decision about which implementation to use (instead of compiling both paths and deciding once at run-time). Is that the case?
  2. Maybe SDL needs to be on a newer macOS host to be able to compile the Metal version and maybe it needs to be on an older macOS install to compile the old path, e.g. if there are compile-time dependencies on stuff that ships only with the OS and that the newer macOS no longer bundles the old thing. Is that the case?

If it's only the first problem, then I wonder if it is feasible to somehow change our wiring code or apply a source patch to make it compile both variants and decide at run-time. Or perhaps upstream SDL might be open to making that work. Or if that's not possible, perhaps we could have two invocations of build-osx-bundle, e.g. two downloadables for osx, both the the latest version of the game, but one targtting= macOS <= 10.11, and the other newer macOS.

If it's the second problem (or both), I suppose we'd have to not just make two bundles but also make them from differnet hosts as it would mean you need to be on older macOS to build for that macOS. Would that be a viable option? It seems straight forward, but I also get that it's extra work around release :)

wraitii abandoned this revision.Nov 26 2020, 8:24 AM
wraitii added a subscriber: wraitii.

We dropped 10.11 and earlier yesterday, so SDL2 could be updated and this can be closed.