Bug 365989 - Default desktop layout is not loaded properly from template
Summary: Default desktop layout is not loaded properly from template
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Desktop Containment (show other bugs)
Version: 5.7.2
Platform: ROSA RPMs Linux
: NOR crash
Target Milestone: 1.0
Assignee: Sebastian Kügler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-22 18:17 UTC by Pulfer
Modified: 2016-07-27 09:25 UTC (History)
5 users (show)

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


Attachments
xsessions-errors with more debug output (20.87 KB, text/plain)
2016-07-25 07:27 UTC, Pulfer
Details
stack (6.68 KB, text/x-log)
2016-07-25 07:57 UTC, Vladimir Potapov
Details
xsession-errors for another crash (200.13 KB, text/plain)
2016-07-25 08:01 UTC, Vladimir Potapov
Details
Patch to fix load order (647 bytes, patch)
2016-07-25 12:00 UTC, Pulfer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pulfer 2016-07-22 18:17:39 UTC
Default desktop layout is not loaded properly from system template. It happens because Plasma Shell cannot create an activity ("Failed to create and switch to the activity" message in .xsession-errors).

This commit looks like an attempt to fix it:

https://quickgit.kde.org/?p=plasma-workspace.git&a=commitdiff&h=f7ef6ee87b8957bebc976b6fc9e0df279cea05f1

But in fact it only makes things worse (if backported to 5.7.2 package) - Plasma Shell locks on load, there's only black screen without desktop and panel.

You can try to download ROSA Desktop ISO (with Plasma 5.7.2 + backported f7ef6ee87b8957bebc976b6fc9e0df279cea05f1) and start it in live mode to reproduce Plasma deadlock: https://abf.rosalinux.ru/platforms/rosa2014.1/products/137/product_build_lists/15706

Reproducible: Always
Comment 1 Pulfer 2016-07-23 02:52:17 UTC
https://phabricator.kde.org/D2268 seems to fix Plasma Shell deadlock on start. But still loading default layout is broken:

------- .xsession-errors -------
...
Setting default Containment plugin: "org.kde.plasma.folder"
Failed to create and switch to the activity
"1"
Plasma Shell startup completed
...
------- .xsession-errors -------


------- layout.js -------
loadTemplate("org.kde.plasma.desktop.defaultPanel")

