Bug 466211

Summary: file previews of images in file-open dialog consumes a lot of cpu and causes errors in updating the dialog (elements are overdrawn)
Product: [Frameworks and Libraries] frameworks-kio Reporter: slartibart70
Component: Open/save dialogsAssignee: KIO Bugs <kio-bugs-null>
Status: REPORTED ---    
Severity: normal CC: aleixpol, jgrulich, kdelibs-bugs, nate
Priority: NOR    
Version: 5.103.0   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: select 7z file
ALT-up
ALT-up 2
file open

Description slartibart70 2023-02-21 20:42:12 UTC
In wayland using chrome or firefox, the xdg file open dialog and save-as (using  xdg-portal) is broken when operated by keyboard

Setup:
Use  the env.Var GTK_USE_PORTAL=1 and start firefox or chromium-freeworld, then try to open a file with Ctrl-O.
The open-file Portal dialog comes up.

Problem:
- select a folder containing lots of images (where no previews were rendered before)
- you notice kioslave consuming a lot of cpu in the background
- (prepare beforehand: have two 7z zipfiles inside the image folder containing (other) images, both ~250MB in size)
- click on those .7z files (or select them with the keyboard)

- now, use either the mouse or keyboard and try to navigate away from the selected 7z file
- the dialog does still refreshes the preview panel, but the file selection inside the list-panel is broken
(elements overdrawn, multiple selections, lots of bad stuff)
- the name field still follows you selection (as does the preview) so the dialog still somehow works until you try to go to the parent directory with Alt-cursor-up.
- Then, the dialog is completely broken and unusable
Comment 1 slartibart70 2023-02-21 20:46:55 UTC
Operating System: Fedora Linux 37
KDE Plasma Version: 5.27.0
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8
Kernel Version: 6.1.12-200.fc37.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-7820HQ CPU @ 2.90GHz
Memory: 31,1 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 630
Comment 2 Nate Graham 2023-02-21 21:49:49 UTC
I'm having a hard time reproducing this one. Any chance I could ask you to attach a screen recording that shows it happening?
Comment 3 slartibart70 2023-02-22 09:15:11 UTC
simplescreenrecorder does not yet work with wayland, so i made 2 pictures
steps to reproduce:
- open file dialog, enter folder with 7z file
- select file (mouse, keyboard)
- use mouse/keyboard  and hover/select other files above the 7z file
--> see:  after_selecting_the_zip.png

then press ALT-up to go to the parent dir
--> see:   after_ALT_arrow_up.png
Here we have a mix of folders of the parent dir and content of the pictures dir we left previously.
I think the list-panel only redraws only the upper left quadrant of the list and keeps other stuff unaffected
Comment 4 slartibart70 2023-02-22 09:15:42 UTC
Created attachment 156593 [details]
select 7z file
Comment 5 slartibart70 2023-02-22 09:16:39 UTC
Created attachment 156594 [details]
ALT-up
Comment 6 slartibart70 2023-02-22 09:21:25 UTC
Created attachment 156595 [details]
ALT-up 2
Comment 7 slartibart70 2023-02-22 09:23:45 UTC
i added image "ALT-up 2" to show the rectangle where - after pressing ALT-up the updates take place when moving around with the cursor keys.
The rest of the list-panel remains static / keeps old content

And, neither preview nor 'name' input field get updated
Comment 8 Nate Graham 2023-02-22 20:47:35 UTC
Thanks for the detailed steps. Unfortunately after following them I still can't manage to reproduce the issue.
Comment 9 slartibart70 2023-02-23 17:52:51 UTC
Created attachment 156654 [details]
file open
Comment 10 slartibart70 2023-02-23 17:57:39 UTC
the file open dialog is also pretty quickly broken if i want to add a startup/login script from ~/.local/bin (see screenshot 'file open')
This is definitely sth worth looking into

(i had also the effect, that in the 'name' field using the cursor keys i had entries with just the filename and sometimes entries with the complete path in front of it ... pretty much alternating between those 'states' when using up/down arrows.
Right now, the only way to choose a file is to close the dialog and reopen it and use it only by mouse, and never touch the keyboard... and pray :-D )

I am tempted to mark this as a 'severe' bug...
Comment 11 slartibart70 2023-02-23 18:07:49 UTC
i tried this with 5.27.1 on a dual-monitor system
and 
on a different, single-screen laptop
Both times this dialog is severly dysfunctional

Example (single laptop, t420, fc37, plasma 5.27.1)
open file dialog (systemsettings > autostart > add...  > login script
click into the path, select '/bin' (so we have lots of files)
click into the list-panel
select some files
now, use the keyboard and go into the 'name' input field with 'Alt-N'
use up/down arrows

Now you see filenames appearing in the name field,  and if you press up/down long enough, you find entries in the 'name' field coming with full path from
/home/claus/Documents/ ...
/usr/share/sddm/...
and so on.

Just unusable and severly broken