Created attachment 156194 [details] reproducer.js SUMMARY When using Junction (non-flatpak) to start the browser, the whole desktop freezes for less than a second before the browser shows up. This does not happen when it's running inside Flatpak. I've nailed down the problem and attached a simple reproducer script. STEPS TO REPRODUCE 1. Execute the script with GJS: gjs test.js OBSERVED RESULT Upon executing the script, the whole screen freezes for about a second. This can be verified with some animated/moving things, e.g. glxgears or simply moving the mouse. In the journal, kwin_wayland prints some warnings from kf.services: kwin_wayland[1398775]: kf.service.services: The desktop entry file "/usr/share/applications/qemu.desktop" has Type= "Application" but no Exec line kwin_wayland[1398775]: kf.service.sycoca: Invalid Service : "/usr/share/applications/qemu.desktop" kwin_wayland[1398775]: kf.service.sycoca: The menu spec file ( "" ) contains a Layout or DefaultLayout tag without the mandatory Merge tag inside. Please fix it. EXPECTED RESULT The screen should not freeze. SOFTWARE/OS VERSIONS Operating System: Arch Linux KDE Plasma Version: 5.26.90 KDE Frameworks Version: 5.103.0 Qt Version: 5.15.8 Kernel Version: 6.1.10-arch1-1 (64-bit) Graphics Platform: Wayland
The problem is this: app.set_as_last_used_for_type(mimeType) touches .config/mimeapps.list. It doesn't actually change anything, but it updated the lastmodified timestamp. When an app is started KWin uses KService to check for the X-KDE-Wayland-Interfaces in the app's desktop file. KService notices that mimeapps.list was touched since the last time it used it and rebuilds its cache. That takes about a second and causes the freeze
Is there something that we can do from kwin or kservice?
Is it possible to make the sycoca build process async? For example, if the timestamp mismatches when querying, then query against the stale database until it is rebuilt. Or, is it possible (or desirable) to make KService a standalone DBus service? Currently, every application using KApplicationTrader::query has to scan all desktop files sometimes. That sounds like a lot of duplicated effort.
> Is there something that we can do from kwin or kservice? KSyscoca::disableAutoRebuild would prevent the rebuild, but then the results won't be correct if something changes
This is no longer happening for me with KWin git master (835d6f4bc68a7e88b486daeec6712570a3a237a4).