for (var i = 0; i < screenCount; ++i) {
    var id = createActivity("Rosa Desktop", "org.kde.plasma.folder");
    var desktopsArray = desktopsForActivity(id);
    print(desktopsArray.length);
    for( var j = 0; j < desktopsArray.length; j++) {
        desktopsArray[j].wallpaperPlugin = 'org.kde.image';
        desktopsArray[j].currentConfigGroup = ["General"]
        desktopsArray[j].writeConfig("showToolbox", "false")
        //var clock = desktopsArray[j].addWidget("org.kde.plasma.analogclock");
    }
}
------- layout.js -------
Comment 2 Pulfer 2016-07-23 03:22:18 UTC
(In reply to Pulfer from comment #0)
> But in fact it only makes things worse (if backported to 5.7.2 package) -
> Plasma Shell locks on load, there's only black screen without desktop and
> panel.

Well, it's not a deadlock. It's possible to run commands via Alt+F2. Just no desktop, panel etc.
Comment 3 Marco Martin 2016-07-23 17:29:40 UTC
(In reply to Pulfer from comment #1)
> ------- layout.js -------
> loadTemplate("org.kde.plasma.desktop.defaultPanel")
> 
> for (var i = 0; i < screenCount; ++i) {
>     var id = createActivity("Rosa Desktop", "org.kde.plasma.folder");
>     var desktopsArray = desktopsForActivity(id);
>     print(desktopsArray.length);
>     for( var j = 0; j < desktopsArray.length; j++) {
>         desktopsArray[j].wallpaperPlugin = 'org.kde.image';
>         desktopsArray[j].currentConfigGroup = ["General"]
>         desktopsArray[j].writeConfig("showToolbox", "false")
>         //var clock =
> desktopsArray[j].addWidget("org.kde.plasma.analogclock");
>     }
> }
> ------- layout.js -------
I can reproduce the problem on the live image: digging trough .xsession-errors seems that plasmashell is crashing (sadly couldn't get to a backtrace)
Your layout.js appears to be wrong (it's actually cycling on screens twice, i should see why this makes it actually crash) and yes, it appears to be wrong upstream as well :/

can you try without the outer loop as in:
 ------- layout.js -------
 loadTemplate("org.kde.plasma.desktop.defaultPanel")
 
 var id = createActivity("Rosa Desktop", "org.kde.plasma.folder");
 var desktopsArray = desktopsForActivity(id);
 print(desktopsArray.length);
 for( var j = 0; j < desktopsArray.length; j++) {
     desktopsArray[j].wallpaperPlugin = 'org.kde.image';
     desktopsArray[j].currentConfigGroup = ["General"]
     desktopsArray[j].writeConfig("showToolbox", "false")
     //var clock =
 desktopsArray[j].addWidget("org.kde.plasma.analogclock");
 }

this way seems to fix it for me on the live image
Comment 4 Marco Martin 2016-07-23 17:43:50 UTC
https://phabricator.kde.org/D2275 for the wroong script upstream
Comment 5 Pulfer 2016-07-24 03:00:21 UTC
(In reply to Marco Martin from comment #3)
> can you try without the outer loop as in:
> ...
> this way seems to fix it for me on the live image

It seems to fix the issue indeed. Thanx :-)
Comment 6 Pulfer 2016-07-24 14:52:33 UTC
Looks like in some cases the issue still exists (maybe because D2268).

With plasma-workspace 5.7.2 + fixed (as suggested above) layout.js + backported commits:
1. https://quickgit.kde.org/?p=plasma-workspace.git&a=commitdiff&h=f7ef6ee87b8957bebc976b6fc9e0df279cea05f1
2. https://phabricator.kde.org/D2268

Plasma crashes on start, when it tries to create default desktop from template.

------- .xsession-errors -------
"1"
Plasma Shell startup completed
Plasma Shell startup completed
...
org.kde.plasma: requesting config for "Folder view" without a containment!
Activity added twice "81db3eec-48a9-41d5-a967-bb9cba9fba72"
()
("/home/vuohi/Desktop/Home.desktop")
()
log_kioremote: RemoteDirNotify::FilesChanged
log_kioremote: RemoteDirNotify::toRemoteURL( QUrl("file:///home/vuohi/Desktop/Home.desktop") )
log_kioremote: result => KUrl()
KCrash: Attempting to start /usr/bin/plasmashell from kdeinit
KCrash: Application 'plasmashell' crashing...
KCrash: Attempting to start /usr/lib/libexec/drkonqi from kdeinit
...
------- .xsession-errors -------

I used these ISOs for testing: https://abf.rosalinux.ru/platforms/rosa2014.1/products/137/product_build_lists/15726
Comment 7 Pulfer 2016-07-24 16:06:53 UTC
(In reply to Pulfer from comment #6)
> Looks like in some cases the issue still exists (maybe because D2268).

I tried not to apply D2268 but Plasma still crashes on start and there are still 2 "Plasma Shell startup completed" messages in .xsession-errors and "Activity added twice" message.

Our QA engineer just reported that after first OS install from 15726 ISO he had Plasma crash and broken default desktop layout. But after second install from the same ISO Plasma didn't crash and desktop layout was properly created. In general this issue looks like some kind of a race condition.
Comment 8 Pulfer 2016-07-25 07:27:44 UTC
Created attachment 100282 [details]
xsessions-errors with more debug output

I patched plasma5-worspace to output more debug messages. 

The patch is https://abf.rosalinux.ru/abondrov/plasma5-workspace/blob/rosa2014.1/plasma-workspace-5.7.2-debug.patch

This line looks really surprising: "!!! checkActivities (destroyed activity): "c51bdf4c-5df8-4b04-9cf8-88a446ad2445""

----------- grep .xsession-errors -----------
!!! setShell (init):  "org.kde.plasma.desktop"
!!! setShell (theme name):  "rosa-fresh"
!!! unload (init, m_shell) "org.kde.plasma.desktop"
!!! load (init, m_shell):  "org.kde.plasma.desktop"
!!! loadDefaultLayout (script) "/usr/share/plasma/shells/org.kde.plasma.desktop/contents/layout.js"
!!! ShellCorona screenForContainment:  Plasma::Containment(0x93a3748)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x93a3748)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x93a3748)  Last screen is  -1
!!! insertActivity (id) "c51bdf4c-5df8-4b04-9cf8-88a446ad2445"
!!! insertActivity (plugin) "org.kde.plasma.folder"
!!! createContainmentForActivity (activity) "c51bdf4c-5df8-4b04-9cf8-88a446ad2445"
!!! createContainmentForActivity (screenNum) 0
!!! createContainmentForActivity (plugin) "org.kde.plasma.folder"
!!! ShellCorona screenForContainment:  Plasma::Containment(0x93a3748)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x93a3748)  Last screen is  -1
!!! insertContainment (containment):  Plasma::Containment(0x9348618)
!!! insertContainment (activity):  "c51bdf4c-5df8-4b04-9cf8-88a446ad2445"
!!! insertContainment (screenNum):  0
!!! ShellCorona screenForContainment:  Plasma::Containment(0x93a3748)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x93a3748)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x93a3748)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x93a3748)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x9348618)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x9348618)  Last screen is  -1
!!! checkActivities (status) 2
!!! checkActivities (id) "90960718-8ab6-460d-920d-3074a925c813"
!!! checkActivities (destroyed activity): "c51bdf4c-5df8-4b04-9cf8-88a446ad2445"
!!! load (containments are NOT empty, m_shell) "org.kde.plasma.desktop"
!!! load (containmentType == panel)
!!! createContainmentForActivity (activity) "c51bdf4c-5df8-4b04-9cf8-88a446ad2445"
!!! createContainmentForActivity (screenNum) 0
----------- grep .xsession-errors -----------
Comment 9 Vladimir Potapov 2016-07-25 07:57:39 UTC
Created attachment 100284 [details]
stack

