Bug 499789 - Setting an ICC profile in Display Configuration causes screen to blank when KWin is compiled with GCC and LTO
Summary: Setting an ICC profile in Display Configuration causes screen to blank when K...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: colour-management (show other bugs)
Version: 6.3.0
Platform: Arch Linux Linux
: HI grave
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 499926 500010 500011 500061 500437 (view as bug list)
Depends on:
Blocks:
 
Reported: 2025-02-11 01:57 UTC by Higgins
Modified: 2025-03-05 08:18 UTC (History)
27 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.3.1
Sentry Crash Report:


Attachments
ICC file used for testing (931.97 KB, application/vnd.iccprofile)
2025-02-11 01:57 UTC, Higgins
Details
journald log during the ICC apply process (156.05 KB, text/x-log)
2025-02-11 01:58 UTC, Higgins
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Higgins 2025-02-11 01:57:05 UTC
Created attachment 178133 [details]
ICC file used for testing

SUMMARY

When setting an ICC profile in system settings, when hitting Apply the screen will go blank. Exiting/relogging in or rebooting does not fix this. The only way to resolve is to rename the ICC file and restart plasmashell.

I thought this might be just a Neon thing, and mentioned it briefly in KDE discussions. But, I did this on fresh installs of Neon-testing (VM), Neon-unstable (VM), and Arch with kde-unstable packages enabled to get plasma 6.3.0 (physical hardware, nvidia-570 drivers). All three did the same thing.

STEPS TO REPRODUCE
1. In System Settings - Display Configuration, set a path to an ICC profile
2. Click Apply.

OBSERVED RESULT

Screen goes blank and cannot recover until ICC profile is renamed and plasmashell is restarted.

EXPECTED RESULT

ICC profile is applied and the screen does not go blank.

SOFTWARE/OS VERSIONS
Linux:  6.8.0-53-generic on neon-testing, 6.11.0-17-generic on neon-unstable, 6.12.12-1-lts on Arch
KDE Plasma Version:  6.3.0, 6.3.80 on neon-unstable
KDE Frameworks Version: 6.11.0
Qt Version: 6.8.2
Graphics Platform: Wayland

ADDITIONAL INFORMATION

Attached is the ICC profile I used in the tests. It works fine on Plasma 6.2.5, on Neon, Fedora, and Arch. Just want to eliminate it as an issue.

If any more information can be gathered, let me know how I should go about it and I will do the tests again.
Comment 1 Higgins 2025-02-11 01:58:21 UTC
Created attachment 178134 [details]
journald log during the ICC apply process

I attached the journald log from the time I applied the ICC profile, killed plasmashell, relogged in, killed plasmashell again and then renamed the ICC profile.
Comment 2 Higgins 2025-02-11 20:51:48 UTC
This is fixed in today's Arch kde-testing repo, I was able to successfully set the ICC profile without the screen blanking.

The issue still persists in KDE Neon, user edition 6.3.0 (no longer testing), so it might be specifically related to Neon at this point.
Comment 3 Higgins 2025-02-11 22:46:48 UTC
Addendum: It only works on Arch if "Prefer efficiency" is enabled, this is why it seemed to work. If I switch to "Prefer color accuracy" it will blank the screen and require recovery.

It still blanks on either selection in Neon.
Comment 4 Bug Janitor Service 2025-02-12 14:23:19 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kscreen/-/merge_requests/348
Comment 5 Zamundaaa 2025-02-12 15:20:59 UTC
Git commit 5bee8d00691b1386025efa6c19804ed98bfebbbc by Xaver Hugl.
Committed on 12/02/2025 at 14:19.
Pushed by zamundaaa into branch 'master'.

kcm: re-enable revert message for color power preference

Changing it made the screen black in one instance, so the automatic revert is
important for it.

M  +1    -1    kcm/config_handler.cpp

https://invent.kde.org/plasma/kscreen/-/commit/5bee8d00691b1386025efa6c19804ed98bfebbbc
Comment 6 Bug Janitor Service 2025-02-12 15:21:19 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kscreen/-/merge_requests/349
Comment 7 Zamundaaa 2025-02-12 15:26:20 UTC
Git commit 3b9180c1ab1c8e7c3d32650f0ca6e6fcec61e32c by Xaver Hugl.
Committed on 12/02/2025 at 15:21.
Pushed by zamundaaa into branch 'Plasma/6.3'.

kcm: re-enable revert message for color power preference

Changing it made the screen black in one instance, so the automatic revert is
important for it.


(cherry picked from commit 5bee8d00691b1386025efa6c19804ed98bfebbbc)

Co-authored-by: Xaver Hugl <xaver.hugl@gmail.com>

M  +1    -1    kcm/config_handler.cpp

