Bug 438608 - "Open Folder" dialog freezes app
Summary: "Open Folder" dialog freezes app
Status: RESOLVED WORKSFORME
Alias: None
Product: xdg-desktop-portal-kde
Classification: Plasma
Component: general (show other bugs)
Version: 5.27.5
Platform: Flatpak Linux
: NOR critical
Target Milestone: ---
Assignee: Jan Grulich
URL:
Keywords:
Depends on:
Blocks: 435225
  Show dependency treegraph
 
Reported: 2021-06-14 11:21 UTC by Julius Künzel
Modified: 2023-05-19 10:02 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
gdb backtrace (6.32 KB, text/plain)
2021-06-18 14:47 UTC, Julius Künzel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Julius Künzel 2021-06-14 11:21:39 UTC
SUMMARY
File open dialogs with selection mode "directory" are freezing the application forever. I experienced this with multiple KDE Applications, but only with the Flatpak version. I marked this as critical as I think the open directory dialog is quite common and often used but the related features are completely broken with the freeze.
It seems that the freeze happen only with the modal version, but in the non-modal version there seems to be still something strange as folders in my home dir are not shown at all. However I haven't tested this further…

Experienced with: Kdenlive, Kate and flatpak-portal-test-kde (https://invent.kde.org/libraries/xdg-portal-test-kde/-/tree/master)

STEPS TO REPRODUCE
1. Install flatpak-portal-test-kde (https://invent.kde.org/libraries/xdg-portal-test-kde/-/tree/master)
2. Start the application
3. Hit the button "Open (modal)…" in the "Open directory" line

OBSERVED RESULT
The application freezes

EXPECTED RESULT
Everything works as expected

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE Neon User Edition and Ubuntu Studio (XFCE)
Comment 1 Jan Grulich 2021-06-14 12:24:06 UTC
What is your xdg-desktop-portal version? I believe the issue is that you have old xdg-desktop-portal version and the dialog is opened inside sandbox instead. At least I cannot reproduce it here.
Comment 2 Julius Künzel 2021-06-14 18:55:45 UTC
How can I check the xdg-desktop-portal?
I compiled flatpak-portal-test-kde just today from source. All other packages on my machine (flatpak as well) should be up-to-date…

Btw BUG 43533is exactly about this for Kdenlive

Operating System: KDE neon 5.22
KDE Plasma Version: 5.22.0
KDE Frameworks Version: 5.83.0
Qt Version: 5.15.3
Kernel Version: 5.4.0-74-generic (64-bit)
Graphics Platform: X11
Processors: 4 × Intel® Core™ i5-2540M CPU @ 2.60GHz
Memory: 7.7 GiB of RAM
Graphics Processor: AMD CAICOS
Comment 3 Julius Künzel 2021-06-14 18:56:58 UTC
(In reply to Julius Künzel from comment #2)
> Btw BUG 43533is exactly about this for Kdenlive

Wrong bug, this is the right one Bug 435225
Comment 4 Jan Grulich 2021-06-16 08:48:53 UTC
I cannot reproduce the freeze, possibly because of newer version of xdg-desktop-portal, no idea. However, in order to have folder selection dialog to work you need to have https://invent.kde.org/frameworks/kio/-/merge_requests/445.
Comment 5 Julius Künzel 2021-06-18 14:40:18 UTC
The Flatpak runtime got the update to 5.83 yesterday so I updated org.kde.Platform to have the MR you mentioned, but I still have the same problem (or is it necessary to rebuild the kdenlive Flatpak with the updated org.kde.Sdk???)
Comment 6 Julius Künzel 2021-06-18 14:47:10 UTC
Created attachment 139492 [details]
gdb backtrace

Here is a gdb backtrace. Does it help?
Comment 7 Jan Grulich 2021-06-25 15:39:01 UTC
I cannot reproduce still. Does it happen only when trying to open a directory? Does it happen when picking a file?
Comment 8 Julius Künzel 2021-07-02 08:14:15 UTC
It only happens with directory, with files it works fine
Comment 9 Alexander Ewering 2021-09-22 11:23:22 UTC
I have this problem with Kdenlive 21.08.1 when clicking on 'Search recursively' in the 'Missing clips' dialog upon opening a project. A folder tree dialog is opened, and the whole application becomes completely unresponsive, necessitating a kill -9.
Comment 10 Julius Künzel 2022-01-11 04:04:13 UTC
@Jan In the meanwhile I have a new PC and new Plasma Version and I can still reproduce this. Have you tested it on X11 or Wayland?

Here is some code to reproduce:

    QFileDialog *fileDialog = new QFileDialog(this);
    fileDialog->setFileMode(QFileDialog::Directory);

    if (fileDialog->exec() == QDialog::Accepted) {
        fileDialog->deleteLater();
    }

If you change use fileDialog->setFileMode(QFileDialog::ExistingFile) instead it works perfectly fine.

Here is the output of flatpak-portal-test-kde after you triggered the "Open (modal)…" button in the "Open Directory" row. If you do the same with the one in the "FileChooser:" row there is no output:

    kf.kio.widgets: Cannot read information about filesystem under path "/home/julius/.var/app/org.kde.portal-test-kde/cache/thumbnails/"
    Qt: Session management error: networkIdsList argument is NULL


Operating System: KDE neon 5.23
KDE Plasma Version: 5.23.5
KDE Frameworks Version: 5.89.0
Qt Version: 5.15.3
Kernel Version: 5.15.6-051506-generic (64-bit)
Graphics Platform: X11
Processors: 16 × AMD Ryzen 7 5800HS with Radeon Graphics
Memory: 15.1 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 1650 with Max-Q Design/PCIe/SSE2
Comment 11 Albert Astals Cid 2022-01-24 23:01:57 UTC
I can not reproduce it hanging but i can reproduce QFileDialog::Directory not working.

Run org.kde.gwenview, select 2 images, open the right mouse button menu, select "Copy To".

See how regular gwenview from not flatpak works but the one from flatpak doesn't actually let you select a folder.
Comment 12 Julius Künzel 2022-01-24 23:13:01 UTC
For me with Kdenlive and flatpak-portal-test-kde it is a strange hanging, because it does not real freeze (the cursor continues to flash), but it doesn't accept any input anymore (not even close) so the only option is to kill the app.
Comment 13 Julius Künzel 2022-02-09 11:39:03 UTC
Still confirmed on 5.24
Comment 14 Julius Künzel 2022-02-09 11:52:18 UTC
Just to avoid misunderstandings I like to mention that this happens with flatpak-portal-test-kde and the code I posted above only inside a Flatpak, while flatpak-portal-test-kde outside a Flatpak does not have this problem
Comment 15 Jan Grulich 2022-02-16 11:46:37 UTC
(In reply to Julius Künzel from comment #14)
> Just to avoid misunderstandings I like to mention that this happens with
> flatpak-portal-test-kde and the code I posted above only inside a Flatpak,
> while flatpak-portal-test-kde outside a Flatpak does not have this problem

I'm still not able to reproduce, I tried flatpak-portal-test-kde (as flatpak) and it just works without any issue.

 (In reply to Albert Astals Cid from comment #11)
> I can not reproduce it hanging but i can reproduce QFileDialog::Directory
> not working.
> 
> Run org.kde.gwenview, select 2 images, open the right mouse button menu,
> select "Copy To".
> 
> See how regular gwenview from not flatpak works but the one from flatpak
> doesn't actually let you select a folder.

This is because I can see it calling "FileChooser::SaveFile" instead "FileChooser::SaveFiles" which should request a directory. This is something I will have to fix in Qt itself and possibly in xdg-desktop-portal-kde.
Comment 16 Julius Künzel 2022-02-17 08:49:05 UTC
Hmm. Very annoying. Any idea what else I can do to debug this?
Comment 17 Trent M 2022-03-09 03:12:29 UTC
I reproduced this issue using KDE Neon 5.24 and two specific Flatpak apps: OBS Studio and youtubedl-gui. OBS Studio when trying to pick a directory to save recordings in, and youtubedl-gui when trying to pick a directory to save downloads in.

OBS Studio is especially problematic because this app is published by upstream directly on Flathub; it's an official package from them.
Comment 18 Nate Graham 2022-03-09 20:13:40 UTC
In progress with https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/merge_requests/76
Comment 19 Boba Fit 2023-02-17 10:51:37 UTC
Today I was able to find the bug in my system. ~/.conifg/QtProject.conf was 512MB.

```
[FileDialog]
shortcuts=file:, file:///home/bobafit, file:///home/bobafit/Documents/KDFÃÂÃÂÃÂÃÂÃÂ...[and 500MB more]...ÃÂE/script
```

I just moved this file away and now KDE runs very smoothly again :-)
Comment 20 Linus Dierheimer 2023-05-15 09:52:24 UTC
I am having the same problem, but my QtProject.conf is normal. Instead i get spammed with the following logs from xdg-desktop-portal-kde in journald: QWindow::fromWinId(): platform plugin does not support foreign windows.
Comment 21 Linus Dierheimer 2023-05-18 13:33:14 UTC
The issue for me was, that QT_QPA_PLATFORMTHEME was set to someting incorrect. Deleting it fixes this issue.
Comment 22 Nate Graham 2023-05-18 13:41:09 UTC
Worth checking for sure. Julius, can you run `echo $QT_QPA_PLATFORMTHEME` in a terminal window and paste the output?
Comment 23 Julius Künzel 2023-05-19 10:02:52 UTC
I tested it again with the latest versions of Kdenlive and xdg-portal-test-kde and it works with both now. So I am closing it.

BTW the output of `echo $QT_QPA_PLATFORMTHEME` is empty