another crash
Comment 10 Vladimir Potapov 2016-07-25 08:01:27 UTC
Created attachment 100285 [details]
xsession-errors for another crash
Comment 11 Marco Martin 2016-07-25 08:10:18 UTC
pasting inline

Thread 1 (Thread 0xb1e62980 (LWP 4474)):
[KCrash Handler]
#6  0xb51c4eaa in QObject::property(char const*) const () from /usr/lib/libQt5Core.so.5
#7  0x08069fee in DesktopView::event (this=0xa09f548, e=0xbf84ccb0) at /usr/src/debug/plasma-workspace-5.7.2/shell/desktopview.cpp:197
#8  0xb5b5a94a in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#9  0xb5b5f154 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#10 0xb519bcad in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#11 0xb54c8691 in QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent*) () from /usr/lib/libQt5Gui.so.5
#12 0xb54c8ba1 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () from /usr/lib/libQt5Gui.so.5
#13 0xb54a7ecc in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Gui.so.5
#14 0xb1a6ba5e in ?? () from /usr/lib/libQt5XcbQpa.so.5
#15 0xb4454fef in g_main_context_dispatch () from /lib/libglib-2.0.so.0
#16 0xb4455299 in ?? () from /lib/libglib-2.0.so.0
#17 0xb4455366 in g_main_context_iteration () from /lib/libglib-2.0.so.0
#18 0xb51e7ec4 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#19 0xb1a6bc31 in ?? () from /usr/lib/libQt5XcbQpa.so.5
#20 0xb519a356 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#21 0xb519a762 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#22 0xb51a259a in QCoreApplication::exec() () from /usr/lib/libQt5Core.so.5
#23 0xb54be251 in QGuiApplication::exec() () from /usr/lib/libQt5Gui.so.5
#24 0xb5b577f4 in QApplication::exec() () from /usr/lib/libQt5Widgets.so.5
#25 0x0805ce90 in main (argc=2, argv=0xbf84d144) at /usr/src/debug/plasma-workspace-5.7.2/shell/main.cpp:166
Comment 12 Marco Martin 2016-07-25 08:18:30 UTC
Git commit 214443fdff330629104509de9e1738aadcfe36b6 by Marco Martin.
Committed on 25/07/2016 at 08:16.
Pushed by mart into branch 'Plasma/5.7'.

apparently containment() can be null

null in some rare occasions during startup

M  +1    -1    shell/desktopview.cpp

http://commits.kde.org/plasma-workspace/214443fdff330629104509de9e1738aadcfe36b6
Comment 13 Ivan Čukić 2016-07-25 08:36:05 UTC
@Marco

I'm afraid this crash is a consequence of something else that will still be the problem even if the crash is avoided with your patch.

Can we say this issue is big enough and important enough to warrant a logic rewrite under the 5.7 branch? (we would need a really thorough testing before actually merging it)
Comment 14 Pulfer 2016-07-25 09:48:38 UTC
(In reply to Marco Martin from comment #12)
> Git commit 214443fdff330629104509de9e1738aadcfe36b6 by Marco Martin.

Plasma still crashes with this patch applied:

----------- grep .xsession-errors -----------
Plasma Shell startup completed
org.kde.plasma: requesting config for "Просмотр папки" [translation: "Folder View"] without a containment!
KCrash: Attempting to start /usr/bin/plasmashell from kdeinit
KCrash: Application 'plasmashell' crashing...
KCrash: Attempting to start /usr/lib/libexec/drkonqi from kdeinit
----------- grep .xsession-errors -----------

I'll try to get new backtrace log.
Comment 15 Pulfer 2016-07-25 12:00:30 UTC
Created attachment 100288 [details]
Patch to fix load order

This patch seems to fix the issue. And .xsession-errors with extra debug now looks sane:

----------- grep .xsession-errors -----------
!!! setShell (init):  "org.kde.plasma.desktop"
!!! setShell (theme name):  "rosa-fresh"
!!! unload (init, m_shell) "org.kde.plasma.desktop"
!!! load (init, m_shell):  "org.kde.plasma.desktop"
!!! checkActivities (status) 2
!!! checkActivities (id) "c01f2662-8731-4a60-8e2b-82cd4efba366"
!!! loadDefaultLayout (script) "/usr/share/plasma/shells/org.kde.plasma.desktop/contents/layout.js"
!!! ShellCorona screenForContainment:  Plasma::Containment(0x9dccb90)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x9dccb90)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x9dccb90)  Last screen is  -1
!!! insertActivity (id) "94bbf033-08f1-49ca-8f58-d1963a7d6415"
!!! insertActivity (plugin) "org.kde.plasma.folder"
!!! createContainmentForActivity (activity) "94bbf033-08f1-49ca-8f58-d1963a7d6415"
!!! createContainmentForActivity (screenNum) 0
!!! createContainmentForActivity (plugin) "org.kde.plasma.folder"
!!! ShellCorona screenForContainment:  Plasma::Containment(0x9dccb90)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x9dccb90)  Last screen is  -1
!!! insertContainment (containment):  Plasma::Containment(0x9d7bef0)
!!! insertContainment (activity):  "94bbf033-08f1-49ca-8f58-d1963a7d6415"
!!! insertContainment (screenNum):  0
!!! ShellCorona screenForContainment:  Plasma::Containment(0x9dccb90)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x9dccb90)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x9dccb90)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x9dccb90)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x9d7bef0)  Last screen is  -1
!!! ShellCorona screenForContainment:  Plasma::Containment(0x9d7bef0)  Last screen is  -1
!!! load (containments are NOT empty, m_shell) "org.kde.plasma.desktop"
!!! load (containmentType == panel)
!!! load (containmentType == desktop)
!!! createContainmentForActivity (activity) "94bbf033-08f1-49ca-8f58-d1963a7d6415"
!!! createContainmentForActivity (screenNum) 0
----------- grep .xsession-errors -----------
Comment 16 David Edmundson 2016-07-25 14:30:10 UTC
Given this patch works round a crash, the reason for the crash presumably is that loadLayout() creates a containment on an activity then checkActivities() cleans up any containments are for activities that no longer exist...but after they've been assinged to views.

