Bug 445196 - Open/Save File Dialog suffers from horrible tearing in Wayland under certain circumstances.
Summary: Open/Save File Dialog suffers from horrible tearing in Wayland under certain ...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: Open/save dialogs (show other bugs)
Version: git master
Platform: Other Linux
: HI normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords: wayland
: 415137 450199 450595 454795 457559 461589 477640 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-11-09 10:58 UTC by SoilpH96
Modified: 2024-01-17 05:30 UTC (History)
13 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Tearing in file dialog. (72.78 KB, image/png)
2021-11-10 11:12 UTC, SoilpH96
Details
Graphical corruptions in file dialog (53.38 KB, image/png)
2021-11-15 21:43 UTC, Jan Rathmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description SoilpH96 2021-11-09 10:58:53 UTC
SUMMARY
When browsing folders within the file dialog in Wayland, bad tearing can happen, making the dialog unusable. This can always be reproduced with Firefox (version 94.0.1), but only occasionally with other applications (I also got it reliably when trying to choose a new notification sound in System Settings).

STEPS TO REPRODUCE
1. Open the file dialog from Firefox
2. Try to browse 

OBSERVED RESULT
The folder view tears badly, making the dialog unusable.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.23.2
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2
Kernel Version: 5.14.16-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 4 × Intel® Core™ i5-7200U CPU @ 2.50GHz
Memory: 7.7 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 620
Comment 1 Nate Graham 2021-11-09 14:28:16 UTC
Can you attach a screenshot?
Comment 2 SoilpH96 2021-11-10 11:12:13 UTC
Created attachment 143406 [details]
Tearing in file dialog.

Here is a screenshot of the bug occurring. The application used to trigger this is Firefox with "widget.use-xdg-desktop-portal" enabled in about:config.
Comment 3 Nate Graham 2021-11-10 14:49:59 UTC
Thanks. Looks like content from Dolphin is leaking into the render buffer for this window. Moving to KWin.
Comment 4 Jan Rathmann 2021-11-15 21:41:53 UTC
I think I see the same thing, additional information how I reproduce this:

1. Open app that uses the KDE file dialog (tested with Ark, Kate, Firefox), try to open a file
2. Everything seems fine first
3. Ensure that the information pane on the right side (F11) in file dialog is enabled
4. Go to a directory that contains archive files (e.g. /var/log on my system)
5. Hover over files/scroll.
6. Graphical corruptions start to appear (see attached screenshot).
7. The graphical corruptions will appear in every directory until the file dialog gets closed.
8. If I invoke the MinimizeAll kwin function, the corruptions on an open file dialog go away temporarily until I scroll or hover over the items. (Minimizing the dialog window with via minimize button from the title bar leaves the corrupted window content unchanged.)

Workaround: Disable the information pane in file dialog (F11).

I'll try to check if this is maybe a regression in the KDE Frameworks update to 5.88 that I installed this morning.

My system:
Kubuntu 21.10 with Kubuntu-backports
Plasma 5.23.3
Frameworks 5.88.0
Graphics: Asus AMD Radeon R7 240

Kind regards, Jan
Comment 5 Jan Rathmann 2021-11-15 21:43:07 UTC
Created attachment 143601 [details]
Graphical corruptions in file dialog
Comment 6 Jan Rathmann 2021-11-15 21:52:40 UTC
Oh, my bad, the original report is from a system with Frameworks 5.87, so it doesn't seem to be a regression (I can also reproduce the bug with an alternate installation with fresh home dir containing Frameworks 5.87).
Comment 7 David Edmundson 2021-11-16 19:15:03 UTC
Please do not move bugs to kwin unless you have proved kwin is responsible. You can add the wayland keyword.
Comment 8 David Edmundson 2021-11-16 19:30:42 UTC
It's the issue seen before. QWidget::winId() called on a non-toplevel

First QPlatformWindow

#10 0x00007ffff5d6f6ce in QWidget::winId (this=0x55555f2023e0)
    at ../../include/QtWidgets/../../../../../src/Qt5/qtbase/src/widgets/kernel/qwidget.h:132
#11 0x00007ffff01aef0d in KDEPlatformFileDialogHelper::restoreSize (this=0x55555efd5ef0)

Second QPlatformWindow

#10 0x00007ffff5d7b760 in QWidget::setVisible (this=this@entry=0x7fffffffc610, visible=visible@entry=true)
    at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qwidget.cpp:8044
#11 0x00007ffff5f79542 in QDialog::setVisible (this=this@entry=0x7fffffffc610, visible=visible@entry=true)

note how this is a different widget. Code in KDEPlatformFileDialogHelper is probably wrong.
Comment 9 David Edmundson 2021-11-16 19:43:32 UTC
Edit, it's not quite the same. The window parent is null in both cases. 
Though it's still a bit odd that we're creating two platform windows when we open the open dialog.
Comment 10 David Edmundson 2021-11-17 15:10:25 UTC
Edit again. It was the same bug, just I had the wrong traces.
There are two windows for the native and built-in dialog. That's fine.

But it's this code in gstreamer (which we load randomly) that causes the subsurface issue.

--Type <RET> for more, q to quit, c to continue without paging--
#29 0x00007ffff66faad7 in QWidget::setAttribute(Qt::WidgetAttribute, bool) ()
    at /usr/lib/libQt5Widgets.so.5
