Don’t use JPEG-XR on the Web
calendar.perfplanet.com
calendar.perfplanet.com
New formats are not supported on all browsers so you wind up having to support the mainstream formats as well as one or more new formats. Rather than benefiting from reduced storage costs, your storage costs get multiplied.
Performance is also a problem, particularly when people add "yet another polyfill" to get an image to work without native support.
Once I get into eyeballing images closely I also end up questioning if the compression gains are real. For instance, one I read a comment on the article here
https://calendar.perfplanet.com/2018/is-avif-the-future-of-i...
and looked closely I couldn't unsee that the AV1 had very different artifacts than the other compressed images. Not necessarily worse, but definitely different. Unlike the poster I liked the way the suit rendered but definitely there was a lot of blocking around edges that the poster interprets as "pixelation on the flag".
Like many things, the costs of switching image formats are definite, but the benefits are questionable.
I just checked the Google homepage, and even the New Year's Eve Google Doodle currently being shown is a good ol' GIF, rather than a modern format such as WebP. And this is with me using a desktop Chrome browser that definitively supports WebP.
> Like many things, the costs of switching image formats are definite, but the benefits are questionable.
One easy way to get some of the benefits without incurring the switching costs is to leverage Cloudflare Polish[1]. I've used it at a few places, and have had good experiences. Although the majority of gains came from optimizing images that were poorly optimized to begin with, rather than the incremental improvements that occurred from enabling WebP support.
[1] https://support.cloudflare.com/hc/en-us/articles/36000060737...
https://chrome.google.com/webstore/detail/h264ify/aleakchihd...
HEIF is made by MPEG. HEIG is extensible (see AVIF fusing the AV1 royalty-free codec). Also an application format (MIAF) will ensure interoperability.
While waiting for native browser support, some js implementation would do the job.
What else?
Formats do not provide HW acceleration, implementations do. And so far there is zero HW accelerated HEIF implementations for the web.
You sure of that? Apple[1] and Qualcomm[2] might argue otherwise.
[1] https://developer.apple.com/videos/play/wwdc2017/513/
[2] https://techreport.com/news/34306/qualcomm-snapdragon-855-sp...
new-years-eve-2018-4995722058399744.2-law.gif
299 972 bytes
new-years-eve-2018-4995722058399744.2-law.webp
293 636 bytes
new-years-eve-2018-4995722058399744.2-law.apng
251 516 bytes
Interesting...
On some old and buggy machines, that might cause the browser to crash too.
Not something Google wants to risk for a doodle - that's why all non-trivial doodles require a click to load.
OTOH it might be cheaper (relatively) on phones as they can offload the work to hardware components and ramp CPU down (or avoid ramping it up).
with the resulting out.webp being 285 932 bytes, so it seems apng does a very good job here, unless I'm using suboptimal options for webp.
However, as TFA mentions, better compression is currently a double-edged sword, because the CPU has become a bottleneck again: even top-of-the-line Android phones have weak Qualcomm CPUs, and sites use so much JavaScript that even high-end machines can struggle.
So we may end up living with JPEG for a few more years. This format has been designed when CPUs had 25Mhz, and we've had over 25 years to optimize the implementations, so we get a lot of bang for the buck from it.
Most of which has nothing to do with compression format, to be honest. No image compression format is going to save us from websites that use 2000x2000 sized photos for 200x200 author thumbnails.
Maybe I should write one, I guess.
Please respond to the strongest plausible interpretation of what someone says, not a weaker one that's easier to criticize. Assume good faith.
https://github.com/metalabdesign/sharp-loader
https://github.com/herrstucki/responsive-loader
https://github.com/tcoopman/image-webpack-loader
(and many more, just grabbing a few examples)
Something that I've not seen is a plugin/loader that will automatically use the <picture> tag to make available multiple auto-generated source images and a fallback <img>. It'd be great to be able to
import myImage from 'res/img/my_img.png'
and have myImage be a string like
<picture><source srcset="[generated-name-of-my-image.webp]"><img src="generated-name-of-my-image.png"]></picture>
This sounded like an obvious truth but I think you're wrong!
JPEG has progressive rendering, so a browser could easily decide to stop once it has rendered enough for the image size. Once you zoom or if it's used elsewhere, it can render a little more.
Except for JPEG2000, which Safari supports but does not include in its Accepts: header. So Akamai just sniffs the user-agent and serves JPEG2000 to anything that looks like Safari, whether they support it or not.
Edit: I agree that something like the pagespeed module rewriting html probably goes too far and html rewriting is fraught with weird edge cases, but content negotiation is something only a webserver (or CDN) can do.
$ convert 400px-President_Barack_Obama.jpg.av1.mkv.png -colorspace YUV -channel 0 -separate Y.png
$ convert 400px-President_Barack_Obama.jpg.av1.mkv.png -colorspace YUV -channel 1 -separate U.png
$ convert 400px-President_Barack_Obama.jpg.av1.mkv.png -colorspace YUV -channel 2 -separate V.png
$ convert U.png -filter point -resize 50% -filter Mitchell -resize 200% smoothed_U.png
$ convert V.png -filter point -resize 50% -filter Mitchell -resize 200% smoothed_V.png
$ convert Y.png smoothed_U.png smoothed_V.png -combine -set colorspace YUV -colorspace sRGB combined.png
Result: https://imgur.com/a/AwoVmh1There's a big thing that bugs me about that when it comes to the web: Software patents and licenses basically ruined wavelet-based image compression schemes on the web.
Wavelets would have been ideal. Basically, the lossy compression would work about the same as the cosine transform in JPEG, but by using the discrete wavelet transform, you basically get thumbnailing built in: Imagine transmitting a tiny little thumbnail of your image. Then, you transmit the information used to derive a version 4x that size (2x width, 2x height) from that. Then, you transmit the data used to derive the next 4x layer. Rinse, repeat -- that's exactly how image data is organized after a wavelet transform.
With some clever adaptions, this could have done away with so much cruft and complexity we have today (like image sets and @media queries for background images): Imagine just putting a 4K version of your background on the server and telling the browser how to render it (an <img> tag with a specified size, or background-size in css). The browser could then start loading the image until it realizes it has all the data for your resolution (say on your phone), and just terminate the transmission before the whole image is downloaded.
Jpeg was released the MPEG-1 ( H.261 ) era. Since then we have had H.262 / MPEG2, H.263 / Divx, H.264 /AVC, H.265 / HEVC, and the coming H.266 / VVC. If we consider the amount of improvement we got from Video Encoding, images hasn't changed much at all, we happen to fine tune the heck out of Jpeg. And I hardly call a new image format with 50% reduction bitrate compared to a nearly 30 years old tech a major breakthrough, and that is without mentioning the huge decoding resources requirement.
There are many project that just improves on JPEG, Dropbox had a lossless compressor for JPEG, and Cant remember if Pik was originally based on jpeg as well.
Unless there is a real major breakthrough that gives the current best JPG encoder quality at 25% or less its size, focusing on 200KB, 100KB, 50KB images size, ( i.e the new image will have to be 50KB, 25KB, 12.5KB ) while using within 2x decoding power. I am convinced our roadmap for Network bandwidth improvement in the next 3 - 5 years are going to make JPEG to last forever.
However, the summary (and the article) leaves out a relevant question that immediately comes to mind: Are other image formats decoded off the main thread or is it just that decoding JPEG-XR is just more taxing compared to other formats, thus negating its advantages?
I'm fairly certain the article may be poorly worded. Certainly standard JPGs are decoded on the CPU side as well, are they not?
To the best of my knowledge, I don't think any browsers are doing JPG decoding in hardware; I think they use the GPU for primitives and compositing, etc.
I would look forward to being corrected if I'm wrong!
Other formats use more expensive entropy coding, more block sizes, smoothing filters, and inter-block prediction which forces them to be decoded mostly serially.
1. This is exactly what I've feared and suspected about JPEG-XR, webp, and JPEG-2000 (which Safari ever so quietly supports). I especially wondered about JPEG-XR after reading how Microsoft had done some great things with GPU-based hardware acceleration for JPEG decoding in IE11: https://blogs.msdn.microsoft.com/ie/2013/09/12/using-hardwar...
I was puzzled by the fact that they never mention JPEG-XR and have never published a similar post about hardware acceleration for the more modern format. They've been incredibly lazy and unfocused on XR for years. It's effectively dead now.
2. The author of the don't use it post keeps saying it gets "software decoded". This implies that this is unusual. But it isn't. Does he think JPEGs are not software decoded? They are in Firefox, and probably every other browser but IE11 and Edge. Someone correct me if I'm wrong. Browser makers have been surprisingly inert on using GPUs for image decoding. libjpeg-turbo is used by Chrome and Firefox, and possibly Safari. It's pure CPU, albeit with some SIMD. That's "software decoding". Hardware acceleration normally means GPU, or a fixed function unit/ASIC like you see for some video codecs.
3. One percent? This was all about a -1% drop in some metric? What's the error margin?
4. He implies that there's a lot of JS in this SPA. This seems like a possible confound that won't necessarily apply to rigorous web developers who don't overload on JS (who are admittedly extremely rare in 2019). Sure, they showed that XR was using more CPU, but so do all post-JPEG formats.
5. Which leads to my last point. What about webp? He strangely never mentions it. It's like only JPEG and XR exist. webp performs very poorly in CPU efficiency compared to JPEG. What are trivago and Cloudinary seeing on that front? Is webp less taxing than XR?
Is this an overreaction, or a subversive call to improve the decode perf of JPEG-XR? I'm certainly on the performance-is-a-feature bandwagon myself, but 1% ux impact is pretty small. And shouldn't we assume that decode perf will improve in the near future? Is there any reason to assume that this problem is permanent and unfixable?
The best you can say here is that it’s within the margin of error, in which case the effect is so small it’s literally unmeasurable. In that case the null hypothesis still wins, and you should not switch.
> Is there any reason to assume that this problem is permanent and unfixable?
IE11 as tested in the article is not getting anything other than security patches. The users who use IE11 are probably also the users most affected by poor performance since they most likely have the oldest hardware.
> The best you can say here is that it’s within the margin of error
What is preventing JPEG-XR from becoming faster and a net ux positive, tomorrow or in the future? Isn't the best I can say that today's results might be a bug or fluke or a quick and dirty implementation, and not a permanent problem?
> IE11 as tested in the article is not getting anything other than security patches.
The title and conclusion both said we should avoid JPEG-XR on the web, not that we should avoid it on IE11.
You're right, the article focused on the problem with IE11. Is it already a net positive on Edge? (The article didn't say.) Should the shim to make it work in the old browser that fewer people use really override the potential benefits on the newer browser that more people are already using?
Does it seem reasonable or unreasonable to make future web decisions depend on an old browser that's on life support today and has small and declining market share?
And even if you don't, taking a 1% hit to your conversion rate and hurting user experience just because you want to use a fancy new image format is probably not a good idea.
The may be a spurious figure.
"we were able to statistically verify a -1% negative impact on core business metrics including conversions"
Ultimately though the issue is more fundamental: you can't make assertions about performance without publishing actual figures. All we have to go on is the author's assertion that the test methodology was sound and the results were out of the bounds of chance. That's not really enough.
I have worked with many, many teams who earnestly believed they were running "scientific" MVTs, with solid statistical analysis free of bias. They weren't.
I don't know why they wouldn't just switch over to WebP in preference to that, though. It's better to have fewer of these formats around and the simplest thing to do is use the one that already has support.
Note that parent said "Chrome would gain support for JPEG XR", which I believe is what 05 is replying to.
Why should anyone test a format which is used by just two browsers with a very small market share and which will be never adopted by the company with the biggest market share (because Google has WebP). JPEG-XR is DOA and nobody should care and waste time on this (except the OP gone astray).
I like that there is a tl;dr right at the beginning though.
Thinking about it, assuming they’ve got a WebP output for Chrome already this could be as simple as adding one more build step with a different encoder, and one more negotiation rule on the CDN.
It indicates to me that either the inmates are running the asylum - that devs are being given too much leeway to pursue personal interests - or (and?) that Trivago's day to day work is proving so dull that developers in some teams are inventing R&D work just to stay sane.
The solution to this problem is to start using these new technologies, so the browser vendors can prioritise work to make them performant. It is not to write articles that entrench that neglect and tie us to flawed, ancient technologies from the 1990s.
It gets worse. If there's one kind of meme that survives a long time in the development world, it's performance memes. Rumours about poor perf invariably end up haunting technologies with FUD long after any issues have ceased to be relevant.
I was surprised to see a post from Trivago - I might have to book my next hotel through them.
Now, overall time to decode still matters. If it's a gigantic hero image above the fold, then it could take a noticeable amount of time to decode, but it's probably still a win.
With the only good JPEG 2000 encoder, its quality at small file sizes is easily better than webp, but in practice it seems virtually nobody uses JPEG 2000, because the open source encoders are not really that great (probably because the patents are a guessing game, although technically the known holders are willing to grant royalty-free licenses).
That's a hilarious thought to me. How can a 1% change in a sales funnel be considered statistically relevant?
Is the TLDR actually "jpeg xr implementation is poorly optimized and negatively affects browser performance which decreased conversions."