Bug 495684

Summary: plasmashell: language layout tray icon is sometimes missing on session start
Product: [Plasma] plasmashell Reporter: i.Dark_Templar <idarktemplar>
Component: Keyboard Layout widgetAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: butirsky, duha.bugs, nate
Priority: NOR    
Version: 6.2.0   
Target Milestone: 1.0   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In: 6.3.0
Sentry Crash Report:
Attachments: kde layout tray bug.png
layout-not-loaded.png

Description i.Dark_Templar 2024-11-01 11:25:04 UTC
Created attachment 175442 [details]
kde layout tray bug.png

SUMMARY
Sometimes when I start plasma 6.2.0 X11 session, language layout tray icon is missing.
Restarting plasmashell via "Alt+F2, plasmashell --replace" fixes issue.
It doesn't happen every time.

STEPS TO REPRODUCE
1. Start plasma 6.2.0 X11 session

OBSERVED RESULT
Sometimes language layout tray icon is missing.

EXPECTED RESULT
Language layout tray icon should always be present.

SOFTWARE/OS VERSIONS
Operating System: Gentoo Linux 
KDE Plasma Version: 6.2.2
KDE Frameworks Version: 6.7.0
Qt Version: 6.7.3
Graphics Platform: X11

ADDITIONAL INFORMATION
I have line like this in my ~/.bash_profile:
[ -d ~/.cache ] && tmpwatch 30d --exclude-pattern icon-cache\\.kcache ~/.cache

But issue happens like every 3 days, not 30 days. It started happening with plasma 6.2.0.
Pressing language layout switch button still switches the language, just indication of language currently used is missing.
Not sure if it's relevant, but I'm using "restore last session" option for session management.
Comment 1 Nate Graham 2024-11-01 17:00:32 UTC
Does it ever happen on Wayland? Or only on X11?
Comment 2 i.Dark_Templar 2024-11-01 23:09:41 UTC
I did 10 cycles of logout and login back into X11, and then into wayland.
With X11 it happened literally every second time: tray icon is present, missing, present, missing, present, missing, etc, i.e. 5 out of 10 times it reproduced for me today.
With wayland it never reproduced in 10 tries. Considering how often it reproduced for me on X11, I've decided not to continue trying at the moment.

I didn't hit this issue with plasma 6.1.2.
Comment 3 i.Dark_Templar 2024-11-02 10:05:52 UTC
If I don't do "plasmashell --restart", next time tray icon usually is also missing.
Comment 4 i.Dark_Templar 2024-11-12 19:04:15 UTC
Any additional info needed?
Comment 5 i.Dark_Templar 2024-12-15 18:53:35 UTC
Created attachment 176659 [details]
layout-not-loaded.png

I did a bit of debugging and noticed some additional hint at what's going on wrong.

When no language name is present in tray as icon, when I do right mouse button click on keyboard layout tray item, I get tray menu with 1 item: "Configure keyboard layout widget...".

When everything works fine, I get tray menu with 4 items: 1 as above and 3 with languages.

I assume that for some reason keyboard layout tray component loads sometimes faster than plasma loads keyboard layouts, and since there are no keyboard layouts, there is nothing to display in tray.
Comment 6 Bug Janitor Service 2025-01-27 19:20:14 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/5127
Comment 7 Bug Janitor Service 2025-02-02 01:28:29 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/5148
Comment 8 Fushan Wen 2025-02-02 02:14:58 UTC
Git commit ae8f289bd9a9e50acaa3b814b99cd84b94a6ac1e by Fushan Wen.
Committed on 02/02/2025 at 02:14.
Pushed by fusionfuture into branch 'Plasma/6.3'.

keyboardlayout: wait for org.kde.keyboard service from kded asynchronously

When X11 KDE session is starting, kded6 is started before kwin_x11 and plasmashell.
kded6 is considered started when org.kde.kded6 dbus service is up.
At that moment org.kde.keyboard dbus service is not up yet,
but kwin_x11 and plasmashell are started.
plasmashell expects org.kde.keyboard dbus service to be available when it runs,
but due to scheduling kded6 may not start org.kde.keyboard service
before plasmashell attempts to use it.

To make keyboard layout applet work even in that case,
wait asynchronously for org.kde.keyboard service
if it's not running at the moment.
FIXED-IN: 6.3.0

(cherry picked from commit 0ec684194c637e564253e17b92b83aeb57f3ec16)

Co-authored-by: Dark Templar <darktemplar@dark-templar-archives.net>

M  +19   -4    components/keyboardlayout/keyboardlayout.cpp
M  +3    -0    components/keyboardlayout/keyboardlayout.h

https://invent.kde.org/plasma/plasma-workspace/-/commit/ae8f289bd9a9e50acaa3b814b99cd84b94a6ac1e