Closed Bug 2055532 Opened 4 days ago Closed 3 days ago

Build and package Metal ANGLE libraries on macOS

Categories

(Core :: Graphics, task)

task

Tracking

()

RESOLVED FIXED
154 Branch
Tracking Status
firefox154 --- fixed

People

(Reporter: jnicol, Assigned: jnicol)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fxpe])

Attachments

(5 files)

Vendor ANGLE's Metal backend sources in to tree, build libEGL.dylib and libGLESv2.dylib, and package them.

Selects libEGL as the target, rather than the translator. This
automatically also pulls in both libGLESv2 and the translator.

Add -Wno-unguarded-availability to mozilla_flags, allowing ANGLE's
Metal backend to compile despite using APIs too recent for Firefox's
minimum macOS version without guards.

Note that this does not set the flag for all ANGLE targets, only those
whose definition in ANGLE's GN build scripts include the flag, which
in practice is only angle_metal_backend. This is important, as it
means we can be confident that the translator, which we use on all
macOS versions, is safe to use. libEGL/libGLESv2 on the other hand,
must not be used on older macOS versions. We already ensure this is
the case by blocklisting Metal ANGLE on these macOS versions.

This contains:

  • A patch to allow building ANGLE's Metal backend for a minimum
    macOS version of 10.15. Note that it currently will only work at
    runtime on macOS 12 onwards, so Firefox must ensure it does not
    attempt to use ANGLE's Metal backend on older macOS versions.

  • A simple copy-paste error bug fix. This has been submitted upstream,
    but at time of writing has not yet been merged.

  • A patch to disable compiling ANGLE's internal shaders at build-time,
    which cannot currently be supported by our build system. They will
    instead be compiled at runtime.

Stay on the same base revision, but additionally pull in the required
files for the Metal backend.

Ensure ANGLE's libEGL and libGLESv2 are packaged on macOS as well as
Windows.

Additionally update some stale comments: we've long since used ANGLE
for webrender in addition to WebGL, and as of this change it's no
longer only the D3D backend that is used.

Now that Metal ANGLE is built and packaged on macOS, we can unblock
it. Note that it is still disabled by default, but can be enabled by
setting the pref webgl.disable-angle to false.

It remains blocked for macOS versions prior to 12 and on devices with
multiple GPUs for the time being.

Pushed by abutkovits@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/291a4bd0ecbf https://hg.mozilla.org/integration/autoland/rev/295564107ffe Revert "Bug 2055532 - Unblock WebGL on Metal ANGLE. r=gfx-reviewers,bradwerth" for causing bustages in SystemInfo_macos.mm.

Ah, gn_processor.py doesn't distinguish between macOS and iOS builds - it generates a macOS configuration then emits the moz.build files using the CONFIG["OS_TARGET"] == "Darwin" condition, which includes iOS. This means we were attempting to build the libEGL and libGLESv2 targets for iOS, but using a configuration intended for macOS, which led to attempting to include macOS-specific headers, which caused the iOS build to fail.

I had previously filed bug 2047963 about this limitation. I have worked around this for now with a bit of a kludge - replacing the CONFIG["OS_TARGET"] == "Darwin" conditions in the top-level generated moz.build file with CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa" (which is macOS specific). Since the top-level moz.build file simply adds the required targets to DIRS, this ensures we don't pull in the libEGL and libGLESv2 specific targets on iOS, and instead only build the translator targets as before.

Flags: needinfo?(jnicol)
Whiteboard: [fxpe]
Blocks: 2055931
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: