Bug 366067 - Impartial kscreen config for setup leads to partially configured desktop on hitting 'Apply'
Summary: Impartial kscreen config for setup leads to partially configured desktop on h...
Status: RESOLVED FIXED
Alias: None
Product: KScreen
Classification: Plasma
Component: common (show other bugs)
Version: 5.7.2
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: Sebastian Kügler
URL:
Keywords: multiscreen
Depends on:
Blocks:
 
Reported: 2016-07-25 02:30 UTC by jamese
Modified: 2016-08-10 01:09 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.8.0


Attachments
Possibly impartial Kscreen config leading to bug ? (1.13 KB, text/plain)
2016-07-25 02:34 UTC, jamese
Details
Kscreen config for setup when displays correctly configure (1.43 KB, text/plain)
2016-07-25 02:36 UTC, jamese
Details
Photo of Laptop Screen when it's split down the middle (397.06 KB, image/jpeg)
2016-07-25 02:41 UTC, jamese
Details
Kscreen config, laptop with HDMI plugged in (974 bytes, text/plain)
2016-07-29 00:46 UTC, jamese
Details
Laptop with MST Displayport config (1.43 KB, text/plain)
2016-07-29 00:48 UTC, jamese
Details
Output of kcmshell5 kcm_kscreen (11.35 KB, text/plain)
2016-07-29 00:52 UTC, jamese
Details
Output of kscreen-bug with HDMI resolution OK (22.50 KB, text/plain)
2016-07-29 00:53 UTC, jamese
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jamese 2016-07-25 02:30:13 UTC
I've got a DisplayPort 1.2 / MST setup, same is in the unrelated Bug #362570.
There are two DP1.2 screens above the laptop screen, the laptop is placed below and in the middle of the two external screens. The left screen DP1-2 is the last in the MST chain, the right is the primary screen in the chain.

Often when I configure the screens for this setup in Display Settings, the 2 external screens appear greyed out in the Display Settings area and are not marked as "Enabled". When I Enable them, position them and then hit "Apply" the external screens remain blank and the Laptop Screen is split down the middle (probably due to the positioning in Display Settings). 
No widgets or applications are usable when this happens but the mouse cursor remains movable.

The only way to resurrect the Desktop is by switching to a another run level, moving the offending ~/.local/share/kscreen config file (or all of them) and then restarting sddm, then logging in again. At this point the screen configuration proceeds OK.
Obviously restarting SDDM causes all running applications to close including running virtual machines which means I now close all applications and shutdown virtual machines before trying to configure this screen setup to avoid issues with the VMs.

In the other run level, I check the config file being used by kscreen and it appears that the two external screens are missing the "mode" entry, which contain refresh and size values.  If I was a user that didn't know about runlevels I'd probably hard reset the laptop.


Makes me think that the config is being partially applied or being applied without refresh, width and height values.


See upcoming attachments and some debug output. This happened with Kubuntu 16.04 packages as well (now using Neon/User)

I can switch to an HDMI / Displayport hybrid setup and see if this can reproduced as it would help to isolate the issue.



Reproducible: Sometimes

Steps to Reproduce:
1. Plug in Display Port  1.2 / MST screens, external screens don't automatically configure
2. Position and Enable external screens
3. Hit Apply, laptop screens split down the middle and is unresponsive

Actual Results:  
Switched to runlevel 1 and remove kscreen config, then restart sddm to reconfigured screens

Expected Results:  
External screens should be configured and appear with most recent panel configuration, laptop screen should not split down the middle.
Comment 1 jamese 2016-07-25 02:34:00 UTC
Created attachment 100279 [details]
Possibly impartial Kscreen config leading to bug ?

This is the config that was active at the time of the bug. The 'mode' entries are not present for the two external screens
Comment 2 jamese 2016-07-25 02:36:28 UTC
Created attachment 100280 [details]
Kscreen config for setup when displays correctly configure

This config includes the "mode" entry. It has the same filename as the config without the mode entry.
Comment 3 jamese 2016-07-25 02:41:47 UTC
Created attachment 100281 [details]
Photo of Laptop Screen when it's split down the middle

The left part of the screen is moved to the right, the other half is on the left. Panel is at top on purpose.
The location of the split is based on where the external screens are joined above the Laptop Screen.
Comment 4 jamese 2016-07-25 02:43:58 UTC
Plasma 5.7.2, Qt 5.7, Neon/User packages.

I'll try to grab some debugging info when it happens again based on https://community.kde.org/Solid/Projects/ScreenManagement
Comment 5 Sebastian Kügler 2016-07-25 22:58:29 UTC
Thanks for the bug report! I've had a look at the info you provided, here's my analysis:

