Bug 488270 - Displays lose setting when waking from power save.
Summary: Displays lose setting when waking from power save.
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: output configuration (show other bugs)
Version: 6.0.5
Platform: Arch Linux Linux
: NOR major
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 497459 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-06-09 21:13 UTC by docw2732
Modified: 2025-01-27 03:02 UTC (History)
6 users (show)

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


Attachments
journalctl of wake process (67.01 KB, text/plain)
2024-06-09 21:13 UTC, docw2732
Details
First journalctl was fail, second journalctl was sucessful wake (11.16 KB, text/plain)
2024-06-09 23:00 UTC, docw2732
Details
wayland-info (51.79 KB, text/plain)
2024-06-11 14:52 UTC, docw2732
Details
kscreen-doctor -o (78.91 KB, image/png)
2024-06-11 14:53 UTC, docw2732
Details
kscreen-doctor -o after issue (1.20 MB, image/png)
2024-06-11 19:21 UTC, docw2732
Details
kwinoutputconfig.json before the issue happens (6.97 KB, text/plain)
2024-07-11 17:24 UTC, docw2732
Details
kwinoutputconfig.json after the issue happened (8.52 KB, text/plain)
2024-07-11 17:24 UTC, docw2732
Details
drm_info befor the issue happens (71.69 KB, application/octet-stream)
2024-07-11 17:25 UTC, docw2732
Details
drm_info after the issue happens (71.68 KB, application/octet-stream)
2024-07-11 17:25 UTC, docw2732
Details
Requested edid (384 bytes, application/octet-stream)
2024-12-18 00:44 UTC, docw2732
Details
edid2 (384 bytes, application/octet-stream)
2024-12-18 00:44 UTC, docw2732
Details
Clean pre-bug kwinoutputconfig.json (3.82 KB, application/json)
2024-12-18 01:04 UTC, Elabajaba
Details
Bad post-bug kwinoutputconfig.json (6.82 KB, application/json)
2024-12-18 01:05 UTC, Elabajaba
Details
/sys/class/drm/card0-DP-2/edid (256 bytes, application/octet-stream)
2024-12-18 01:06 UTC, Elabajaba
Details
/sys/class/drm/card0-DP-3/edid (256 bytes, application/octet-stream)
2024-12-18 01:06 UTC, Elabajaba
Details
/sys/class/drm/card0-HDMI-A-1/edid (256 bytes, application/octet-stream)
2024-12-18 01:06 UTC, Elabajaba
Details

Note You need to log in before you can comment on or make changes to this bug.
Description docw2732 2024-06-09 21:13:06 UTC
Created attachment 170301 [details]
journalctl of wake process

SUMMARY
When monitors wake up from power save (just turning the displays off, not full sleep) sometimes settings are lost and rotation, position and sizing is lost. It happens about 25% of the time.

2 Samsung Odyssey Neo G8 32" 4k monitors. Both connected with DP
1 LG TV 1920x1080. Connected with HDMI

The 2 monitors are side by side with one monitor horizontal and one monitor vertical. The TV gets turned on infrequently and is above the horizontal monitor.
The monitors are set to 3840x2160 120hz with no scaling and the horizontal monitor being primary.

Using the latest version of plasma 6 (wayland) on arch.

My computer is set to never sleep but to turn off displays after 15 minutes. The issues happens when waking the displays.

STEPS TO REPRODUCE
1. Let the monitors enter power save.
2.  Wake up monitors at a later point

OBSERVED RESULT
When waking the monitors from power save both monitors wake up but 25% of the time one or more of the following happens.

    One or both displays are rotated incorrectly.
    Screens will swap places (left/right)
    Primary display will switch.
    Scaling of one or both monitors will change.


EXPECTED RESULT
Screens (position, orientation, scaling, primary etc.) stay as they were before turning off for power save.

SOFTWARE/OS VERSIONS
Arch Linux Kernel Version: 6.9.3-arch1-1 (64-bit)
KDE Plasma Version: 6.0.5
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.1