I don't think the patch makes sense though; all you're doing is removing the cleanup, but that's not getting to the root cause of the messup. 
It's going to break the whole "you can have a different default containment per activity"...though that's something that was never used in practice anyway.
Comment 17 Pulfer 2016-07-25 15:17:35 UTC
(In reply to David Edmundson from comment #16)
> Given this patch works round a crash, the reason for the crash presumably is
> that loadLayout() creates a containment on an activity then
> checkActivities() cleans up any containments are for activities that no
> longer exist...but after they've been assinged to views.

I guess xsession-errors log with extra debug output (lines starting with "!!!") from https://bugs.kde.org/show_bug.cgi?id=365989#c8 is very helpful to track Plasma loading order.
Comment 18 Marco Martin 2016-07-25 15:26:01 UTC
can you try with https://phabricator.kde.org/D2283 (based upon yours)
if reliably fixes the crash for you?
Comment 19 Pulfer 2016-07-25 15:57:01 UTC
(In reply to Marco Martin from comment #18)
> can you try with https://phabricator.kde.org/D2283 (based upon yours)
> if reliably fixes the crash for you?

I guess it should because there's no "!!! load (containments are empty, m_shell)" line in .xsession-errors (neither for crashed Plasma nor for properly started).

So we don't enter "if (containments().isEmpty()) {}" and adding there "currentActivityChanged(m_activityController->currentActivity());" shouldn't change the behaviour of my patch that fixed the crash.

Likely there should be another test case for this new line. Something that actually runs the code.
Comment 20 Ivan Čukić 2016-07-25 19:21:53 UTC
> I used these ISOs for testing: https://abf.rosalinux.ru/platforms/rosa2014.1/products/137/product_build_lists/15726


Is the live session supposed to crash or do I need to install it? (the live session seems to work for me)
Comment 21 Pulfer 2016-07-26 01:41:06 UTC
(In reply to Ivan Čukić from comment #20)
> > I used these ISOs for testing: https://abf.rosalinux.ru/platforms/rosa2014.1/products/137/product_build_lists/15726
> 
> Is the live session supposed to crash or do I need to install it? (the live
> session seems to work for me)

Yes, live session supposed to crash. But it's not 100% reproducible. I guess it may depend on boot speed. Marco could reproduce it (see comment 3).

I suggest to use this ISO for testing: https://abf.rosalinux.ru/platforms/rosa2014.1/products/137/product_build_lists/15736

This ISO has https://quickgit.kde.org/?p=plasma-workspace.git&a=commit&h=214443fdff330629104509de9e1738aadcfe36b6 applied and extra debug output ( https://abf.rosalinux.ru/abondrov/plasma5-workspace/blob/rosa2014.1/plasma-workspace-5.7.2-debug.patch ) turned on.
Comment 22 Pulfer 2016-07-27 09:25:12 UTC
Fixed in upcoming 5.7.3. See more info here: https://phabricator.kde.org/D2283