https://invent.kde.org/plasma/kscreen/-/commit/3b9180c1ab1c8e7c3d32650f0ca6e6fcec61e32c
Comment 8 DemonicSavage 2025-02-12 16:30:02 UTC
Using this ICC file you provided, I see that, on Arch Linux, it works only when "prefer efficiency" is enabled.

That said, my girlfriend tested on her PC (also Arch) and it does not work at all, regardless of the setting being accuracy or efficiency.
Comment 9 Shaun 2025-02-12 21:23:50 UTC
I get a blank screen setting an ICC profile regardless of which profile I select as well. Obviously if you are setting a new ICC profile on KDE 6.3 you get this blank screen, but not it will just revert after the 30 seconds times out.

For me, I already had an ICC profile set, so when I upgraded to 6.3 on my first login I was met with a blank screen and was unable to do anything. After realizing creating a new user worked, it had to be something with that specific user. Once I found this page, I was able to rename my ICC profile from terminal and login normally.
Comment 10 Manuel 2025-02-12 21:54:16 UTC
I just encountered this issue as well. With an icc profile set, my screen just turns black if I set the new color accuracy mode to "Prefer color accuracy" but it also happens if I just turn on Night Light (while having an icc profile set). The last one is quite important to me as I like to keep my monitor calibrated but frequently use the Night Light mode for less eye strain. That is also one of the things that only works on Wayland and did work before (on 6.2). So this seems to be some kind of regression.
Comment 11 Harald Weissmueller 2025-02-12 22:20:27 UTC
I had this as well right now. After some experimenting, I found out I can use my ICC profile only with the "prefer efficiency" setting and with Night Light disabled. The ICC profile causes a black screen when using "prefer accuracy", and when enabling Night Light, then both "prefer efficiency" and "prefer accuracy" cause a black screen.

So what works here is:

ICC profile + "prefer efficiency" + Night Light disabled

What doesn't work here is:

ICC profile + Night Light enabled
ICC profile + "prefer accuracy" + Night Light disabled
Comment 12 zellox 2025-02-13 11:26:07 UTC
For me the display is black always, regardless of whether night mode is on, and whether "prefer efficiency" or "prefer colour" is set.
Comment 13 lakmoesproef 2025-02-13 11:38:08 UTC
Same for me. 