ADDITIONAL INFORMATION
GPU doesnโ€™t matter. Wife has same displays/setup. I have Nvidia GTX 1070. Wife has Radeon 7900XTX. Issue is the same with both setups, leading me to believe its something cause by the monitors.
No issues on boot. Only happens when waking from power save or turning on the TV (adding as 3rd monitor)

I am new to Linux, please let me know if I can add any additional useful information, or find better logs somewhere different.
Comment 1 docw2732 2024-06-09 23:00:15 UTC
Created attachment 170310 [details]
First journalctl was fail, second journalctl was sucessful wake

This shows 2 different wake from power saves. The first one flipped orientation of main screen on wake. The second one kept settings as expected.
Comment 2 Zamundaaa 2024-06-11 14:30:18 UTC
Please attach the outputs of "wayland-info" and "kscreen-doctor -o" while both displays are connected
Comment 3 docw2732 2024-06-11 14:52:40 UTC
Created attachment 170374 [details]
wayland-info
Comment 4 docw2732 2024-06-11 14:53:24 UTC
Created attachment 170375 [details]
kscreen-doctor -o
Comment 5 Zamundaaa 2024-06-11 16:14:31 UTC
Okay, so both monitors have the same serial number. Could you please attach the output of kscreen-doctor -o again after triggering the output configuration to swap?
Comment 6 docw2732 2024-06-11 19:21:08 UTC
Created attachment 170388 [details]
kscreen-doctor -o after issue

Primary monitor lost primary, changed from 100% scaling to 150% and swapped sides. Secondary monitor swapped orientation and got marked as primary.
Comment 7 Bug Janitor Service 2024-06-26 03:47:51 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 8 Zamundaaa 2024-07-10 17:31:46 UTC
Okay, I think it's picking completely different output settings alltogether. Could you also attach the ~/.config/kwinoutputconfig.json file and the output of drm_info, each for before you trigger the issue and after?
Comment 9 docw2732 2024-07-11 17:24:03 UTC
Created attachment 171577 [details]
kwinoutputconfig.json before the issue happens
Comment 10 docw2732 2024-07-11 17:24:32 UTC
Created attachment 171578 [details]
kwinoutputconfig.json after the issue happened
Comment 11 docw2732 2024-07-11 17:25:02 UTC
Created attachment 171579 [details]
drm_info befor the issue happens
Comment 12 docw2732 2024-07-11 17:25:40 UTC
Created attachment 171580 [details]
drm_info after the issue happens
Comment 13 docw2732 2024-07-11 17:27:42 UTC
I found I am able to set my monitors back when this happens with the following alias I created. I don't know if this helps at all with preventing the issue from happening.