#30 0x00007ffff66fa659 in QWidgetPrivate::createWinId() () at /usr/lib/libQt5Widgets.so.5
#31 0x00007ffff66fc6c5 in QWidget::winId() const () at /usr/lib/libQt5Widgets.so.5

#32 0x00007fffd02cd341 in Phonon::Gstreamer::VideoWidget::setupVideoBin() (this=this@entry=
    0x555555ed12a0)
    at /home/david/projects/kde5/src/kdesupport/phonon-gstreamer/gstreamer/videowidget.cpp:171
#33 0x00007fffd02cd1eb in Phonon::Gstreamer::VideoWidget::VideoWidget(Phonon::Gstreamer::Backend*, QWidget*) (this=0x555555ed12a0, backend=<optimized out>, parent=<optimized out>)
    at /home/david/projects/kde5/src/kdesupport/phonon-gstreamer/gstreamer/videowidget.cpp:65
#34 0x00007fffd02aae00 in Phonon::Gstreamer::Backend::createObject(Phonon::BackendInterface::Class, QObject*, QList<QVariant> const&)
    (this=0x555555f98700, c=Phonon::BackendInterface::VideoWidgetClass, parent=0x5555562c3dd0, args=<optimized out>) at /home/david/projects/kde5/src/kdesupport/phonon-gstreamer/gstreamer/backend.cpp:173
#35 0x00007fffe0099004 in Phonon::Factory::createVideoWidget(QObject*) (parent=0x5555562c3dd0)
    at /home/david/projects/kde5/src/kdesupport/phonon/phonon/factory.cpp:294
#36 0x00007fffe00c8f41 in Phonon::VideoWidgetPrivate::createBackendObject() (this=0x5555562d1380)
    at /home/david/projects/kde5/src/kdesupport/phonon/phonon/videowidget.cpp:76
#37 0x00007fffe00c8e52 in Phonon::VideoWidget::VideoWidget(QWidget*)
    (this=0x5555562c3dd0, parent=<optimized out>)
    at /home/david/projects/kde5/src/kdesupport/phonon/phonon/videowidget.cpp:46
#38 0x00007fffe098f5ca in KFileAudioPreview::KFileAudioPreview(QWidget*, QList<QVariant> const&) (this=
    0x555555f5c3c0, parent=0x555555e9b410)


        QWidget *parentWidget = qobject_cast<QWidget*>(parent());
        if (parentWidget) {
            parentWidget->winId();  // Due to some existing issues with alien in 4.4,


this should obviously be parentWidget->window()->winId();
Comment 11 Bug Janitor Service 2021-11-17 15:21:59 UTC
A possibly relevant merge request was started @ https://invent.kde.org/libraries/phonon-gstreamer/-/merge_requests/2
Comment 12 David Edmundson 2021-11-19 14:03:51 UTC
Git commit bbbb160f30a394655cff9398d17961142388b0f2 by David Edmundson.
Committed on 19/11/2021 at 14:03.
Pushed by davidedmundson into branch 'master'.

Only create window handles for actual windows

winId() creates a platform window for the given widget. This makes sense
for the topmost widget in a tree, we can't assume the parent widget is
the topmost widget.

Doing this on XCB is confusing and wrong, but apparently harmless. Doing
this on wayland causes issues as we promote the parent window to a
subsurface but never show that window leaving things in a bizarre
corrupt state that leads to content not updating.

M  +3    -3    gstreamer/videowidget.cpp

https://invent.kde.org/libraries/phonon-gstreamer/commit/bbbb160f30a394655cff9398d17961142388b0f2
Comment 13 Patrick Silva 2022-02-14 16:12:00 UTC
*** Bug 450199 has been marked as a duplicate of this bug. ***
Comment 14 Patrick Silva 2022-02-17 10:56:33 UTC
*** Bug 415137 has been marked as a duplicate of this bug. ***
Comment 15 Patrick Silva 2022-06-03 15:19:31 UTC
*** Bug 454795 has been marked as a duplicate of this bug. ***
Comment 16 Andrea Ippolito 2022-06-15 01:04:45 UTC
Hello,

I'm able to reproduce this on KDE Plasma 5.24.5 on a Wayland session:

https://www.reddit.com/r/kde/comments/vbwige/firefox_vs_qtplasma_file_picker_and_visual/
Comment 17 Patrick Silva 2022-08-06 20:31:43 UTC
*** Bug 457559 has been marked as a duplicate of this bug. ***
Comment 18 SoilpH96 2022-10-22 10:21:34 UTC
Hello, this bug has been marked as fixed for a good while, but there hasn't been a Phonon release since then to distribute the fix. Could it be possible to do a new minor release of Phonon, or at least recommend distros to include this patch, since this has long persisted as a serious usability problem on Wayland?
Comment 19 Patrick Silva 2022-10-22 11:14:43 UTC
you can install the following package from AUR
https://aur.archlinux.org/packages/phonon-qt5-gstreamer-git

or open a report in Arch bug tracker asking for the patch that fixes the bug.
Comment 21 Nicolas Fella 2022-11-08 14:17:03 UTC
*** Bug 461589 has been marked as a duplicate of this bug. ***
Comment 22 Patrick Silva 2023-11-28 14:21:55 UTC
*** Bug 477640 has been marked as a duplicate of this bug. ***
Comment 23 pallaswept 2024-01-17 05:30:52 UTC
*** Bug 450595 has been marked as a duplicate of this bug. ***