Colours in jpegxl images are displayed wrong
#2033
Closed
opened 2 months ago by Joshix
·
10 comments
No Branch/Tag Specified
1210
1769-take2
1791
28.9-platform
28.9-platform-old
CCW-perf
Pale_Moon-release
RFC6367
aruba
dynamic-module-import
fetchstreams-work
getnativepath-work
js-modules
master
modulefix
nss-update-work
re-unify
redwood
regexp-hookup-v2
release
release-29
scroll-anchoring-wip
xpiprovider-work
z-index-work
29.4.6_RC1
31.0.0_RC1
31.0.0_RC2
Checkpoint_1
FF_Checkpoint_1
FullFunction_CP1
Goanna_6.0.0
NSS_3.35_TEST
PM28.0.0.1_Release
PM28.0.0_Build1
PM28.0.0_Release
PM28.0.0a2_Unstable
PM28.0.0a3_Unstable
PM28.0.0a4_Unstable
PM28.0.0b1_Unstable
PM28.0.0b2_Unstable
PM28.0.0b3_Unstable
PM28.0.0b4_Unstable
PM28.0.0b5_Unstable
PM28.0.1_Release
PM28.1.0_Release
PM28.2.0_Release
PM28.2.1_Release
PM28.2.2_Release
PM28.3.0_Release
PM28.3.1_Release
PM28.4.0_Release
PM28.4.1_Release
PM28.5.0_Release
PM28.5.1_Release
PM28.5.2_Release
PM28.6.0.1_Release
PM28.6.0_Release
PM28.6.1_Release
PM28.7.0_Release
PM28.7.1_Release
PM28.7.2_Release
PM28.8.0_Release
PM28.8.1_Release
PM28.8.2.1_Release
PM28.8.2_Release
PM28.8.3_Release
PM28.8.4_Release
RB20220707
RB_20220510
RB_20220607
RB_20220607_2
RB_20220802
RB_20220927
RB_20220928
RB_20221101
RB_20221122
RB_20221129
RB_20221220
RB_20230123
RB_29.4.5
RB_29.4.5-UXP
RB_29.4.5.1
RB_29.4.5.1-UXP
RB_29.4.6
RC_20200924
RC_20201024
RC_20201120
RC_20201215
RC_20201216
RC_20210128
RC_20210130
RC_20210225
RC_20210226
RC_20210326
RC_20210421
RC_20210604
RC_20210715
RC_20210813
RC_20210815
RC_20211105
RC_20211209
RC_20220114
RC_20220214
RC_20220216
RC_20220219
RC_20220309
RC_20220409
RC_20220507
RC_20220728
RC_20220922
RC_20220924
RC_20221026
RC_20221120
RC_20221120_2
RC_20221216
RELBASE_20200324
RELBASE_20200408
RELBASE_20200426
RELBASE_20200427
RELBASE_20200506
RELBASE_20200603
RELBASE_20200711
RELBASE_20200712
RELBASE_20200730
RELBASE_20200831
RELBASE_20200901
RELBASE_20200929
RELBASE_20200930
RELBASE_20201001
RELBASE_20201024
RELBASE_20201120
RELBASE_20201124
RELBASE_20201218
RELBASE_20210202
RELBASE_20210205
RELBASE_20210302
RELBASE_20210330
RELBASE_20210427
RELBASE_20210608
RELBASE_20210719
RELBASE_20210817
RELBASE_20210823
RELBASE_20210914
RELBASE_20210914-UXP
RELBASE_20211109
RELBASE_20211109-UXP
RELBASE_20211110
RELBASE_20211110-UXP
RELBASE_20211214
RELBASE_20211214-UXP
RELBASE_20220118
RELBASE_20220118-UXP
RELBASE_20220127
RELBASE_20220127-UXP
RELBASE_20220310
RELBASE_20220320
v2018.04.23
v2018.04.26
v2018.04.27
v2018.05.15
v2018.06.01
v2018.07.18
v2018.09.05
v2018.09.27
v2018.11.04
v2018.11.07
v2018.12.18
v2019.02.11
v2019.03.08
v2019.03.27
v2019.06.08
v2019.09.03
v2019.09.12
v2019.10.31
v2020.01.12
v2020.02.06
v2020.02.18
Labels
This issue is eligible for payment of a bounty. Bounty paid
Bounty issue fully completed and paid. Bug Build Bustage Build System Code Cleanup Crash Critical Debug: Build
Debug Build Issues Debug: Runtime
Debug Runtime Issues dependencies
Pull requests that update a dependency file Devtools Documentation DOM Done
Like fixed but merely done Duplicate Editor
HTML editor and editable HTML elements Enhancement Everybody Wins!
For those really rare occasions where everyone agrees in the end. Extensions Fixed Good Enough Good first issue
Good issue for contributers new to the project. Hang High Priority High Risk Images
Image codecs and image handling Incomplete Installer/Updater Intermittent Invalid Javascript Layout Layout - CSS Leave open Legal Localization Low Priority Low Risk MailNews Core
MailNews, Mork, and LDAP Media Memory Meta-issue More info needed Networking Not an Issue On Hold OS: Android OS: Linux OS: Linux (AltArch)
Linux on other architectures such as ARM and PPC OS: Mac OS X OS: Other OS: Solaris / Illumos OS: Windows Parser
Dealing with the XML/HTML parser Performance Places
Bookmarks/History/Library Plugins PR requested
Issue with code work but no PR. PR: Draft - DO NOT MERGE Printing Privacy Product Polish Question Redirected to Forum Regression Regression-window Wanted
Regression window or fix window wanted (either on mozilla-central with mozregression, or manual on our tree). Release Engineering Release Uplift Wanted Rendering Research Retarded
Do not use this label Security Services
Related to services provided for applications. SessionStore Stale Standards Compliance String Changes Sync The whole codebase
Affects many components Theme Theme Changes UI
User Interface Unconfirmed Verification Needed Verified Web Compatibility WebGL/3D
Related to WebGL(2) and 3D object rendering code. Widget Won't Fix Works for me
Apply labels
Clear labels
Add-ons Manager
App: All
App: Basilisk
App: Fennec
App: IceApe
App: IceDove
App: IceWeasel
App: Interlink
App: Pale Moon
App: Toolkit
Assigned
Backed Out
Bitrotted
Bounty
This issue is eligible for payment of a bounty. Bounty paid
Bounty issue fully completed and paid. Bug Build Bustage Build System Code Cleanup Crash Critical Debug: Build
Debug Build Issues Debug: Runtime
Debug Runtime Issues dependencies
Pull requests that update a dependency file Devtools Documentation DOM Done
Like fixed but merely done Duplicate Editor
HTML editor and editable HTML elements Enhancement Everybody Wins!
For those really rare occasions where everyone agrees in the end. Extensions Fixed Good Enough Good first issue
Good issue for contributers new to the project. Hang High Priority High Risk Images
Image codecs and image handling Incomplete Installer/Updater Intermittent Invalid Javascript Layout Layout - CSS Leave open Legal Localization Low Priority Low Risk MailNews Core
MailNews, Mork, and LDAP Media Memory Meta-issue More info needed Networking Not an Issue On Hold OS: Android OS: Linux OS: Linux (AltArch)
Linux on other architectures such as ARM and PPC OS: Mac OS X OS: Other OS: Solaris / Illumos OS: Windows Parser
Dealing with the XML/HTML parser Performance Places
Bookmarks/History/Library Plugins PR requested
Issue with code work but no PR. PR: Draft - DO NOT MERGE Printing Privacy Product Polish Question Redirected to Forum Regression Regression-window Wanted
Regression window or fix window wanted (either on mozilla-central with mozregression, or manual on our tree). Release Engineering Release Uplift Wanted Rendering Research Retarded
Do not use this label Security Services
Related to services provided for applications. SessionStore Stale Standards Compliance String Changes Sync The whole codebase
Affects many components Theme Theme Changes UI
User Interface Unconfirmed Verification Needed Verified Web Compatibility WebGL/3D
Related to WebGL(2) and 3D object rendering code. Widget Won't Fix Works for me
No Label
Add-ons Manager
App: All
App: Basilisk
App: Fennec
App: IceApe
App: IceDove
App: IceWeasel
App: Interlink
App: Pale Moon
App: Toolkit
Assigned
Backed Out
Bitrotted
Bounty
Bounty paid
Bug
Build Bustage
Build System
Code Cleanup
Crash
Critical
Debug: Build
Debug: Runtime
dependencies
Devtools
Documentation
DOM
Done
Duplicate
Editor
Enhancement
Everybody Wins!
Extensions
Fixed
Good Enough
Good first issue
Hang
High Priority
High Risk
Images
Incomplete
Installer/Updater
Intermittent
Invalid
Javascript
Layout
Layout - CSS
Leave open
Legal
Localization
Low Priority
Low Risk
MailNews Core
Media
Memory
Meta-issue
More info needed
Networking
Not an Issue
On Hold
OS: Android
OS: Linux
OS: Linux (AltArch)
OS: Mac OS X
OS: Other
OS: Solaris / Illumos
OS: Windows
Parser
Performance
Places
Plugins
PR requested
PR: Draft - DO NOT MERGE
Printing
Privacy
Product Polish
Question
Redirected to Forum
Regression
Regression-window Wanted
Release Engineering
Release Uplift Wanted
Rendering
Research
Retarded
Security
Services
SessionStore
Stale
Standards Compliance
String Changes
Sync
The whole codebase
Theme
Theme Changes
UI
Unconfirmed
Verification Needed
Verified
Web Compatibility
WebGL/3D
Widget
Won't Fix
Works for me
Milestone
Set milestone
Clear milestone
No items
No Milestone
Assignees
Assign users
Clear assignees
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.
No due date set.
Dependencies
No dependencies set.
Reference: MoonchildProductions/UXP#2033
Reference in new issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
No
Yes
I first noticed this on my one website where a red thing in an image was displayed as blue.
As example the image on: https://jpegxl.info/
Palemoon:

Firefox:

Someone on twitter thinks it is because of a mixup between BGR and RGB
I assumed it was supposed to be yellow, not teal.
@athenian200 I thought we had already solved this?
The discussion on this issue was a while back, and this issue only appears on certain images I believe?
I think either this problem was forgotten about when we started discussing compiler issues, or else we decided to implement it first and fix this problem later.
So much was going on with that issue that this particular part of it seems to have gotten lost in the shuffle. Probably better that we use this issue to track what's going on with it from here on out.
#1928
This was the last status of this as mentioned, and it was only briefly early on, in a single post on Job's PR (I created the PR for him because his computer couldn't handle it).
Right. seems though that quite a few of the jxls currently out there have the channels swapped. Just didn't catch it because i assumed that was what all the jpegxl.info images were supposed to look like ;P
https://old.lucaversari.it/jpeg_xl_data/bees.jxl
Clearly that's not right ;)
I'm guessing we have a B8G8R8A8 instead of an R8G8B8A8 (or v.v.) somewhere... :P
It indeed seems to be an B8G8R8A8 versus R8G8B8A8 issue.
Up to now, the libjxl API does not provide output in arbitrary channel order (although that is something we plan to add).
The first attempt of changing
SurfaceFormat::B8G8R8A8
toSurfaceFormat::R8G8B8A8
didn't work for a reason that I don't ye understand; in that case the images where still displayed with the wrong colors, but one getsCrash Annotation GraphicsCriticalError: |[0][GFX1]: Unknown image format 2 (t=6.67418) [GFX1]: Unknown image format 2
as output when looking at an jxl image.
To confirm that images look correct when b and r are swapped, we can manually fix the order:
We can certainly do a quick and dirty conversion on the buffer for the time being but it'd be a fairly hot path so if that becomes permanent then we'll need a more performant one.
I can prepare a pull request with the hack and a comment saying that this needs fixing. One more step towards making jxl-decoding in Pale Moon better would be to it it in a streaming fashion using a callback like it is done in chrome.
Indeed, it didn't work for me either when I was working on the PR. I didn't really know how the decoder worked exactly in detail, I only copied the code from Mozilla's implementation at bug 1707590 and made some few changes to make it build. I thought the inverted color issue was either solved or just deferred for fixing in another PR, but looks like I should've been more vocal about the issue (even if it meant delaying the JPEG-XL support to 31.5.0) I faced 5 months ago... Sorry.
I did some research and we use gfxPackedPixel to expand RGB to BGRA specifically in the image decoders. So we don't have direct support for RGBA AFAICT.
Plugging that into search landed me on this BZ bug which we may need to port to have better plumbing. Seems mostly mechanical to port. Unfortunately I don't have time in the coming month or so to go into that as I have family matters to attend to (which involves international travel) and this probably needs ample time to do right.
Transparency might rely on this as well, although we may also just look more closely at how our APNG is done instead of falling into the refactoring rabbit hole and getting stuck there.
All of that is kinda offtopic here though, aside from us just needing to use the workaround for the time being until it can be handled properly otherwise with native RGBA surfaces.
We probably will need to backport bug 1255106 as well for QCMS in SurfaceFilter.
I've split off the different things we'd want to port in other bugs like CMS. In good Mozilla fashion it's a bit of a potpourri though.