Repository navigation
Conversation
…er change The host only listens for the `serviceRegistered` and `serviceUnregistered` signals. When a client such as kded6 restarts, the new instance asks for the `org.kde.StatusNotifierWatcher` service while the old instance still owns it, so the request is queued in the bus. The old instance then exits and the bus hands the service over to the new one directly. From the bus's point of view the service is never unowned, so Qt only sends `serviceOwnerChanged`. Normally the service would be unregistered when the old instance exits and registered again once an owner asks for it, but here the request was already queued, so neither of those two signals is sent. The problem is that the host does not listen for `serviceOwnerChanged` at all. To cover this edge case, we now listen for that event as well and trigger our own unregistration and registration handling inside the host.
Once the watcher has registered the org.kde.StatusNotifierWatcher service, it goes on assuming that it is still the owner, and it does not listen for the event that tells it that the service has been taken from it. We now make it listen for that event as well. When the service is taken from it, it steps aside and clears its own state. Once it finds out that nobody is the watcher any more, it tries to register again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
The host only listens for the
serviceRegisteredandserviceUnregisteredsignals. When a client such as kded6 restarts, the new instance asks for theorg.kde.StatusNotifierWatcherservice while the old instance still owns it, so the request is queued in the bus. The old instance then exits and the bus hands the service over to the new one directly. From the bus's point of view the service is never unowned, so Qt only sendsserviceOwnerChanged. Normally the service would be unregistered when the old instance exits and registered again once an owner asks for it, but here the request was already queued, so neither of those two signals is sent.The problem is that the host does not listen for
serviceOwnerChangedat all. To cover this edge case, we now listen for that event as well and trigger our own unregistration and registration handling inside the host.quickshell's own watcher has the same problem from the other side. Once it has registered the service it goes on assuming that it is still the owner, and it does not listen for the event that tells it that the service has been taken from it. It now listens for that event as well, and when the service is taken from it, it steps aside and clears its own state. Once it finds out that nobody is the watcher any more, it tries to register again.
Details and descisions
QDBusServiceWatcherturns the ownership change of a watched service into three different signals, and it only sendsserviceRegisteredandserviceUnregisteredwhen one side of the change is empty:The service is never unowned in the case described above, so neither of the two signals the host listens for is sent. The bus reports the ownership change in a single event instead:
The host therefore never noticed that the watcher changed, and the items of the previous watcher stayed in the model. They point at bus names that no longer exist, and the items the new watcher knows about were added next to them, which shows up as two icons for one application, one of them dead.
The host now also watches for
serviceOwnerChangedand rebuilds its item list when the watcher changes owner, which is what the two existing handlers already do for the other two cases:The watcher side has the same gap. Its
QDBusServiceWatcherusedWatchForUnregistration, whose match rule isarg0='<service>', arg2='', so it only saw events where the new owner is empty.WatchForOwnerChangewidens the rule toarg0='<service>', which delivers ownership changes as well, and the watcher now drops its item and host lists and clearsregisteredwhen the service is taken from it. It takes the service back withtryRegister()once it is free again, which is what it already did before.Open concerns
No ?
Testing
The reproduction needs a watcher that is replaced while a replacement is already asking for the service, so the service is never unowned. A stand-in that queues for it is enough:
With the shell running against the current watcher, the change shows up in the log of the shell. Before the change, nothing is logged and the old items stay in the model:
The tray then shows two identical icons. After the change, the change is noticed and the items are dropped and read again:
Both were run against a Hyprland session where kded6 provides the watcher and the shell is restarted regularly, which is what produced the duplicated icons in the first place.
Participation
I am on Hyprland, using end-4's Hyprland dotfiles, which ship a quickshell configuration for the bar and the panels. I noticed that every time quickshell dies and is restarted, my tray ends up showing every icon twice. I had some time today, so I dug into it.
What I found first is that the end-4 dots kill kded6 on every quickshell start. Their conflict killer runs
killall kded6while the shell is starting, and kded6 is restarted afterwards, so the new one takes the StatusNotifierWatcher service over from the old one without it ever being unowned.I could open a pull request against the end-4 dots to stop kded6 and start it again instead, which would leave the service unowned for a moment. But the missing handling of that state is the more fundamental problem here, so I am opening this pull request instead.
I will be following the PR. The maintainer is welcome to suggest changes or to push commits to the branch directly. If there are any questions or things left to do, I am happy to take care of them.