Bug 404542

Summary: Gwenview crashes after a few minutes of 180% CPU on large directory of 12000 images
Product: [Applications] gwenview Reporter: Paul Hands <jphands>
Component: generalAssignee: Gwenview Bugs <gwenview-bugs-null>
Status: REPORTED ---    
Severity: crash CC: aspotashev, bugseforuns, khalukhin
Priority: NOR    
Version: 18.12.2   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Paul Hands 2019-02-19 02:40:17 UTC
SUMMARY
Gwenview crashes on a very large directory in Browse mode.  The directory has 12111 images and 247 videos, totaling 36.2 Gb.  Invoking Gwenview in View mode works OK, consuming a lot (>80%) CPU, but still responds.  Switching to Browse mode instantly freezes the machine (unresponsive cursor response to mouse moves, 180% CPU) which crashes after a couple of minutes.  The behaviour is repeatable.  

System info:...

KDE Neon 5.14 running on Zotac E1750 with 4x core i7 CPU @ 3.2GHz, 16G RAM, 2Tb SSD.

Operating System: KDE neon 5.14
KDE Plasma Version: 5.15.0
KDE Frameworks Version: 5.55.0
Qt Version: 5.12.0
Kernel Version: 4.15.0-45-generic
OS Type: 64-bit
Processors: 8 × Intel® Core™ i7-4770R CPU @ 3.20GHz
Memory: 15.4 GiB of RAM



STEPS TO REPRODUCE
1. Use Dolphin to browse to the directory and select any image for open in Gwenview
2. Gwenview works OK in View mode, able to switch between images and scroll the thumbnail bar.
3. Switch to Browse mode

OBSERVED RESULT
Gwenview freezes the entire machine, and crashes after a couple of minutes of 180% CPU use, according to 'top'.  Mouse cursor doesn't resppnd to mouse movement until after Gwenview crashes, when the system returns to normal.

EXPECTED RESULT
Normal browse behavior.

SOFTWARE/OS VERSIONS

Operating System: KDE neon 5.14
KDE Plasma Version: 5.15.0
KDE Frameworks Version: 5.55.0
Qt Version: 5.12.0
Kernel Version: 4.15.0-45-generic
OS Type: 64-bit
Processors: 8 × Intel® Core™ i7-4770R CPU @ 3.20GHz
Memory: 15.4 GiB of RAM
Display is integrated Intel Iris Pro 5200 with dual 4K monitors.

ADDITIONAL INFORMATION
Comment 1 Paul Hands 2019-02-19 02:42:28 UTC
Additional info....

The images are stored on a 1T m.SATA SSD drive formatted as ext4.
Comment 2 Patrick Silva 2019-02-23 14:45:14 UTC
Tested here using a folder containing ~50,000 jpg files located in a ntfs partition.
After I switch to browse mode, led of my hard disk started to blink all the time, ~10 min later the whole computer becomes unresponsive (music playing in background stopped, mouse/keyboard input stopped).
HD led blinking all the time was weird because iotop command shown
normal read/write activity before the system freezes completely.

gwenview 18.12.2
Operating System: Arch Linux 
KDE Plasma Version: 5.15.1
KDE Frameworks Version: 5.55.0
Qt Version: 5.12.1
Kernel Version: 4.20.11-arch2-1-ARCH
OS Type: 64-bit
Processors: 2 × Intel® Celeron® CPU G1820 @ 2.70GHz
Memory: 7,7 GiB of RAM
Comment 3 Alex Kh 2022-08-29 22:48:17 UTC
It might be related to https://bugs.kde.org/show_bug.cgi?id=458491
Comment 4 Alex Kh 2022-08-30 14:42:51 UTC
Well basically what was observed here is a combination of two bugs:

1) thumbnails generation wasn't very optimal - which caused extensive memory consumption (system went into swap, then was dying). This was fixed in https://invent.kde.org/graphics/gwenview/-/merge_requests/49

2) some extra CPU was burnt while making unnecessary filesystem calls - the merge request is there, all-approved, just waiting to be merged soon
https://invent.kde.org/graphics/gwenview/-/merge_requests/154

Thanks to Nicolas Fella, Arjen Hiemstra and Nate Graham for making this happen.