Bug 417219 - Daemonized Dolphin inappropriately triggers session restoration
Summary: Daemonized Dolphin inappropriately triggers session restoration
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 19.12.2
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords: triaged
: 427905 428207 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-02-06 09:13 UTC by Attila
Modified: 2020-10-30 04:48 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In: 20.12


Attachments
Before logout (28.82 KB, image/png)
2020-07-11 15:07 UTC, Attila
Details
After login (35.72 KB, image/png)
2020-07-11 15:08 UTC, Attila
Details
After login dolphin launched (63.70 KB, image/png)
2020-07-11 15:09 UTC, Attila
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Attila 2020-02-06 09:13:00 UTC
SUMMARY
After quit the process "dolphin" is keep running in background. When the option "restore last session" is set dolphin appears after login automatically.

STEPS TO REPRODUCE
1. Login to KDE
2. Make sure that "restore last session" is set
3. Launch Dolphin
4. Close Doplhin
5. Logout
6. Login to KDE

OBSERVED RESULT
The process "dolphin" is always running in background after quit.

EXPECTED RESULT
Quit Dolphin must end the process.

SOFTWARE/OS VERSIONS
Operating System: Fedora 31
KDE Plasma Version: 5.17.5
KDE Frameworks Version: 5.66.0
Qt Version: 5.13.2
Kernel Version: 5.4.15-200.fc31.x86_64
OS Type: 64-bit

ADDITIONAL INFORMATION
My workaround is to kill the process "dolphin" before I logout. That prevents Dolphin to appear automatically after login.
Comment 1 Nate Graham 2020-02-06 20:05:37 UTC
Yes, the background daemon is to support the "open new folders in tabs rather than new windows" feature. If you don't want a daemonized Dolphin running, you can turn off this feature.

