Bug 349052

Summary: Shared QML engine causes shared layout for all containments, breaking multi-containment setups (screens, activities)
Product: [Plasma] plasmashell Reporter: Luca Beltrame <lbeltrame>
Component: generalAssignee: David Edmundson <kde>
Status: RESOLVED FIXED    
Severity: major CC: bhush94, dvratil, kde, notmart, plasma-bugs, tittiatcoke
Priority: NOR    
Version: master   
Target Milestone: 1.0   
Platform: openSUSE   
OS: Linux   
URL: https://youtu.be/-f_kcPSmTgg
Latest Commit: Version Fixed In: 5.4.0
Sentry Crash Report:

Description Luca Beltrame 2015-06-12 07:23:13 UTC
With latest master, layouting in multiscreen is dysfunctional: widgets can't be moved freely on the desktop, and in fact they self-resize in odd positions for no apparent reason. Part of this can be workarounded with a plasmashell restart, which doesn't save the widget geometry, somehow.

The changes are shown in this clip (see bug URL report):  https://youtu.be/-f_kcPSmTgg

I've reproduced this in two setups:

1. 3 x 1280x1024 monitors
2. 2 x 1920x1080 monitors

Reproducible: Always

Steps to Reproduce:
1. Move widgets in a multiscreen setup


Actual Results:  
Widgets do not move to the right position, resize randomly

Expected Results:  
Widgets move to the right position.
Comment 1 Luca Beltrame 2015-06-12 07:42:58 UTC
Switching to Folder View -> Desktop fixes the issue *for that screen* until plasma restart.
Another sympthom I noticed is that the add widget controller opens on the wrong screen when adding panels.
Comment 2 Luca Beltrame 2015-06-12 07:58:11 UTC
Also, some more hints: after a restart, I got the wallpapers mixed up - the rotated screen one went up on the primary one, and the other on the opposite.
Comment 3 Raymond Wooninck 2015-06-12 08:00:57 UTC
I can reproduce this effect and i noticed the following:

I have a setup with two monitors (1920x1200 and 1600x900). When I want to place a plasmoid, then everything works as expected on the 1600x900 screen. However when I want to place a plasmoid on the 1920x1200 screen, then somehow I can only place the plasmoid in an area equal to 1600x900). This area starts from the upper left corner of the 1920x1200 screen and I can not place any plasmoids in the lower bottom area nor in an area to the right. Everywhere else the plasmoid can be placed without issues. So depending on how the screens are defined (portrait, landscape, etc), this could be giving strange results). 

I copied Dan Vratil to the bug as well, as that this might be related to Kscreen
Comment 4 Luca Beltrame 2015-06-20 22:25:56 UTC
I've seen this behavior also on a single screen (laptop) when switching activites, so I'm not sure it's due to multiscreen.
Comment 5 Luca Beltrame 2015-07-11 08:37:57 UTC
After testing and testing, I finally realized what is causing this issue. The shared QML engine, or something related to it, causes layouts to be transparently *identical* for *all containments* running. 

E.g.: I place a pastebin plasmoid on the lower part of a screen, or even a single-screen containment. Then I move to another containment (activity or screen) and try to move another widget, for example a folder view. It will auto-resize to prevent overlapping the pastebin plasmoid, even though *it's in another containment*.

The differences in behavior with multiscreen and single screen are:

- Single screen: the mis-layouting among containments occurs only at startup, not at runtime
- Multi screen: the mis-layouting occurs at runtime.

Clearly the code needs to be changed to ensure that containments don't share their own layouts.
Comment 6 Kai Uwe Broulik 2015-07-11 09:16:27 UTC
I've seen the layout manager get confused too but couldn't figure out why but I had a projector attached when that happens, makes sense now. Probably the LayoutManager which is in a separate JS file is shared across all views.
Comment 7 David Edmundson 2015-07-11 09:19:03 UTC
Is this with latest frameworks and workspace 5.3 or master of both?
Comment 8 Kai Uwe Broulik 2015-07-11 09:24:32 UTC
Can anyone test whether removing the ".pragma library" statement from the LayoutManager.js in plasma-desktop/containments/desktop/package/contents/code fixes the issue? It causes the LayoutManager to become shared between all items using it, so when somebody calls setSpaceAvailable(x,y,w,h) it will affect all containments, which is undesirable.
Comment 9 Luca Beltrame 2015-07-11 09:35:50 UTC
Latest of everything from git master. 

@Kai: yes, removing the line from LayoutManager.js gets rid of the issue at runtime, but not when saving/restoring layouts. (kquitapp5 plasmashell; plasmashell doesn't preserve them, but it may be a different issue).
Comment 10 Luca Beltrame 2015-07-11 09:40:18 UTC
Some more follow up: while removing that fixes the issue at runtime, the visual guide line when moving plasmoid looks still affected (IOW, it shows the wrong place where the plasmoid will be placed).
Comment 11 Luca Beltrame 2015-07-11 18:32:12 UTC
Scratch the "saving not working correctly". After a few hours of usage, I can say that removing the line Kai mentioned fixes the issue correctly for all cases.
Comment 12 Kai Uwe Broulik 2015-07-12 00:03:28 UTC
Git commit febaa59d1ba0399a28ff3033130464ef1397d379 by Kai Uwe Broulik.
Committed on 12/07/2015 at 00:03.
Pushed by broulik into branch 'master'.

Remove pragma library

It causes the JavaScript file to be shared across all instances of the item on the
same QML engine which breaks with our shared engine approach. This results in the
free space variables to be shared with all containments leading to undesirable results.
FIXED-IN: 5.4.0

M  +0    -2    containments/desktop/package/contents/code/LayoutManager.js
M  +0    -3    containments/panel/contents/code/LayoutManager.js

http://commits.kde.org/plasma-desktop/febaa59d1ba0399a28ff3033130464ef1397d379
Comment 13 Bhushan Shah 2015-07-12 03:38:45 UTC
Git commit b81fae1dd4d5054aba976a54d018a360a6c4b457 by Bhushan Shah.
Committed on 12/07/2015 at 03:34.
Pushed by bshah into branch 'bshah/shell'.

Remove pragma library from pmc containment

M  +0    -3    packages/containment/package/contents/code/LayoutManager.js

http://commits.kde.org/plasma-mediacenter/b81fae1dd4d5054aba976a54d018a360a6c4b457
Comment 14 Kai Uwe Broulik 2015-07-13 17:57:12 UTC
Git commit 4d726c4c48c30199a1508f2137f332e638fd8b1e by Kai Uwe Broulik.
Committed on 13/07/2015 at 17:56.
Pushed by broulik into branch 'master'.

Only have one instance of the LayoutManager

Otherwise the highlighter will get out of sync with the actual applet geometries
and we get strange behavior.

Reviewed-By: notmart

M  +9    -11   containments/desktop/package/contents/ui/AppletAppearance.qml
M  +11   -13   containments/desktop/package/contents/ui/AppletHandle.qml
M  +1    -0    containments/desktop/package/contents/ui/main.qml

http://commits.kde.org/plasma-desktop/4d726c4c48c30199a1508f2137f332e638fd8b1e