Bug 452011 - krunner blocks UI when loading Telepathy contacts runner
Summary: krunner blocks UI when loading Telepathy contacts runner
Status: CONFIRMED
Alias: None
Product: telepathy
Classification: Frameworks and Libraries
Component: contact-runner (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: Future
Assignee: Telepathy Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-28 17:41 UTC by Dāvis
Modified: 2022-03-29 15:35 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dāvis 2022-03-28 17:41:20 UTC
SUMMARY
krunner blocks UI which can be very annoying


STEPS TO REPRODUCE
Not exactly sure, but have something slow that krunner is trying to use and then first time you try to use krunner it will block whole UI for a while.
Note that this is reproducible for both Plasma Desktop left side panel and top Alt+Space runner

OBSERVED RESULT
First time trying to search in krunner it will block whole UI. In case of plasmashell it blocks whole desktop/panels won't be responsive until it finishes. For me that can be like 10+ seconds.

EXPECTED RESULT
Don't block UI, show loading spinner and show results as soon as they come

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version:  5.24.3
KDE Frameworks Version:  5.93.0
Qt Version:  5.15.3

ADDITIONAL INFORMATION

It can be seen in this plasmashell backtrace

```
#0  0x00007fd47046b15a in __futex_abstimed_wait_common () at /usr/lib/libc.so.6
#1  0x00007fd47046d960 in pthread_cond_wait@@GLIBC_2.3.2 () at /usr/lib/libc.so.6
#2  0x00007fd4708fccfc in QWaitCondition::wait(QMutex*, QDeadlineTimer) () at /usr/lib/libQt5Core.so.5
#3  0x00007fd471527db9 in  () at /usr/lib/libQt5DBus.so.5
#4  0x00007fd4714f8b38 in  () at /usr/lib/libQt5DBus.so.5
#5  0x00007fd4714fd9ac in QDBusInterface::QDBusInterface(QString const&, QString const&, QString const&, QDBusConnection const&, QObject*) () at /usr/lib/libQt5DBus.so.5
#6  0x00007fd35804e975 in KTp::GlobalPresence::GlobalPresence(QObject*) () at /usr/lib/libKTpCommonInternals.so.9
#7  0x00007fd3ec84ddf0 in  () at /usr/lib/qt/plugins/kf5/krunner/krunner_ktp_contacts.so
#8  0x00007fd3ec84f6c0 in  () at /usr/lib/qt/plugins/kf5/krunner/krunner_ktp_contacts.so
#9  0x00007fd471413d95 in KPluginFactory::create(char const*, QWidget*, QObject*, QList<QVariant> const&, QString const&) (this=this@entry=0x55763a5b1bb0, iface=0x7fd3b4158990 <qt_meta_stringdata_Plasma__AbstractRunner+336> "Plasma::AbstractRunner", parentWidget=parentWidget@entry=0x0, parent=parent@entry=0x7fd3484a75a0, args=..., keyword=...) at kcoreaddons/src/lib/plugin/kpluginfactory.cpp:232
#10 0x00007fd3b41516e5 in KPluginFactory::create<Plasma::AbstractRunner>(QObject*, QList<QVariant> const&) (args=..., parent=0x7fd3484a75a0, this=0x55763a5b1bb0) at /usr/include/KF5/KCoreAddons/kpluginfactory.h:922
#11 KPluginFactory::instantiatePlugin<Plasma::AbstractRunner>(KPluginMetaData const&, QObject*, QList<QVariant> const&) (data=..., parent=0x7fd3484a75a0, args=...) at /usr/include/KF5/KCoreAddons/kpluginfactory.h:509
#12 0x00007fd3b41526e7 in Plasma::RunnerManagerPrivate::loadInstalledRunner(KPluginMetaData const&) (this=this@entry=0x7fd45c016d80, pluginMetaData=...) at krunner/src/runnermanager.cpp:302
#13 0x00007fd3b415474f in Plasma::RunnerManagerPrivate::loadRunners(QString const&) (this=0x7fd45c016d80, singleRunnerId=...) at krunner/src/runnermanager.cpp:210
#14 0x00007fd3b414ea04 in Plasma::RunnerManager::launchQuery(QString const&, QString const&) (this=0x7fd3484a75a0, untrimmedTerm=<optimized out>, runnerName=...) at krunner/src/runnermanager.cpp:968
#15 0x00007fd3b414ea9a in Plasma::RunnerManager::launchQuery(QString const&) (this=<optimized out>, term=<optimized out>) at krunner/src/runnermanager.cpp:942
#16 0x00007fd470ace463 in  () at /usr/lib/libQt5Core.so.5
#17 0x00007fd470ad069f in QTimer::timeout(QTimer::QPrivateSignal) () at /usr/lib/libQt5Core.so.5
#18 0x00007fd470ac1766 in QObject::event(QEvent*) () at /usr/lib/libQt5Core.so.5
#19 0x00007fd47173d1c6 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#20 0x00007fd470a9d5aa in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#21 0x00007fd470ae8dd5 in QTimerInfoList::activateTimers() () at /usr/lib/libQt5Core.so.5
#22 0x00007fd470ae93ba in  () at /usr/lib/libQt5Core.so.5
#23 0x00007fd46edf9163 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#24 0x00007fd46ee4f9e9 in  () at /usr/lib/libglib-2.0.so.0
#25 0x00007fd46edf66c5 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#26 0x00007fd470ae957a in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#27 0x00007fd470a9588b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#28 0x00007fd470aa0fd7 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#29 0x0000557635d8e3f2 in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at plasma-workspace/shell/main.cpp:243
```
Comment 1 Nate Graham 2022-03-28 21:35:58 UTC
This seems to be the culprit:

#5  0x00007fd4714fd9ac in QDBusInterface::QDBusInterface(QString const&, QString const&, QString const&, QDBusConnection const&, QObject*) () at /usr/lib/libQt5DBus.so.5
#6  0x00007fd35804e975 in KTp::GlobalPresence::GlobalPresence(QObject*) () at /usr/lib/libKTpCommonInternals.so.9
#7  0x00007fd3ec84ddf0 in  () at /usr/lib/qt/plugins/kf5/krunner/krunner_ktp_contacts.so
#8  0x00007fd3ec84f6c0 in  () at /usr/lib/qt/plugins/kf5/krunner/krunner_ktp_contacts.so

Do you have KDE's telepathy software installed?
Comment 2 Dāvis 2022-03-29 01:42:44 UTC
(In reply to Nate Graham from comment #1)
> This seems to be the culprit:
> 
> #5  0x00007fd4714fd9ac in QDBusInterface::QDBusInterface(QString const&,
> QString const&, QString const&, QDBusConnection const&, QObject*) () at
> /usr/lib/libQt5DBus.so.5
> #6  0x00007fd35804e975 in KTp::GlobalPresence::GlobalPresence(QObject*) ()
> at /usr/lib/libKTpCommonInternals.so.9
> #7  0x00007fd3ec84ddf0 in  () at
> /usr/lib/qt/plugins/kf5/krunner/krunner_ktp_contacts.so
> #8  0x00007fd3ec84f6c0 in  () at
> /usr/lib/qt/plugins/kf5/krunner/krunner_ktp_contacts.so
> 
> Do you have KDE's telepathy software installed?

Yeah, but I don't really use it.
From backtrace can see that KTP runner waits on QBus which obviously causes this slowdown, but that's just one potential culprit. I would say the real issue is that it blocks UI while loading runners at https://invent.kde.org/frameworks/krunner/-/blob/master/src/runnermanager.cpp#L968 which very likely is slow.
Comment 3 Alexander Lohnau 2022-03-29 13:37:57 UTC
The issue is that the initialization is in the main thread done and we run into a DBus timeout.

Though I haven't heard of anyone using this runner, IMHO we should just move it to unmaintained and tell distros to not ship it anymore by default.

> I would say the real issue is that it blocks UI while loading runners

Yeah, but you have to load them somehow and we can not do that in threads. With recent optimizations that will land in Plasma 5.25, the runners will do far less heavy work when being loaded.
Comment 4 Nate Graham 2022-03-29 14:41:04 UTC
Ok, if there is already code improvement in KRunner itself to make this faster, then our only actionable thing is to deprecate the telepathy runner. As far as I can see, Telepathy stuff is still in https://invent.kde.org/network?filter=telepathy getting commits (well, some repos). It doesn't look unmaintained, but I can't see it on kde.org/applications, either... Maybe it's worth having a conversation about this on a mailing list somewhere?
Comment 5 Nicolas Fella 2022-03-29 15:20:55 UTC
As far as I can tell it's hanging while creating the QDBusInterface in https://invent.kde.org/network/ktp-common-internals/-/blob/master/KTp/global-presence.cpp#L48

It could be that the other side (the ktp kded module) is not responding for some reason. Or just the fact that creating a QDBusInterface this way is slow and should not be done. It could well be that this can be easily improved by using a generated interface class, but my motivation to touch KTP code is slim and I'd rather see it buried. But that's just my opinion
Comment 6 Dāvis 2022-03-29 15:35:20 UTC
Okay, for now I just uninstalled telepathy runner. But it's very unfortunate issue because it might not be obvious at all why krunner freezes things and there could be other slow runners aswell. Many people can have them installed without realizing they would cause such issues.