That said, it's a bug if the daemonized Dolphin triggers session restore. It shouldn't do that. Will investigate.
Comment 2 Attila 2020-02-07 08:34:26 UTC
In my case "open new folders in tabs" is not set. However it seems that Dolphin is running daemonized.
Comment 3 Attila 2020-02-10 12:02:49 UTC
Just tested on neon-user-20200207-1737.iso.
I can't see any "dolphin-process" after quitting Dolphin. This means to me, Dolphin never runs deamonized in both cases when "open new folders in tabs" is set or not.
Comment 4 Nate Graham 2020-02-16 23:30:48 UTC
FWIW I cannot reproduce the issue.
Comment 5 Attila 2020-02-17 14:22:14 UTC
(In reply to Nate Graham from comment #4)
> FWIW I cannot reproduce the issue.

Hi,

what do you mean by you cannot reproduce the issue?
How did you test it?
Did you try NEON? Like I said everything is OK on NEON. No bug.
Or did you try Fedora 31? If not, would you mind to install somewhere Fedora 31 (KDE spin) to test it?

I can always reproduce this bug on all of my installations. It doesn't matter if it's a laptop or desktop PC.
Comment 6 Elvis Angelaccio 2020-02-22 23:47:22 UTC
(In reply to Nate Graham from comment #1)
> Yes, the background daemon is to support the "open new folders in tabs
> rather than new windows" feature. If you don't want a daemonized Dolphin
> running, you can turn off this feature.

Not exactly, the deamon is to support the freedesktop's File Manager DBus Interface and cannot be turned off.

There is nothing to fix here, really.
Comment 7 Attila 2020-02-24 08:45:59 UTC
(In reply to Elvis Angelaccio from comment #6)
> (In reply to Nate Graham from comment #1)
> > Yes, the background daemon is to support the "open new folders in tabs
> > rather than new windows" feature. If you don't want a daemonized Dolphin
> > running, you can turn off this feature.
> 
> Not exactly, the deamon is to support the freedesktop's File Manager DBus
> Interface and cannot be turned off.
> 
> There is nothing to fix here, really.

Hi, you are right when you say there is nothing to fix because you have answered to comment 1 but the summary of my bug report was something like: "doplhin is running in background after quitting". This has been changed by someone here to "Daemonized Dolphin inappropriately triggers session restoration". Please read my description. So the bug is definitely still there and it is always reproducible.
I am a user and don't know much about KDE's mechanism, but Nate gave me the idea about "triggering session restoration". When I quit Doplhin the process is still running in the background and therfore it can not "untrigger" session restoration. That is my thought.

Please allow my to say that I am a bit upset, because the bug is always reproducible and someone set the status to "resolved intentional". I don't report bugs just for kicks.
Please REOPEN this report and CHANGE the status and the summary.
Comment 8 Nate Graham 2020-02-24 16:34:57 UTC
I would say, "yes, this is definitely not intentional behavior from a user perspective; re-opening" but I cannot reproduce the issue on my machine (openSUSE Tumbleweed). I use session restore and Dolphin doesn't come up on boot.
Comment 9 Attila 2020-02-25 13:21:56 UTC
It sounds like this bug is on Fedora and perhaps on some other distros, but not on openSuse. That's why I have specified "Fedora RPMs" as platform.
Comment 10 Attila 2020-05-24 15:49:02 UTC
Hi,

I have just tested on Fedora 32, Dolphin 19.12.2 and I can still reproduce this bug always on several computers.
Please reopen this bug report.

Do you need some additional information?
Is there anything I can do as a user to fix this bug?
Comment 11 Julian Steinmann 2020-05-24 16:07:23 UTC
From what I can gather this appears to be a legitimate issue, but people have trouble reproducing it. I'm setting the status to REPORTED and hope that eventually someone will be able to reproduce reliably.
Comment 12 Attila 2020-07-11 15:07:34 UTC
Created attachment 130039 [details]
Before logout
Comment 13 Attila 2020-07-11 15:08:47 UTC
Created attachment 130040 [details]
After login
Comment 14 Attila 2020-07-11 15:09:24 UTC
Created attachment 130041 [details]
After login dolphin launched
Comment 15 Attila 2020-07-11 15:10:26 UTC
This could help perhaps to investigate the issue.
It is always reproducible. Please see the attached scrennshots.

1. Before I logout, I make sure that the process "dolphin" is not running.
2. Logout.
3. Login again.
4. There is already running one "dolphin" process.
5. Launch Dolphin.
6. There are two "dolphin" processes running.
7. Interesting is that only one "dolphin" process got an icon.
Comment 16 Fabsk 2020-09-25 15:48:03 UTC
I think I'm facing this bug with Kubuntu 20.04.1 (I had it in previous releases, but cannot remember how many).
Each time I restart my machine, I get an additional new window of Dolphin. So there is the usual one with some tabs open, and one or several with my home folder opened. It's a bit annoying because if I don't close the new ones, I end up having many opened.

In my ~/.config/ksmserverrc, I can see I have:
program12=/usr/bin/dolphin
program13=/usr/bin/dolphin

restartCommand12=/usr/bin/dolphin,-session,10cde26262000160098025700000070490020_1601048614_510748
restartCommand13=/usr/bin/dolphin,-session,10cde26262000160104804000000021040011_1601048614_510564

In ~/.config/session, I can see that I have one file for the first (with data about the tabs), but not for the other one.

I don't know more about ksmserver and how the programs manage the session saving and restoration, so I cannot provide right away more insight.
If you think it's not the same bug, I can open another one.
Comment 17 Fabsk 2020-09-25 16:47:19 UTC
Regarding my previous comment, tt turns out that for an unknown reason I had a file "~/.config/autostart/dolphin.desktop" which started "dolphin --deamon". After removing it, the additional Dolphin window/process does not show up any more in a new session. "dolphin --deamon" is not started automatically any more, but I don't know what will be the impact for me.
Comment 18 Attila 2020-09-26 14:30:31 UTC
(In reply to Fabsk from comment #17)
> Regarding my previous comment, tt turns out that for an unknown reason I had
> a file "~/.config/autostart/dolphin.desktop" which started "dolphin
> --deamon". After removing it, the additional Dolphin window/process does not
> show up any more in a new session. "dolphin --deamon" is not started
> automatically any more, but I don't know what will be the impact for me.

In my case the directory "~/.config/autostart/" is empty. Dolphin continues to run in the background after it has been closed. I can watch it when I press Crtl+Esc.
Comment 19 Fabsk 2020-09-26 19:48:51 UTC
@attila, could you run in a command line (Konsole for example) the following command after your login (as described in your summary):

ps -efj |grep dolphin

to see with which arguments the mysterious instance was launched (is it launched with "--deamon" or other parameters?). Also the 3rd column will tell you the process ID of the parent (excepted if it is "1").

In term of end-user experience, why is it a problem to have this additional problem? In my case I had an unwanted Dolphin window opened, but in your case I don't see (excepted some memory wasted maybe).
Comment 20 Attila 2020-09-27 09:07:49 UTC
Here you go. The output of the command "ps -efj |grep dolphin"

myusername  1446   1   1445   1445  1 10:49 ?   00:00:00 /usr/bin/dolphin --daemon

The process ID is "1" and it is launched with "--daemon".
Is this exactly what you expected? The process ID "1" is the init process which is responsible for starting and shutting down the system and so on.

Do you have any idea what I can try? Do you need more information?
Comment 21 Attila 2020-09-27 09:25:09 UTC
One more additional information. I have changed the setting from "restore last session" to "start with an empty session".

The output of the command "ps -efj |grep dolphin" is the same. Process ID "1" and "--daemon".

The only difference is that "Dolphin" doesn't come up.
Comment 22 Fabsk 2020-09-27 13:46:09 UTC
I'm afraid I don't know more that you about the cause of the issue. There must be a configuration specific to Fedora that launches "dolphin --deamon". I'm too lazy to investigate any further. Again, does it cause any trouble to the end user (excepted having an additional unwanted dolphin process)?

PPID == 1 can mean that the parent process has finished.
Comment 23 Attila 2020-09-27 20:59:26 UTC
I think I have got it, but first let me just mention something.

In your case Dolphin was autostarted because of "~/.config/autostart/dolphin.desktop". You had that file for an unknown reason and the behaviour was intended and OK. In my case the behaviour was unintended and really annoying plus a bad user experience.

It has turned out that there is a file in "/etc/xdg/autostart/org.kde.dolphin.desktop" which is provided by the RPM "dolphin". This file contains a line "Exec=dolphin --daemon". I have deleted the file and Dolphin doesn't come up. Tt wasn't a big deal to me as a user  to investigate a little further.

Somehow I have to inform the Fedora packagers to remove the file "org.kde.dolphin.desktop", but I don't know how. Any idea?
Comment 24 Rex Dieter 2020-09-29 21:55:56 UTC
Fedora does autostart 'dolphin --daemon' for plasma sessions, I can confirm this.  I implemented it on purpose.

It's a workaround to not rely on dbus activation, since there can be multiple providers.  I believe that's been discussed at length in another bug
Comment 26 Nate Graham 2020-09-30 17:01:17 UTC
Dupe of Bug 418322 I guess. Hopefully it will eventually fixed for Fedora users.

*** This bug has been marked as a duplicate of bug 418322 ***
Comment 27 Attila 2020-10-01 08:48:38 UTC
(In reply to Rex Dieter from comment #24)
> Fedora does autostart 'dolphin --daemon' for plasma sessions, I can confirm
> this.  I implemented it on purpose.
> 
> It's a workaround to not rely on dbus activation, since there can be
> multiple providers.  I believe that's been discussed at length in another bug

There is one more workaround. I have added a new line to the file "/etc/xdg/autostart/org.kde.dolphin.desktop" with the following:

Hidden=true

It has the effect that dolphin won't come up unintentionally after login.

I don't notice any problem after the file "org.kde.dolphin.desktop" has been deleted or I add a new line to the file "Hidden=true".
It works for me in both cases.

Would this new line solve the issue?
Comment 28 Rex Dieter 2020-10-02 14:05:31 UTC
I'll echo here what I also said in the other bug.

I'd argue this is still a bug worth solving on the kde side.  dolphin --daemon processes should *not* be restored via session management.
Comment 29 Rex Dieter 2020-10-02 14:10:02 UTC
That said, if autostarting 'dolphin --daemon' is going to be explicitly not supported by kde as a solution to the issue I highlighted,
Red Hat bugzilla 
Bug 1394927 - Dolphin takes over the desktop folder in GNOME in F25 

https://bugzilla.redhat.com/show_bug.cgi?id=1394927

Then, I'll revert it.  

But then I expect that issue should be addressed by kde some other (better?) way.

Thoughts?
Comment 30 Nate Graham 2020-10-02 16:03:06 UTC
(In reply to Rex Dieter from comment #28)
> I'll echo here what I also said in the other bug.
> 
> I'd argue this is still a bug worth solving on the kde side.  dolphin
> --daemon processes should *not* be restored via session management.
Seems fixable. I'm still not clear why you need this workaround on Fedora in the first place though. If dbus activation isn't reliable for Dolphin, isn't, like, the rest of the system broken too? We use dbus activation for a lot of things, and even more in Plasma 5.20 and beyond.

Basically I want to understand the problem so we can see if the best solution is you removing the workaround, or us explicitly supporting it.
Comment 31 Rex Dieter 2020-10-02 19:05:42 UTC
The full saga is in the linked bug,
Bug 1394927 - Dolphin takes over the desktop folder in GNOME in F25 
https://bugzilla.redhat.com/show_bug.cgi?id=1394927

Cliff's notes:
As the title suggests, by default dolphin ships a dbus activation file at
/usr/share/dbus-1/services/org.kde.dolphin.FileManager1.service

problem is that this file is offered unconditionally to all desktops, not just plasma.  So, it can sometimes intercept org.freedesktop.FileManager1 dbus calls in gnome, for example.

Workaround is instead of relying on the dbus activation, autostart 'dolphin --daemon' in plasma sessions only, that will listen on that dbus interface.  In practice this works to solve that problem well... modulo this side-effect issue with session management.
Comment 32 Elvis Angelaccio 2020-10-03 13:34:43 UTC
@Rex: this should probably be discussed on plasma-devel. From the dolphin side I don't think we would have problems with plasma autostarting `dolphin --daemon`.
Comment 33 Nate Graham 2020-10-21 03:48:14 UTC
*** Bug 427905 has been marked as a duplicate of this bug. ***
Comment 34 Nate Graham 2020-10-21 03:49:58 UTC
I don't know of that's necessarily the best solution. I don't want a daemonized Dolphin instance always running in the background, consuming some resources, when dbus activtion works just fine for me.

We could make the daemonized Dolphin not trigger session restoration I guess. That seems sensible enough.
Comment 35 Attila 2020-10-21 14:52:06 UTC
(In reply to Nate Graham from comment #34)
> I don't know of that's necessarily the best solution. I don't want a
> daemonized Dolphin instance always running in the background, consuming some
> resources, when dbus activtion works just fine for me.
> 

I agree. Why wasting resources with a daemonized Dolphin instance always running in the background?
It's been now three weeks since I have removed the file "/etc/xdg/autostart/org.kde.dolphin.desktop" and everything seems to work so far.
Comment 36 Rex Dieter 2020-10-21 17:57:23 UTC
I'll re-iterate the background I outlined in comment #24 and comment #25,

See dolphin's org.kde.dolphin.FileManager1.service file installed for dbus activation, contains:
Name=org.freedesktop.FileManager1

It is possible for there to be multiple providers for org.freedesktop.FileManager1 (e.g. dolphin and nautlus).  If you'd reviewed the old bugs I referenced, what happened was that dolphin was getting dbus-activated under gnome, for example, instead of nautilus.  DBus activation has no way to prefer one provider over another.  There's a very old bug open with dbus upstream about that, I've doubts it'll ever get addressed.

So, in fedora we did 2 things:
1.  omitted the dbus service file from packaging, to ensure it never gets dbus-activated (esp on non-plasma desktops)
2.  set dolphin to autostart (in daemon mode), which allows dolphin to listen on those dbus interfaces at runtime

Yes, it kinda sucks that another executable is running under plasma (dolphin --daemon) that may never get used, but the alternative is arguably worse... unexpectedly seeing nautilus running under plasma or dolphin running under gnome responding to org.freedesktop.FileManager1 dbus calls.
Comment 37 Nate Graham 2020-10-25 01:26:35 UTC
*** Bug 428207 has been marked as a duplicate of this bug. ***
Comment 38 Bug Janitor Service 2020-10-29 21:01:59 UTC
A possibly relevant merge request was started @ https://invent.kde.org/system/dolphin/-/merge_requests/88
Comment 39 Nate Graham 2020-10-30 04:48:56 UTC
Git commit bf11c835ebd934d9916327262f23edb25aeb8ab8 by Nate Graham.
Committed on 29/10/2020 at 21:00.
Pushed by ngraham into branch 'master'.

Disable session management for daemon

We don't need to autostart the daemon if it was running at logout.
FIXED-IN: 20.12

M  +9    -0    src/main.cpp

https://invent.kde.org/system/dolphin/commit/bf11c835ebd934d9916327262f23edb25aeb8ab8