imageWrite() WebP breaks on Apple Silicon – drop-in fix available?

OS: macOS 27.0.1 on Apple Silicon (arm64)
Java Version: OpenJDK 21.0.12.1 (Homebrew, native arm64)
Tomcat Version: none – CommandBox 6.3.5 (Undertow)
Lucee Version: 5.4.8.2

For comparison, WebP writing works on our servers: Windows x86_64, Tomcat, Lucee 5.3.12.1.


Hi all,

writing WebP images fails on an Apple Silicon Mac, while reading WebP works fine. The same code runs without problems on our Windows x86_64 servers.

Repro

img = imageRead( expandPath( "./test.jpg" ) );
imageWrite( img, getTempDirectory() & "test.webp", true, 0.85 );   // fails
imageWrite( img, getTempDirectory() & "test.jpg",  true, 0.85 );   // works

Error

Multiple exceptions ('long com.luciad.imageio.webp.WebPEncoderOptions.createConfig()';
FileStore The specified format has no associated registered ImageCodec.)

The first part is the UnsatisfiedLinkError of the native createConfig() method. A 0-byte .webp file is left behind.

Analysis

  • The bundle lucee-server/bundles/org.lucee.gotson-webp-0.2.2.jar ships these natives:

    native/Windows/x86
    native/Windows/x86_64
    native/Linux/x86, x86_64, aarch64, arm, armv6, armv7, ppc64
    native/Mac/x86_64
    

    There is no native/Mac/aarch64, so the encoder cannot load on an arm64 JVM on macOS.

  • org.lucee.twelvemonkeys.imageio-webp is present too, but TwelveMonkeys WebP is read-only, which explains why reading works.

  • In lucee/extension-image (master), source/java/pom.xml still depends on com.github.gotson:webp-imageio:0.2.2 (released 2021). So I assume Lucee 6/7 with the current image extension behave the same on Apple Silicon. I haven’t tested Lucee 7 myself.

  • gotson/webp-imageio has not added Mac aarch64 binaries (see PR #1: the maintainer wants reproducible builds).

Possible fix

com.github.usefulness:webp-imageio (currently 0.11.0, Apache 2.0, Java 11+) is a maintained fork of gotson/webp-imageio:

  • it keeps the same package com.luciad.imageio.webp,
  • it ships native/Mac/aarch64/libwebp-imageio.dylib in addition to all platforms of 0.2.2.

It looks like a drop-in replacement for the dependency in the image extension:

<dependency>
  <groupId>com.github.usefulness</groupId>
  <artifactId>webp-imageio</artifactId>
  <version>0.11.0</version>
</dependency>

Questions

  1. Can someone confirm whether WebP writing works on Apple Silicon with Lucee 7 and the current image extension?
  2. Would you consider switching the image extension to com.github.usefulness:webp-imageio? Is there an existing ticket for this I should follow or comment on?
  3. For Lucee 5.4: is there a supported way to use a newer webp-imageio build without patching the bundle in lucee-server/bundles?

Current workaround

Run the local server on an x86_64 JDK under Rosetta 2, so the Mac/x86_64 native is used. Since Apple plans to limit Rosetta after macOS 27, that’s only a short-term option. For now we simply test image uploads on our dev server.

Happy to test a snapshot or a patched extension on Apple Silicon if that helps.

Thanks!

Hi Daniel, thanks for the detailed analysis, that saves us a lot of time.

First question: which version of the Image extension do you have installed? You can see it in the Administrator under Extensions > Applications, or with extensionList(). That matters here, because Lucee 5.4.8.2 runs the Image extension 2.x line (latest is 2.0.0.34), while Lucee 7 uses 3.x.

Your analysis is right as far as I can see: both lines still ship gotson webp-imageio 0.2.2, so I’d expect the same problem on Apple Silicon with Lucee 7 and the current extension. Switching to com.github.usefulness:webp-imageio looks like a good approach, and we’ll have a look at it.

About 5.4: Lucee 5.4 is no longer supported or maintained. The current LTS is 6.2, and that will soon change to 7.1. A fix like this would go into the current Image extension, and newer extension versions need newer Lucee versions (Image 3.1 already needs Lucee 7.1). We’re also starting to move extensions from OSGi bundles to Maven dependencies, which raises the minimum Lucee version further. So for a proper fix, please plan an update to a current Lucee version.

Hi Gian,

thanks for the quick and clear answer.

Image extension version: 2.0.0.26 (ID B737ABC4-D43F-4D91-8E8E973E37C40D1B) on the local Lucee 5.4.8.2. The bundles directory matches:

lucee.image.extension-2.0.0.26.jar
org.lucee.gotson-webp-0.2.2.jar
org.lucee.twelvemonkeys.imageio-webp-3.9.3.jar

So it’s not the latest 2.x build. Since 2.0.0.34 still ships gotson 0.2.2, as you say, I’d expect the same result there.

Switching the Image extension to com.github.usefulness:webp-imageio would really help our dev team, since we develop locally on Apple Silicon Macs.

Regarding the update: point taken. We’re planning the move to a current Lucee version, but it will take us some time. Our application relies heavily on ORM, and we’re still on the Hibernate 3.5 extension (3.5.5.89). Most of the effort will go into testing our entities and services against the Hibernate 5.6 extension on Lucee 7. Your note that the LTS will switch to 7.1 soon helps us decide which version to target. Is there already a rough timeframe for that?

Thanks again!
Daniel