Facts: 
- kscreen can write out a working configuration for your setup
- when logging in, kscreen fails to restore the working config
- a new configuration for your setup is written, your external screens are disabled
- the modes aren't written because the displays are set to disabled
Fiction (my interpretation):
- when logging in, kscreen somehow fails to enable the two external displays
- it then writes out a new configuration with the two externals disabled, overwriting the correct previous config file
- the correct config is now gone until you set the displays explicitly to enabled again (crossing fingers that it works this time)
- everything is peachy, until it fails again...

A problem with debugging is is that we can't really see what's going on deep down in xrandr. These calls are all made out of process, and it's quite hard to get reliable information from it.

Questions:
- Could you try making the correct config file (in a working setup) non-writable for your user, for example by chowning it (temporarily) to root? In this case, do subsequent login attempts work?
- It would indeed be interesting to see if this is only a problem with your MST setup, so if you could try displayport / hdmi as well, that would be useful information.
Comment 6 jamese 2016-07-29 00:45:48 UTC
Here's some further debugging on this one.

Config "ae115bc4aa5f4ce701f72fc9e25f01cb" is the MST setup with Laptop Screen + DP1-1 (master) and DP1-2 (slave) - I chmod'd this to 0400 so it couldn't be written by any user. It still has the width/height in it from the last working setup.
Config "1818bd03d6fa05c34acde90101a5d242" is the Laptop with HDMI plugged in.

I plugged in DP cable and the bug reproduces.  I've got kcmshell5 kcm_kscreen running and will attach output although nothing appears in the output when I activate the DP setup.
I unplug the DP cable and no change to the desktop occurs. Laptop screen is still split in half  & external DP screens are not active at all.
I then switch inputs on DP1-2 to HDMI and plug in the HDMI cable, this brings the desktop back with HDMI output enabled and visible along with Laptop Screen. But:

* HDMI (HDMI2 in kscreen) says "No available resolutions" and the display is slightly fuzzy. It also appears to be at a lower bit depth
* After some repositioning of the HDMI screen and hitting apply, the resolution slider appears with 1920x1080 enabled and the bit depth  / fuzziness issues disappear.

I then unplug the HDMI cable to see if I can get DP displays back and the Laptop screen goes black then comes back and freezes although the mouse cursor works. Can't do anything here. Plugging the DP cable in does not bring the desktop back, nothing in kcmshell output. Can't run kscreen-bug here as only mouse works.
Plugging the HDMI cable back in re-activates the desktop!

Other weirdness that occurs here:
- is when I plug the HDMI cable in, all the windows either from Gtk (Shutter) or KDE apps (e.g kate) disappear under the panel when maximised, even though the panel has "Always Visible" set.
This is a common problem for me at the moment with KDE multi-screen setup.
- when I initally plug in the DP screens they come up greyed out, showing the wrong aspect ratio although the slider says 1920x1080. If I fiddle with the slider the greyed out screens resize correctly.

Configs and outputs will be attached.
Comment 7 jamese 2016-07-29 00:46:55 UTC
Created attachment 100363 [details]
Kscreen config, laptop with HDMI plugged in

This after the screen fuzziness and bit depth issues are resolved.
Comment 8 jamese 2016-07-29 00:48:41 UTC
Created attachment 100364 [details]
Laptop with MST Displayport config

I chmod'd this to 0400, before trying to plug in DP cable.
Comment 9 jamese 2016-07-29 00:52:28 UTC
Created attachment 100365 [details]
Output of kcmshell5 kcm_kscreen

I added a note showing where I switched outputs from DP to HDMI,  as I move the HDMI screen around in the settings layout area and hit apply, the fuzziness and bit depth issues go away but I have to restart kcm_kscreen to get the slider showing in place of "No available resolutions"
Comment 10 jamese 2016-07-29 00:53:29 UTC
Created attachment 100366 [details]
Output of kscreen-bug with HDMI resolution OK
Comment 11 jamese 2016-07-29 01:05:31 UTC
I should also point out that while the Plasma desktop is munged with the DP cable plugged in the following can happen:

- Mouse cursor works
- I can switch to run level 1 with Ctrl+Alt+1
- When I switch to run level 1, my two DP screens come up perfectly, DP1-1 followed by DP1-2 a second later.
- I can't get a "kscreen-console bug" report on run level 1 even with "export DISPLAY=:0" before.

Switching back with Ctrl+Alt+7 returns me to the munged desktop which can now be rescued by plugging in an  HDMI cable
Comment 12 Sebastian Kügler 2016-08-10 01:09:51 UTC
Alright. It seems to all boil down to not being able to enable the display.

I've fixed two bugs in kscreen, which lead to this behavior. These should fix the root cause for your problem. These fixes will be released with Plasma 5.8.

Thanks a lot for the useful bug-report and quick follow-ups!