* pre 6.3 it was working
* after upgrade, black screen
* can be "resolved" by clearing the `iccProfilePath` in `~/.config/kwinoutputconfig.json`
Comment 14 cwo 2025-02-13 15:26:19 UTC
*** Bug 499994 has been marked as a duplicate of this bug. ***
Comment 15 DemonicSavage 2025-02-13 16:25:57 UTC
For now, a workaround for Arch users is to get the PKGBUILD for KWin via ABS and modify it to include `-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF` as a CMake directive. This seems to have fixed the problem for me.
Comment 16 Vlad Zahorodnii 2025-02-13 17:04:24 UTC
Yeah, see also https://mail.kde.org/pipermail/distributions/2025-February/001561.html
Comment 17 Vlad Zahorodnii 2025-02-13 18:49:06 UTC
*** Bug 499926 has been marked as a duplicate of this bug. ***
Comment 18 Harald Weissmueller 2025-02-14 17:06:56 UTC
(In reply to DemonicSavage from comment #15)
> For now, a workaround for Arch users is to get the PKGBUILD for KWin via ABS
> and modify it to include `-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF` as a
> CMake directive. This seems to have fixed the problem for me.

I tried this and it didn't seem to work for me, it still causes a black screen when "prefer color accuracy" is enabled or if Night Light is enabled. I tried adding the argument to the first cmake command line in the build() function of the PKGBUILD.

What does work here for me is adding a line "options=( !lto )" to the PKGBUILD to disable the use of LTO.
Comment 19 DemonicSavage 2025-02-14 17:12:06 UTC
(In reply to Harald Weissmueller from comment #18)
> (In reply to DemonicSavage from comment #15)
> > For now, a workaround for Arch users is to get the PKGBUILD for KWin via ABS
> > and modify it to include `-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF` as a
> > CMake directive. This seems to have fixed the problem for me.
> 
> I tried this and it didn't seem to work for me, it still causes a black
> screen when "prefer color accuracy" is enabled or if Night Light is enabled.
> I tried adding the argument to the first cmake command line in the build()
> function of the PKGBUILD.
> 
> What does work here for me is adding a line "options=( !lto )" to the
> PKGBUILD to disable the use of LTO.

You're actually correct - my GF tested in on her laptop, a Thinkpad x280, and my workaround didn't work for her.
Comment 20 Damo 2025-02-15 00:46:10 UTC
What is interesting is that some ICC profiles are ok as long as prefer efficiency is set. I have two ICC one is colour clamped to SDR colour space. The other is the full colour range of the monitor. The sRGB clamped one never works. Whilst the full colour space one works regardless.  

I guess my sRGB clmaped one is a little redundant now with the sRGB slider which is a welcome addition :)
Comment 21 Damo 2025-02-15 03:32:44 UTC
Couldn't see how to edit. I meant SRGB where I said SDR
(In reply to Damo from comment #20)
> What is interesting is that some ICC profiles are ok as long as prefer
> efficiency is set. I have two ICC one is colour clamped to sRGB colour space.
> The other is the full colour range of the monitor. The sRGB clamped one
> never works. Whilst the full colour space one works regardless.  
> 
> I guess my sRGB clmaped one is a little redundant now with the sRGB slider
> which is a welcome addition :)
Comment 22 Neal Gompa 2025-02-15 11:21:12 UTC
Could someone please test to see if this problem persists with GCC 15?

I have an ISO of Fedora 42 pre-release that folks can test with here: https://kojipkgs.fedoraproject.org//packages/Fedora-KDE-Desktop-Live/42/20250215.n.0/images/Fedora-KDE-Desktop-Live-42-20250215.n.0.x86_64.iso
Comment 23 Sam James 2025-02-15 17:48:47 UTC
It fails for me with GCC 15.

https://invent.kde.org/plasma/kwin/-/blob/master/src/core/iccprofile.cpp?ref_type=heads#L89 looks suspect (aliasing violation). Replacing it with a memcpy should work.

I tried __attribute__((optimize("-fno-strict-aliasing"))) on the function which did help, I didn't yet have a chance to try memcpy. I will tonight unless beaten to it.
Comment 24 Graeme Murray 2025-02-16 00:51:16 UTC
Happens on fedora 41 also. 

* pre 6.3 it was working
* after upgrade, black screen
* can be "resolved" by clearing the `iccProfilePath` in `~/.config/kwinoutputconfig.json`

my iccProfilePath is "iccProfilePath": "",

but of course kwinoutputconfig.json gets re-created ever ytime you login.
Comment 25 Greeniac 2025-02-16 02:05:48 UTC
*** Bug 500061 has been marked as a duplicate of this bug. ***
Comment 26 Bug Janitor Service 2025-02-16 22:01:39 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/7166
Comment 27 Vlad Zahorodnii 2025-02-16 22:30:59 UTC
Git commit 6d6667fc2a3f0a5e51676be267a5a8e1ce3c1337 by Vlad Zahorodnii.
Committed on 16/02/2025 at 22:10.
Pushed by vladz into branch 'master'.

core: Fix initialization of IccProfile::s_connectionSpace

Colorimetry constants can be initialized after IccProfile::s_connectionSpace
when LTO is enabled. It's okay with the C++ standard.

As a way around it, this change moves the CIEXYZD50 constant to the
IccProfile where it's actually needed.

We need to reconsider how the constants are defined, e.g. have static
getters or use constexpr. But as a short term solution, this should be
fine.

Co-authored-by: Xaver Hugl <xaver.hugl@gmail.com>

M  +0    -2    src/backends/wayland/color_manager.cpp
M  +0    -8    src/core/colorspace.cpp
M  +0    -1    src/core/colorspace.h
M  +8    -1    src/core/iccprofile.cpp

https://invent.kde.org/plasma/kwin/-/commit/6d6667fc2a3f0a5e51676be267a5a8e1ce3c1337
Comment 28 Vlad Zahorodnii 2025-02-16 22:53:00 UTC
Git commit 196c95d8bbab6519d0cc742ae3b595081051c08e by Vlad Zahorodnii.
Committed on 16/02/2025 at 22:39.
Pushed by vladz into branch 'Plasma/6.3'.

core: Fix initialization of IccProfile::s_connectionSpace

Colorimetry constants can be initialized after IccProfile::s_connectionSpace
when LTO is enabled. It's okay with the C++ standard.

As a way around it, this change moves the CIEXYZD50 constant to the
IccProfile where it's actually needed.

We need to reconsider how the constants are defined, e.g. have static
getters or use constexpr. But as a short term solution, this should be
fine.

Co-authored-by: Xaver Hugl <xaver.hugl@gmail.com>
(cherry picked from commit 6d6667fc2a3f0a5e51676be267a5a8e1ce3c1337)

M  +0    -8    src/core/colorspace.cpp
M  +0    -1    src/core/colorspace.h
M  +8    -1    src/core/iccprofile.cpp

https://invent.kde.org/plasma/kwin/-/commit/196c95d8bbab6519d0cc742ae3b595081051c08e
Comment 29 David Edmundson 2025-02-17 09:47:53 UTC
*** Bug 500011 has been marked as a duplicate of this bug. ***
Comment 30 David Edmundson 2025-02-17 09:47:56 UTC
*** Bug 500010 has been marked as a duplicate of this bug. ***
Comment 31 Martin Riethmayer 2025-02-20 15:27:58 UTC
*** Bug 500437 has been marked as a duplicate of this bug. ***