Bug 474915

Summary: External monitor doesn't work after plugging in
Product: [Plasma] kwin Reporter: Nicolas Fella <nicolas.fella>
Component: generalAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: nate, xaver.hugl
Priority: NOR Keywords: qt6
Version First Reported In: master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: drm_info while screen is working

Description Nicolas Fella 2023-09-26 19:42:45 UTC
STEPS TO REPRODUCE
0. Start with a fresh setup. Laptop with no monitor connected. rm -r .local/share/kscreen. reboot
1. Connect HDMI monitor

OBSERVED RESULT
KScreen recognizes the screen, i.e. it shows up in the KCM and kscreen-doctor, but the screen is black/not working

EXPECTED RESULT
Working screen

SOFTWARE/OS VERSIONS
KDE Plasma Version: master
KDE Frameworks Version: master
Qt Version: 6.6

ADDITIONAL INFORMATION
Wayland
Comment 1 Nicolas Fella 2023-09-26 19:43:20 UTC
kscreen-doctor -o before plugging in:
Output: 1 eDP-1 enabled connected priority 1 Panel Modes: 0:3840x2400@60*! 1:1920x1200@60 2:1920x1080@60 3:1600x1200@60 4:1680x1050@60 5:1280x1024@60 6:1440x900@60 7:1280x800@60 8:1280x720@60 9:1024x768@60 10:800x600@60 11:640x480@60 12:1600x1200@60 13:1280x1024@60 14:1024x768@60 15:2560x1600@60 16:1920x1200@60 17:1280x800@60 18:3840x2160@60 19:3200x1800@60 20:2880x1620@60 21:2560x1440@60 22:1920x1080@60 23:1600x900@60 24:1368x768@60 25:1280x720@60 Geometry: 0,0 1536x960 Scale: 2.5 Rotation: 1 Overscan: 0 Vrr: Automatic RgbRange: unknown HDR: incapable Wide Color Gamut: incapable

And after:
Output: 1 eDP-1 enabled connected priority 1 Panel Modes: 0:3840x2400@60*! 1:1920x1200@60 2:1920x1080@60 3:1600x1200@60 4:1680x1050@60 5:1280x1024@60 6:1440x900@60 7:1280x800@60 8:1280x720@60 9:1024x768@60 10:800x600@60 11:640x480@60 12:1600x1200@60 13:1280x1024@60 14:1024x768@60 15:2560x1600@60 16:1920x1200@60 17:1280x800@60 18:3840x2160@60 19:3200x1800@60 20:2880x1620@60 21:2560x1440@60 22:1920x1080@60 23:1600x900@60 24:1368x768@60 25:1280x720@60 Geometry: 0,0 1536x960 Scale: 2.5 Rotation: 1 Overscan: 0 Vrr: Automatic RgbRange: unknown HDR: incapable Wide Color Gamut: incapable
Output: 2 HDMI-A-1 enabled connected priority 2 HDMI Modes: 0:3840x2160@30! 1:3840x2160@30 2:3840x2160@30 3:3840x2160@30 4:3840x2160@25 5:3840x2160@24 6:3840x2160@24 7:2560x1440@60 8:2048x1280@60 9:1920x1200@30 10:1920x1080@60 11:1920x1080@60 12:1920x1080@60 13:1920x1080@50 14:1920x1080@30 15:1920x1080@30 16:1920x1080@25 17:1920x1080@24 18:1920x1080@24 19:1600x1200@60 20:1680x1050@30 21:1600x900@60 22:1280x1024@75 23:1280x1024@60 24:1440x900@30 25:1280x800@30 26:1152x864@75 27:1280x720@60 28:1280x720@60 29:1280x720@50 30:1024x768@75 31:1024x768@60 32:800x600@75 33:800x600@60 34:720x576@50 35:720x576@50 36:720x480@60 37:720x480@60 38:720x480@60 39:720x480@60 40:640x480@75 41:640x480@60 42:640x480@60 43:640x480@60 44:720x400@70 45:1600x1200@60 46:1280x1024@60 47:1024x768@60 48:2560x1600@60* 49:1920x1200@60 50:1280x800@60 51:2560x1440@60 52:1920x1080@60 53:1600x900@60 54:1368x768@60 55:1280x720@60 Geometry: 1536,0 1707x1067 Scale: 1.5 Rotation: 1 Overscan: 0 Vrr: incapable RgbRange: unknown HDR: incapable Wide Color Gamut: incapable
Comment 2 Nicolas Fella 2023-09-26 19:47:13 UTC
What's interesting is that the "2560x1600 (16:10)" resolution is automatically chosen instead of the higher "3840x2160 (16:9)".

Selecting the latter in the KCM makes the screen actually work. However after un- and replugging "2560x1600" is chosen again and the screen again doesn't work.

On 5.27 the higher working resolution is chosen automatically. Selecting "2560x1600" makes the screen not work
Comment 3 Nicolas Fella 2023-09-26 19:48:17 UTC
Created attachment 161892 [details]
drm_info while screen is working
Comment 4 Nicolas Fella 2023-09-26 19:53:38 UTC
On another laptop with a different screen and GPU I'm not even offered the broken "2560x1600" resolution
Comment 5 Zamundaaa 2023-09-27 15:27:36 UTC
The lower resolution mode being chosen automatically is intentional, because you only get 30Hz with the 4k mode.

In this case it chose one of the "common modes" that KWin generates though. They're not guaranteed to work and should be filtered out for the choice of the default mode.
Comment 6 Nicolas Fella 2023-09-27 15:30:49 UTC
> Selecting the latter in the KCM makes the screen actually work. However after un- and replugging "2560x1600" is chosen again and the screen again doesn't work.

Shouldn't my explicitly chosen mode persist after un/replugging?
Comment 7 Bug Janitor Service 2023-09-27 15:38:44 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4454
Comment 8 Zamundaaa 2023-09-27 15:41:14 UTC
> Shouldn't my explicitly chosen mode persist after un/replugging?
It should, but there can be situations where KScreen thinks KWin didn't change the default but actually changed a setting at runtime (like when you change stuff in the KCM); I presume that's what's happening to you. That issue should be gone with the new system
Comment 9 Zamundaaa 2023-09-27 17:17:39 UTC
Git commit b266b08145d63aacc2aa43b571f0eaf2bd4a9af4 by Xaver Hugl.
Committed on 27/09/2023 at 17:38.
Pushed by zamundaaa into branch 'master'.

outputconfigurationstore: don't select generated modes as the default

They're not guaranteed to work, so choosing them as the default mode can
result in a display that doesn't light up or only shows garbage

M  +6    -6    src/backends/drm/drm_connector.cpp
M  +1    -1    src/backends/drm/drm_connector.h
M  +1    -0    src/core/output.h
M  +4    -0    src/outputconfigurationstore.cpp

https://invent.kde.org/plasma/kwin/-/commit/b266b08145d63aacc2aa43b571f0eaf2bd4a9af4
Comment 10 Nicolas Fella 2023-09-27 21:12:38 UTC
Now KWin picks 1024x768@75 (4:3) by default, which works, but is very inappropriate