Tk Source Code

View Ticket
Login
Ticket UUID: 35a71bf4296f4260aca6d07d6a1ea178034d79c4
Title: Aqua: imgPhInstance tests fail with default color profile for display
Type: Bug Version: 9.1.0
Submitter: chrstphrchvz Created on: 2026-10-18 09:49:27
Subsystem: 41. Photo Images Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2026-11-18 02:17:33
Resolution: None Closed By: nobody
    Closed on:
Description:

I use a third-party display with my Mac. The tests imgPhInstance-1.1, imgPhInstance-1.2, imgPhInstance-2.1, as well as imgPhInstance-7.1 (enabled by [8316cf93]), all fail when my Mac is set to use the default device-specific color profile for this display, even though these tests appear to have a "tolerance" amount meant to avoid such failures.

After changing the color profile for the display to sRGB, all imgPhInstance tests can pass, including the remaining ones marked notAqua.

The user's selected color profile really is not relevant to the functionality being tested, so I think Tk would be better off running these tests in a toplevel set to use sRGB instead of the display colorspace (whether the means to do so are only for the test harness, or available more generally for anyone wanting color accuracy rather than performance).

User Comments: chrstphrchvz added on 2026-11-18 02:17:33:

I have opened a related RFE [09754594] to introduce an option to enable sRGB drawing for any Tk Aqua program. Even with that option, if Tk tests would prefer that sRGB drawing be enabled by the testsAreRunning variable, rather than needing to set an option in test scripts, that should be easy to accommodate.


chrstphrchvz added on 2026-11-05 05:52:54:

Please see branch bug-35a71bf4 (no need to do so before 9.0.5 is released, though). I have tested the proposed changes with a display set to use a non-sRGB color profile in Settings.

I believe the bare-minimum fix for this issue would be to have TkpReadPixelSRGB() retrieve the colorspace a toplevel is using (rather trying to recreate it by duplicating whatever approach is currently in resetBitmapLayerContext), and then use the sRGB colorspace in toplevels while tests are running by check the existing global variable testsAreRunning.

But if toplevels use sRGB, then TkpReadPixelSRGB() is unnecessary, so I also propose removing it in favor of using the generic testpixel code. If there is objection to disabling or removing TkpReadPixelSRGB(), then just merge from 6b5668ef and ignore later check-ins.


chrstphrchvz added on 2026-10-18 18:49:54:

To be clear, I only changed the display color profile in Settings as a temporary workaround; I am not suggesting that Tk try to change this setting, but rather only the colorspace object used in resetTkLayerBitmapContext (tkMacOSXWindowEvent.c).


serhiy.storchaka added on 2026-10-18 13:41:50:

Instead of setting a color profile, the tests could compare a pixel of the image with a reference pixel drawn by Tk with the expected color, for example a canvas rectangle filled with #ff8000 next to the image, instead of with the color itself. Both go through the same conversion, so the result does not depend on the profile. For imgPhInstance-1.2 and the transparent cells in 2.1 the reference is a pixel of the canvas background outside the image. This does not help the blend tests: macOS blends in the color space of the display, so they would stay notAqua.

imgPhInstance-7.1 is only enabled on Aqua in branch aqua-photo-gamma-palette, which is not merged yet. I can change it the same way there.


marc_culler (claiming to be Marc Culler) added on 2026-10-18 13:14:32:
I don't know of any way to change the color profile in a Tcl script,
but I think it would be possible to set the color profile in TkTest_Init
with some platform specific code.

I think that setting the display color profile at the script level is
probably a missing feature in Tk, though.