displaymain is aliased to `kscreen-doctor output.DP-2.enable output.DP-2.mode.3840x2160@120 output.DP-1.enable output.DP-1.mode.3840x2160@120 output.DP-2.rotation.normal output.DP-1.rotation.right output.DP-2.scale.1.00 output.DP-2.primary  output.DP-1.scale.1.00 output.DP-2.position.0,1193 output.DP-1.position.3840,0; kscreen-doctor output.HDMI-A-2.disable'
Comment 14 Elabajaba 2024-12-17 23:04:19 UTC
I also have this issue, and I believe it's due to having a display connected but disabled in KDE's display settings. On wakeup both the positioning between the displays (orientation is fine, it always remembers my vertical monitor is set to vertical) and the primary display selection gets scrambled.

I don't think it's an AMD driver bug or hardware issue as it works properly on Gnome.
Comment 15 Zamundaaa 2024-12-17 23:34:22 UTC
(In reply to docw2732 from comment #10)
> Created attachment 171578 [details]
> kwinoutputconfig.json after the issue happened
What I can see in there is
1. your Samsung screens have the same serial number (boo Samsung!)
2. the screens do have different EDID hashes though, so we can identify them with that
3. despite that, there are two entries in the config that are completely identical

but I'm still not sure how that happens, this situation is supposed to be handled already.
Could you attach the EDID of your screens here, so that we can put it into an autotest, hopefully find the cause and prevent the issue from happening again in the future? You can get the EDID blobs with
> cat /sys/class/drm/card1-DP-1/edid > edid.bin
> cat /sys/class/drm/card1-DP-2/edid > edid2.bin

(In reply to Elabajaba from comment #14)
> I also have this issue, and I believe it's due to having a display connected
> but disabled in KDE's display settings. On wakeup both the positioning
> between the displays (orientation is fine, it always remembers my vertical
> monitor is set to vertical) and the primary display selection gets scrambled.
> 
> I don't think it's an AMD driver bug or hardware issue as it works properly
> on Gnome.
Please attach your kwinoutputconfiguration.json and the EDID data as well
Comment 16 docw2732 2024-12-18 00:44:15 UTC
Created attachment 176729 [details]
Requested edid
Comment 17 docw2732 2024-12-18 00:44:36 UTC
Created attachment 176730 [details]
edid2
Comment 18 Elabajaba 2024-12-18 01:04:57 UTC
Created attachment 176731 [details]
Clean pre-bug kwinoutputconfig.json
Comment 19 Elabajaba 2024-12-18 01:05:14 UTC
Created attachment 176732 [details]
Bad post-bug kwinoutputconfig.json
Comment 20 Elabajaba 2024-12-18 01:06:21 UTC
Created attachment 176733 [details]
/sys/class/drm/card0-DP-2/edid
Comment 21 Elabajaba 2024-12-18 01:06:35 UTC
Created attachment 176734 [details]
/sys/class/drm/card0-DP-3/edid
Comment 22 Elabajaba 2024-12-18 01:06:57 UTC
Created attachment 176735 [details]
/sys/class/drm/card0-HDMI-A-1/edid
Comment 23 Zamundaaa 2024-12-18 01:53:25 UTC
(In reply to docw2732 from comment #17)
> Created attachment 176730 [details]
> edid2
Wow, this is an especially stupid case. The EDID contains *two* serial numbers, one as a string, and one as a number. The number is the same in the two displays (and this one is currently used for identifying screens in KWin!) but the serial number string is different.
We can improve the situation a bit beyond fixing the bug by adding a version 2 identifier that contains the serial number string in addition to the number. In hindsight I should've expected display manufacturers to mess things up this bad...

(In reply to Elabajaba from comment #18)
> Created attachment 176731 [details]
> Clean pre-bug kwinoutputconfig.json
Okay, that does look like the exact same situation - same serial number, different edid hash.

Thanks for the EDIDs, this should help a lot in fixing it.
Comment 24 Elabajaba 2024-12-18 03:42:14 UTC
(In reply to Zamundaaa from comment #23)
> (In reply to docw2732 from comment #17)
> > Created attachment 176730 [details]
> > edid2
> Wow, this is an especially stupid case. The EDID contains *two* serial
> numbers, one as a string, and one as a number. The number is the same in the
> two displays (and this one is currently used for identifying screens in
> KWin!) but the serial number string is different.
> We can improve the situation a bit beyond fixing the bug by adding a version
> 2 identifier that contains the serial number string in addition to the
> number. In hindsight I should've expected display manufacturers to mess
> things up this bad...
> 
> (In reply to Elabajaba from comment #18)
> > Created attachment 176731 [details]
> > Clean pre-bug kwinoutputconfig.json
> Okay, that does look like the exact same situation - same serial number,
> different edid hash.
> 
> Thanks for the EDIDs, this should help a lot in fixing it.

In my case this isn't really a bug. I've got 2 cables going into the same LG CX TV because I dual boot Windows and use HDMI 2.1 on Windows, but have to use a DP->HDMI 2.1 adapter on Linux because AMD gpus don't support HDMI 2.1 on Linux https://gitlab.freedesktop.org/drm/amd/-/issues/1417 (and I can't just use the adapter for both because the adapter firmware that gives 4k120 4:4:4 + HDR + VRR on Linux doesn't work on Windows ๐Ÿ™ƒ).
Comment 25 Zamundaaa 2024-12-18 16:52:11 UTC
*** Bug 497459 has been marked as a duplicate of this bug. ***
Comment 26 Bug Janitor Service 2024-12-18 17:16:57 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6914
Comment 27 Zamundaaa 2025-01-23 18:50:41 UTC
Git commit 7e450e42e5fcbe5d077fcfa473c65a8954c35d11 by Xaver Hugl.
Committed on 23/01/2025 at 18:33.
Pushed by zamundaaa into branch 'master'.

outputconfigurationstore: handle imperfect matches for outputs better

There are some situations where there can be multiple matches for a given output, like
when two outputs with the same EDID ID but different EDID hashes or connector names were
connected before and now only one of them is connected.
In these situations, we'd previously just pick the first match in the list, even though
the other match is more precise; and that could end up changing the settings for that
output. Once the second output is connected again, it would then get the wrong settings.

To fix that, this commit only considers an entry in the config as a match if there is only
one match for the relevant criteria. If there's multiple, then the search is narrowed down
to take more crtieria into account, like the MST path or the connector name.
Related: bug 489457

M  +90   -38   src/outputconfigurationstore.cpp
M  +3    -4    src/outputconfigurationstore.h

https://invent.kde.org/plasma/kwin/-/commit/7e450e42e5fcbe5d077fcfa473c65a8954c35d11
Comment 28 Zamundaaa 2025-01-23 19:13:44 UTC
Git commit c3f4149bf02322011842ad48682c6deabedefc00 by Xaver Hugl.
Committed on 23/01/2025 at 18:37.
Pushed by zamundaaa into branch 'Plasma/6.3'.

outputconfigurationstore: handle imperfect matches for outputs better

There are some situations where there can be multiple matches for a given output, like
when two outputs with the same EDID ID but different EDID hashes or connector names were
connected before and now only one of them is connected.
In these situations, we'd previously just pick the first match in the list, even though
the other match is more precise; and that could end up changing the settings for that
output. Once the second output is connected again, it would then get the wrong settings.

To fix that, this commit only considers an entry in the config as a match if there is only
one match for the relevant criteria. If there's multiple, then the search is narrowed down
to take more crtieria into account, like the MST path or the connector name.
Related: bug 489457
(cherry picked from commit 7e450e42e5fcbe5d077fcfa473c65a8954c35d11)

M  +90   -38   src/outputconfigurationstore.cpp
M  +3    -4    src/outputconfigurationstore.h

https://invent.kde.org/plasma/kwin/-/commit/c3f4149bf02322011842ad48682c6deabedefc00
Comment 29 Real Name Here 2025-01-27 03:02:59 UTC
(In reply to Zamundaaa from comment #28)
> Git commit c3f4149bf02322011842ad48682c6deabedefc00 by Xaver Hugl.
> Committed on 23/01/2025 at 18:37.
> Pushed by zamundaaa into branch 'Plasma/6.3'.
> 
> outputconfigurationstore: handle imperfect matches for outputs better
> 
> There are some situations where there can be multiple matches for a given
> output, like
> when two outputs with the same EDID ID but different EDID hashes or
> connector names were
> connected before and now only one of them is connected.
> In these situations, we'd previously just pick the first match in the list,
> even though
> the other match is more precise; and that could end up changing the settings
> for that
> output. Once the second output is connected again, it would then get the
> wrong settings.
> 
> To fix that, this commit only considers an entry in the config as a match if
> there is only
> one match for the relevant criteria. If there's multiple, then the search is
> narrowed down
> to take more crtieria into account, like the MST path or the connector name.
> Related: bug 489457
> (cherry picked from commit 7e450e42e5fcbe5d077fcfa473c65a8954c35d11)
> 
> M  +90   -38   src/outputconfigurationstore.cpp
> M  +3    -4    src/outputconfigurationstore.h
> 
> https://invent.kde.org/plasma/kwin/-/commit/
> c3f4149bf02322011842ad48682c6deabedefc00

I don't know if your git commit fixes this but with identical serial numbers, the Display Configuration screen doesn't correctly register applied changes.  The title of the window reads "Display Configuration * -- System Settings", the Apply button remains clickable, and a warning pop ups about unsaved changes when closing the window. However, the settings are indeed applied so this is more of an annoyance than anything.

Thanks for the fixes, by the way!