Firefox and corrupted PNG images, colour management and ICC v4 support

Introduction

I’d previously reported that I had experienced corrupted PNG images in Firefox if I enabled ICC v4 support within the browser:

That was way back in September 2012 and there have been many releases of Firefox since then, and my Windows machines have been through a number of Service Pack and revision updates since then including some changes to my implementation of monitor calibration.

I’ve also noticed this PNG image corruption is logged as a bug at https://bugzilla.mozilla.org/show_bug.cgi?id=791456 and there is suspicion there that the profile embedded in the PNG image may be corrupted in some way. I’ll have to do some separate checks on that suspicion but I could not detect any embedded profile in the PNG image and it appears to be a simple greyscale-formatted image. In the meantime, I have undertaken some quick checks on ICC v2 and ICC v4 support and seeing the effect on viewing the xkcd PNG images.

Tests

With the release of Firefox 18 I thought it was about time to test again. I undertook five tests, with configuration and results detailed below. Generally, I used the ICC test page at http://www.color.org/version4html.xalter to confirm ICC version compatibility, and I also checked the PNG image at http://xkcd.com/1108/ for PNG image corruption. My system is a Windows 8 Pro 64-bit machine with all the latest updates as of today (12th January 2013) in a dual-monitor configuration using two Dell UltraSharp 3008WFP 30-inch wide-gamut monitors.

1. Test 1 – ICC v4 monitor profile (matrix-based), ICC v4 enabled in Firefox

Config: The ICC v4 monitor profile was created with x-rite “i1 Profile” using an i1 Display Pro colorimeter. The profile type was matrix-based.

When I checked at http://xkcd.com/1108/ the PNG image there was not corrupted.

When I checked at http://www.color.org/version4html.xalter the image colours were shown in an unexpected manner:

icc4-test1

Clearly something was very wrong.

I then checked the integrity of this monitor profile using “ICC Profile Inspector” and CHROMIX “ColorThink”; the profile seemed fine, so I suspect that the error is within Firefox. I would like to have used ArgyllCMS to create an ICC v4 profile to help in validating if the error is within Firefox and not within the profile but, at this time, ArgyllCMS does not support ICC v4.

2. Test 2 – ICC v2 monitor profile (LUT-based), ICC v4 enabled in Firefox

Config: The ICC v2 monitor profile was created with ArgyllCMS + dispcalGUI using an i1 Display Pro colorimeter. The profile type was XYZ LUT + “swapped” matrix.

When I checked at http://xkcd.com/1108/ the PNG image there was corrupted.

When I checked at http://www.color.org/version4html.xalter the image indicated full ICC v4 compatibility:

icc4-test2

ICC v4 support and LUT-based support is excellent here but the downside is that the PNG image was corrupted. Oh dear.

3. Test 3 – ICC v2 monitor profile (LUT-based), ICC v4 disabled in Firefox

Config: The ICC v2 monitor profile was created with ArgyllCMS + dispcalGUI using an i1 Display Pro colorimeter. The profile type was XYZ LUT + “swapped” matrix.

As soon as I loaded Firefox I knew there was a problem; all of the Firefox app window colours were messed up. And, of course, so were the colours on the Internet.

When I checked at http://xkcd.com/1108/ the PNG image there was not corrupted but other elements had incorrect colours.

When I checked at http://www.color.org/version4html.xalter the image indicated ICC v2 compatibility but all the colours were incorrect:

icc4-test3

What does all this mean? Well, the ICC v2 profile was LUT-based, to which was added a deliberately wacked matrix. Firefox was clearly not using the LUT data when ICC v4 is disabled and instead used the matrix data as shown by the wacked colours. So the lesson here is not to use LUT-based ICC profiles (at least with ICC v2 profiles, as I was not able to create LUT-based ICC v4 profiles).

To clarify the above, the Firefox setting “gfx.color_management.enablev4” enables ICC v2 LUT support support as well as enabling ICC v4 support; you can’t have one without the other.

4. Test 4 – ICC v2 monitor profile (matrix-based), ICC v4 disabled in Firefox

Config: The ICC v2 monitor profile was created with ArgyllCMS + dispcalGUI using an i1 Display Pro colorimeter. The profile type was matrix-based with curves. I used a matrix-based profile as it was clear from the previous test that Firefox was not reading correctly reading LUT-based profiles.

When I checked at http://xkcd.com/1108/ the PNG image there was not corrupted.

When I checked at http://www.color.org/version4html.xalter the image indicated ICC v2 compatibility:

icc4-test4

5. Test 5 – ICC v4 monitor profile (matrix-based), ICC v4 disabled in Firefox

Config: The ICC v2 monitor profile was created with ArgyllCMS + dispcalGUI using an i1 Display Pro colorimeter. The profile type was matrix-based.

When I checked at http://xkcd.com/1108/ the PNG image there was not corrupted.

When I checked at http://www.color.org/version4html.xalter the image indicated ICC v2 compatibility:

icc4-test5

Recommendations

These tests are by no means exhaustive or even as rigorous as I would have liked but I can recommend the following:

  1. Avoid the use of ICC v4 monitor profiles and, instead, use ICC v2 profiles whenever possible.
  2. Avoid the use of LUT-based monitor ICC profiles and, instead, use matrix-based ICC profiles whenever possible. A mixed LUT+matrix profile is acceptable.
  3. Ensure that ICC v4 support within Firefox is disabled (gfx.color_management.enablev4 = false). Note that this will also disable ICC v2 LUT-based profile support.
  4. Wait for Mozilla to confirm and fix colour-management issues with ICC v4 profiles!

Article by Kulvinder Singh Matharu – 2013