[webkit-changes] [WebKit/WebKit] 6c6337: [macOS] Enable JPEG XL on downlevel OSes

Myles C. Maxfield noreply at github.com
Fri Jun 9 21:01:13 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6c63375bf01a3f1e853a396adcedf5a10ac740d0
      https://github.com/WebKit/WebKit/commit/6c63375bf01a3f1e853a396adcedf5a10ac740d0
  Author: Myles C. Maxfield <mmaxfield at apple.com>
  Date:   2023-06-09 (Fri, 09 Jun 2023)

  Changed paths:
    M Configurations/CommonBase.xcconfig
    M Configurations/WebKitProjectPaths.xcconfig
    M Makefile
    M Source/WebCore/Configurations/WebCore.xcconfig
    M Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj
    A Source/WebCore/PAL/pal/spi/cocoa/AppleJPEGXL/AppleJPEGXLSPI.h
    A Source/WebCore/PAL/pal/spi/cocoa/AppleJPEGXL/LICENSE.txt
    M Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp
    M Source/WebCore/platform/image-decoders/jpegxl/JPEGXLImageDecoder.cpp
    M Source/WebCore/platform/image-decoders/jpegxl/JPEGXLImageDecoder.h
    M Source/WebCore/platform/image-decoders/jpegxl/JxlDecoderPtr.h
    A WebKitLibraries/DownlevelFrameworkStubs/120000/AppleJPEGXL.framework/AppleJPEGXL.tbd
    A WebKitLibraries/DownlevelFrameworkStubs/130000/AppleJPEGXL.framework/AppleJPEGXL.tbd

  Log Message:
  -----------
  [macOS] Enable JPEG XL on downlevel OSes
https://bugs.webkit.org/show_bug.cgi?id=257768
rdar://110349884

Reviewed by Alexey Proskuryakov.

When Apple's internal build system builds WebKit for downlevel OSes, AppleJPEGXL.framework will
be present, and we can use it. Also, when the installer for new Safari on downlevel OSes runs,
it will install AppleJPEGXL.framework to a place where WebKit can use it.

However, when people build WebKit themselves on downlevel OSes, AppleJPEGXL.framework won't
be present. But, we want locally-built versions of WebKit to be _able_ to use
AppleJPEGXL.framework if it just happens to be present - we want to be able to test the feature
*before* Apple's internal build system produces the official build. So we can't just turn the
feature off entirely on local builds; instead, we have to do something more complicated.

What we want is to create a minimal stub of AppleJPEGXL.framework, check it in to the tree, and
link to it at build time on downlevels using `-weak_framework`. This allows WebKit to use the
framework if it's present at build time, and not use it if it's not. Inside WebKit, we can
detect the framework's presence by declaring one of the external functions with
`__attribute__((weak_import))`, and then just checking to see if the function is null.

Doing it like this means that all downlevel builds will all build with `USE(JPEGXL)`, and will
check at runtime whether or not it can actually open AppleJPEGXL.framework, and gracefully
fall back if it can't. If we want to test the feature, we just build WebKit, and manually place
AppleJPEGXL.framework at a place where WebKit can see it, and WebKit will automatically
use it. However, if you don't have a copy of AppleJPEGXL.framework on your development machine,
that's fine; WebKit will happily run without it.

* Configurations/CommonBase.xcconfig:
* Configurations/WebKitProjectPaths.xcconfig:
* Makefile:
* Source/WebCore/Configurations/WebCore.xcconfig:
* Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj:
* Source/WebCore/PAL/pal/spi/cocoa/AppleJPEGXL/AppleJPEGXLSPI.h: Added.
* Source/WebCore/PAL/pal/spi/cocoa/AppleJPEGXL/LICENSE.h: Added.
* Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp:
* Source/WebCore/platform/image-decoders/jpegxl/JPEGXLImageDecoder.cpp:
(WebCore::JPEGXLImageDecoder::create):
* Source/WebCore/platform/image-decoders/jpegxl/JPEGXLImageDecoder.h:
* Source/WebCore/platform/image-decoders/jpegxl/JxlDecoderPtr.h:
* WebKitLibraries/DownlevelFrameworkStubs/120000/AppleJPEGXL.framework/AppleJPEGXL.tbd: Added.
* WebKitLibraries/DownlevelFrameworkStubs/130000/AppleJPEGXL.framework/AppleJPEGXL.tbd: Added.

Canonical link: https://commits.webkit.org/265050@main




More information about the webkit-changes mailing list