Bug 495974

Summary: recentlyused worker hangs
Product: [Frameworks and Libraries] frameworks-activities-stats Reporter: Nicolas Fella <nicolas.fella>
Component: generalAssignee: Ivan Čukić <ivan.cukic>
Status: RESOLVED FIXED    
Severity: normal CC: bugseforuns, caceko8579, fernandommuniz, kde, kdedev, nai.xia, piotrekd, plasma-bugs, qydwhotmail
Priority: VHI    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 6.3.0
Sentry Crash Report:
Attachments: Hotspot analysis

Description Nicolas Fella 2024-11-08 15:29:34 UTC
STEPS TO REPRODUCE
1. Run kioclient ls recentlyused:/files

OBSERVED RESULT
It hangs indefinitely, consuming CPU

EXPECTED RESULT
It prints files

SOFTWARE/OS VERSIONS
KDE Plasma Version: master
KDE Frameworks Version: master
Qt Version: 6.8

ADDITIONAL INFORMATION
Comment 1 Nicolas Fella 2024-11-08 15:30:56 UTC
Created attachment 175652 [details]
Hotspot analysis
Comment 2 Nicolas Fella 2024-11-08 15:31:49 UTC
Seems to be caused by https://invent.kde.org/plasma/plasma-activities/-/merge_requests/52
Comment 3 David Edmundson 2024-12-10 13:30:26 UTC
*** Bug 497271 has been marked as a duplicate of this bug. ***
Comment 4 Piotr Doroszewski 2024-12-10 14:18:47 UTC
Can confirm with KDE Frameworks 6.8.0 and Qt 6.8.1.

Appeared on Reddit today: https://www.reddit.com/r/kde/comments/1hb0ech/does_any_of_you_guys_have_this_recent_files_bug/
Comment 5 Patrick Silva 2024-12-27 21:21:29 UTC
*** Bug 495239 has been marked as a duplicate of this bug. ***
Comment 6 John Kizer 2025-01-08 20:26:44 UTC
*** Bug 497970 has been marked as a duplicate of this bug. ***
Comment 7 Fushan Wen 2025-01-09 13:04:05 UTC
Git commit 8a4731b811f322e93c3c6e3e15ceda7214184620 by Fushan Wen, on behalf of David Edmundson.
Committed on 09/01/2025 at 13:04.
Pushed by fusionfuture into branch 'master'.

Avoid nested event processing waiting for DBus queries.


If a plasma-activity-stats queries can reference the current activity
which involves loading from the running daemon. This is typically async
and cached.
    
If the daemon has not yet loaded or no event loop is running the current
code blocks to wait for a response.
    
The current code could work processEvents only handles the main thread
not the DBus thread. If we need to wait for a DBus result the right
action in this situation is a blocking DBus call.
    
Nested event processing is always a terrible anti-pattern and even if it
did work properly can lead to all sorts of issues elsewhere.
    
To avoid blocking calls in long-running applications which will re-run
queries when the activity changes anyway, it is guarded to only make
blocking calls for headless apps.

M  +25   -8    src/activitiessync_p.cpp

https://invent.kde.org/plasma/plasma-activities-stats/-/commit/8a4731b811f322e93c3c6e3e15ceda7214184620
Comment 8 Fushan Wen 2025-01-09 13:05:26 UTC
Git commit 1ddf939b53f883d0bae1e1e01c44eac2c0af8ef5 by Fushan Wen.
Committed on 09/01/2025 at 13:05.
Pushed by fusionfuture into branch 'Plasma/6.3'.

Avoid nested event processing waiting for DBus queries.


If a plasma-activity-stats queries can reference the current activity
which involves loading from the running daemon. This is typically async
and cached.
    
If the daemon has not yet loaded or no event loop is running the current
code blocks to wait for a response.
    
The current code could work processEvents only handles the main thread
not the DBus thread. If we need to wait for a DBus result the right
action in this situation is a blocking DBus call.
    
Nested event processing is always a terrible anti-pattern and even if it
did work properly can lead to all sorts of issues elsewhere.
    
To avoid blocking calls in long-running applications which will re-run
queries when the activity changes anyway, it is guarded to only make
blocking calls for headless apps.


(cherry picked from commit 8a4731b811f322e93c3c6e3e15ceda7214184620)

b251ac83 Avoid nested event processing waiting for DBus queries.

Co-authored-by: David Edmundson <kde@davidedmundson.co.uk>

M  +25   -8    src/activitiessync_p.cpp

https://invent.kde.org/plasma/plasma-activities-stats/-/commit/1ddf939b53f883d0bae1e1e01c44eac2c0af8ef5
Comment 9 John Kizer 2025-01-14 06:19:59 UTC
*** Bug 498139 has been marked as a duplicate of this bug. ***