Bug 424024 - Main window doesn't repaint correctly on Wayland
Summary: Main window doesn't repaint correctly on Wayland
Status: ASSIGNED
Alias: None
Product: lokalize
Classification: Applications
Component: general (show other bugs)
Version: 22.12.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Simon Depiets
URL:
Keywords: wayland
: 445887 462485 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-07-09 13:03 UTC by Matej Mrenica
Modified: 2024-10-20 23:08 UTC (History)
26 users (show)

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


Attachments
Log (693.09 KB, text/plain)
2020-07-27 09:49 UTC, Matej Mrenica
Details
workaround is fine for now (53.46 KB, image/jpeg)
2023-05-12 04:10 UTC, Geraldo Simião
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matej Mrenica 2020-07-09 13:03:57 UTC
SUMMARY
On wayland certain parts of Lokalize main window don't repaint. For example after scrolling in the list of strings there is an area that doesn't change. Or clicking on a string should show the original and the translation on the right side but only one of the fields gets updated. Usually hovering over the affected area, clicking in the area, switching to a different app and other actions force the repaint. Forcing Lokalize to use XWayland fixes this issue.

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.19.3
KDE Frameworks Version: 5.71
Qt Version: 5.15.0

This report might belong to Kwin bugs.
Comment 1 Vlad Zahorodnii 2020-07-27 07:10:58 UTC
Can you please run lokalize as `env WAYLAND_DEBUG=1 lokalize` and post the output here?
Comment 2 Matej Mrenica 2020-07-27 09:49:52 UTC
Created attachment 130430 [details]
Log
Comment 3 David Edmundson 2020-07-27 13:31:18 UTC
The symptoms sound similar to drkonqi bug 418755/420035

which was the result of an application bug creating accidental windows randomly for non-toplevel QWidgets.
Comment 4 David Edmundson 2020-09-16 22:42:41 UTC
Gammaray implies it's the same thing as above. There are a bunch of QWidgetWindow objects children of the toplevel QWidgetWindow. There should only be one for each actual window. This is an application bug. 

Can you give steps from a clean install and no config to reproduce this issue?
Comment 5 David Edmundson 2020-09-16 22:54:33 UTC
I'm debugging blind a bit, but it seems we have multiple TMTab objects that (indirectly) inherit from KMainWindow despite being children.

kmainwindow.cpp will force creation of a platform window, which makes sense for a toplevel, but otherwise will cause the problems above.

  349     q->winId(); // workaround for setWindowRole() crashing, and set also window role, just in case TT


This should hopefully be fixable if we add some sort of  "if (q->isWindow())" round this code.
Comment 6 Matej Mrenica 2020-09-17 06:30:41 UTC
(In reply to David Edmundson from comment #4)
> Can you give steps from a clean install and no config to reproduce this
> issue?

1. (create a new user)
2. start Lokalize
3. open a .po file
4. try to scroll in the "list of strings" -> it doesn't move
or try resizing one of the sub-windows -> it leaves a trail
Comment 7 Bug Janitor Service 2020-09-17 09:54:35 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kxmlgui/-/merge_requests/21
Comment 8 Albert Astals Cid 2020-09-29 22:39:28 UTC
Git commit 03b0f4c333c688059645846563e7795772e62bfe by Albert Astals Cid, on behalf of David Edmundson.
Committed on 29/09/2020 at 22:34.
Pushed by davidedmundson into branch 'master'.

[kmainwindow] Don't create native windows for non-toplevel windows

winId() creates a QPlaformWindow; i.e a native xcb_window or wl_surface.
This makes sense for a toplevel which will be a real window.

If someone (in this case localize) uses kmainwindow as a subwidget
inside an existing window the current code will create a subwindow for
this widget. It's a very weird window, as the window is never actually
mapped so all contents are drawn as part of the parent window. Leaving
us in a very corrupt state.

Doing this on XCB is wasteful but the side effects are unnoticed. On
QtWayland things explode in weird ways.

M  +5    -3    src/kmainwindow.cpp

https://invent.kde.org/frameworks/kxmlgui/commit/03b0f4c333c688059645846563e7795772e62bfe
Comment 9 Matej Mrenica 2020-12-21 20:16:13 UTC
I am on Arch Linux, Lokalize 20.12, everything else also up-to-date and I still have this issue. Can someone confirm either way?
Comment 10 geisserml 2021-02-21 12:41:26 UTC
I can confirm that the issue is still present in Lokalize 20.12.2 (Qt 5.15.2, KDE Neon User).
This unfortunately makes Lokalize basically unusable on Wayland.
Comment 11 geisserml 2021-03-12 10:28:38 UTC
Could you please look at it again? The modifications in kxmlgui didn't fix the issue with Lokalize.
Enforcing XWayland by adding `-platform xcb` is good a workaround for the meantime if you don't want to go back to X11 completely.
Comment 12 geisserml 2021-05-03 14:42:22 UTC
The problem persists in Lokalize 21.04.0
Comment 13 David Edmundson 2021-05-03 15:27:09 UTC
Put a breakpoint on QPlatformWindow::QPlatormWindow

it should occur once for the top level and again for menus, any others are your source of problems
Comment 14 geisserml 2021-05-03 16:37:18 UTC
typo Platorm

QPlatformWindow::QPlatformWindow would be correct
Comment 15 geisserml 2021-05-03 16:49:59 UTC
It occurs fairly often in fact, about 45 breakpoints until the main window turns up.
Comment 16 geisserml 2021-05-03 17:00:22 UTC
However, I'm not sure whether this is the right approach. This is not one of the classical Qt/Wayland rendering issues; and no breakpoint happens when the window doesn't repaint properly.
Comment 17 geisserml 2021-06-18 16:11:03 UTC
(In reply to David Edmundson from comment #13)
> Put a breakpoint on QPlatformWindow::QPlatormWindow
> 
> it should occur once for the top level and again for menus, any others are
> your source of problems
I suggest that you, the developers, could make the backtracing on your own rather than asking unskilled users (who can't understand the output) to do it. This issue is easy to reproduce after all.
Comment 18 David Edmundson 2021-11-18 01:42:09 UTC
needs a trace to be Probably fixed with my commit above, it was reopened without confirming frameworks version. if it's not please add backtrace as requested.
Comment 19 geisserml 2021-11-18 12:36:57 UTC
I don't know if there's a misunderstanding, but the commit you referenced is one year old and therefore should already have been released to end users, right? As the obvious visual problems still persist, I believe your commit did not fix the issue.
(Software versions: KDE Frameworks 5.88 and kxmlgui 5.87.0+build37 in Neon User)
Comment 20 geisserml 2021-11-18 12:43:24 UTC
(In reply to geisserml from comment #19)
> (Software versions: KDE Frameworks 5.88 and kxmlgui 5.87.0+build37 in Neon User

... however, now I come to think about this, it's really strange that system settings report Frameworks 5.88 and most kf5 package versions have something with 5.88, but libkf5xmlgui5 is still at 5.87 - is this an issue with Neon Packages? Is the fix part of KF5 5.87 already, or not?
Comment 21 Bug Janitor Service 2021-12-03 04:38:32 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 22 geisserml 2021-12-08 18:22:21 UTC
@davidedmundson Repeating the question: Is your supposed fix part of the kxmlgui release that is currently in KDE Neon User?
If yes, then it clearly didn't fix the issue.
If not, we need to update kxmlgui and then check again.
Comment 23 geisserml 2021-12-13 18:45:11 UTC
So today kxmlgui got updated to 5.89 in Neon User. Your commit unfortunately does not fix the issue. Please investigate the true cause.
Comment 24 Jan Rathmann 2021-12-30 20:33:48 UTC
I'm seeing this too, on Kubuntu 21.10 with Plasma 5.24.3 an Frameworks 5.89.

Is there any additional helpful data that I can provide?
Comment 25 David Marzal 2022-02-17 11:33:30 UTC
*** Bug 445887 has been marked as a duplicate of this bug. ***
Comment 26 farline99 2022-12-01 11:03:00 UTC
Same problem on Arch Linux, KDE Plasma 5.26.4, Wayland. Repo or Flatpak version does not matter. Guys, PLEASE fix this. I can't use this program with so many UI glitches...
Comment 27 farline99 2022-12-02 19:19:26 UTC
*** This bug has been confirmed by popular vote. ***
Comment 28 Nicolas Fella 2022-12-04 22:24:45 UTC
*** Bug 462485 has been marked as a duplicate of this bug. ***
Comment 29 David Edmundson 2023-02-17 10:52:48 UTC
I just ran localize with my steps above:

#0  0x00007ffff1883720 in QtWaylandClient::QWaylandWindow::QWaylandWindow(QWindow*, QtWaylandClient::QWaylandDisplay*) () from /opt/qt5/lib/libQt5WaylandClient.so.5
#1  0x00007ffff69dfa02 in ?? () from /opt/qt5/plugins/wayland-graphics-integration-client/libqt-plugin-wayland-egl.so
#2  0x00007ffff69dded7 in ?? () from /opt/qt5/plugins/wayland-graphics-integration-client/libqt-plugin-wayland-egl.so
#3  0x00007ffff1871e1a in QtWaylandClient::QWaylandIntegration::createPlatformWindow(QWindow*) const () from /opt/qt5/lib/libQt5WaylandClient.so.5
#4  0x00007ffff5584aeb in QWindowPrivate::create (this=0x555556f526b0, recursive=false, nativeHandle=0) at /home/david/projects/kde5/src/Qt5/qtbase/src/gui/kernel/qwindow.cpp:528
#5  0x00007ffff5583ac8 in QWindow::create (this=0x555556fe3f10) at /home/david/projects/kde5/src/Qt5/qtbase/src/gui/kernel/qwindow.cpp:657
#6  0x00007ffff5fd1852 in QWidgetPrivate::create (this=0x555555b16030) at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qwidget.cpp:1316
#7  0x00007ffff5fcfed7 in QWidget::create (this=0x555555fac280, window=0, initializeWindow=true, destroyOldWindow=true)
    at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qwidget.cpp:1181
#8  0x00007ffff5fd11ba in QWidgetPrivate::createWinId (this=0x555555b16030) at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qwidget.cpp:2384
#9  0x00007ffff5fcf8de in QWidget::setAttribute (this=0x555555fac280, attribute=Qt::WA_NativeWindow, on=true)
    at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qwidget.cpp:11059
#10 0x00007ffff5fd10e2 in QWidgetPrivate::createWinId (this=0x555555aab0f0) at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qwidget.cpp:2375
#11 0x00007ffff5fcf8de in QWidget::setAttribute (this=0x555555aaad00, attribute=Qt::WA_NativeWindow, on=true)
    at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qwidget.cpp:11059
#12 0x00007ffff5fd10e2 in QWidgetPrivate::createWinId (this=0x55555708cb10) at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qwidget.cpp:2375
#13 0x00007ffff5fd10fe in QWidgetPrivate::createWinId (this=0x555556aacf10) at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qwidget.cpp:2377
#14 0x00007ffff5fd1012 in QWidget::createWinId (this=0x555556aecb10) at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qwidget.cpp:2444
#15 0x00007ffff5fed05c in QWidgetPrivate::setParent_sys (this=0x555556aacf10, newparent=0x555556cbb050, f=...)
    at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qwidget.cpp:10633
#16 0x00007ffff5fd04c1 in QWidget::setParent (this=0x555556aecb10, parent=0x555556cbb050, f=...) at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qwidget.cpp:10443
#17 0x00007ffff5fec89c in QWidget::setParent (this=0x555556aecb10, parent=0x555556cbb050) at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qwidget.cpp:10366
#18 0x00007ffff5fbdc80 in QLayout::addChildWidget (this=0x555556d1f690, w=0x555556aecb10) at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qlayout.cpp:926
#19 0x00007ffff5fbd941 in QLayout::addWidget (this=0x555556d1f690, w=0x555556aecb10) at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/kernel/qlayout.cpp:235
#20 0x00007ffff61b9b80 in QMdiSubWindow::setWidget (this=0x555556cbb050, widget=0x555556aecb10) at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/widgets/qmdisubwindow.cpp:2312
#21 0x00007ffff61a5675 in QMdiArea::addSubWindow (this=0x555555fac280, widget=0x555556aecb10, windowFlags=...)
    at /home/david/projects/kde5/src/Qt5/qtbase/src/widgets/widgets/qmdiarea.cpp:1987
#22 0x00005555555dda13 in LokalizeMainWindow::fileOpen (this=0x5555558cce40, filePath=..., entry=0, setAsActive=true, mergeFile=..., silent=false)
    at /home/david/projects/kde5/src/kde/kdesdk/lokalize/src/lokalizemainwindow.cpp:262
#23 0x00005555555c4cc1 in LokalizeMainWindow::qt_static_metacall (_o=0x5555558cce40, _c=QMetaObject::InvokeMetaMethod, _id=33, _a=0x7fffffffaad0)
    at src/liblokalize_autogen/EWIEGA46WW/moc_lokalizemainwindow.cpp:288


here's our problem.
Comment 30 David Edmundson 2023-02-17 11:04:51 UTC
The editor window we're embedding into a subwindow is a subclass of KMainWindow. 

As soon as the backend things we're embedding windows in windows, but client code thinks it's embedding widgets in widgets it all gets out of sync.
Comment 31 farline99 2023-02-17 11:05:59 UTC
Problem is still here. Arch Linux, plasma 5.27, frameworks 103, Lokalize 22.12.2.
Comment 32 Shinjo Park 2023-02-24 21:37:37 UTC
I just found that on Kubuntu 22.10 the XCB workaround is also completely broken, just making the file tab all black. Wayland problem is still present.

(In reply to David Edmundson from comment #5)
> I'm debugging blind a bit, but it seems we have multiple TMTab objects that
> (indirectly) inherit from KMainWindow despite being children.

I think you are right, see https://invent.kde.org/sdk/lokalize/-/blob/master/DESIGN:
> Tabs are KMainWindows + KXmlGuiCleints.

Given that workarounds are not really working, I guess the application code should be modified.
Comment 33 Geraldo Simião 2023-05-12 03:54:39 UTC
Bug still present at my setup:

lokalize-23.04.0-1.fc37.x86_64

Operating System: Fedora Linux 37
KDE Plasma Version: 5.27.5
KDE Frameworks Version: 5.105.0
Qt Version: 5.15.9
Kernel Version: 6.2.15-200.fc37.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-3632QM CPU @ 2.20GHz
Memory: 15.4 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 4000

kf5-kwindowsystem-5.105.0-1.fc37.x86_64
kf5-kxmlgui-5.105.0-1.fc37.x86_64
kwin-libs-5.27.5-1.fc37.x86_64
kwin-common-5.27.5-1.fc37.x86_64
kwin-x11-5.27.5-1.fc37.x86_64
kwin-wayland-5.27.5-1.fc37.x86_64
kwin-5.27.5-1.fc37.x86_64
Comment 34 Geraldo Simião 2023-05-12 04:10:41 UTC
Created attachment 158875 [details]
workaround is fine for now

Added ´´-platform xcb´´ to the launcher at menu edit and its correctly using xwayland without problems on fedora 37 KDE spin.
Its a workaround indeed.
Comment 35 Heimen Stoffels 2023-06-19 12:37:14 UTC
Still present on openSUSE Tumbleweed with KDE Plasma 5.27. -platform xcb is a good workaround, but really shouldn't be needed, especially now that KDE is so focused on Wayland.
Comment 36 Mirko Pagliai 2023-07-26 11:32:39 UTC
(In reply to Geraldo Simião from comment #34)
> Created attachment 158875 [details]
> workaround is fine for now
> 
> Added ´´-platform xcb´´ to the launcher at menu edit and its correctly using
> xwayland without problems on fedora 37 KDE spin.
> Its a workaround indeed.

Problem is still here, but this workaround works for me, great!
Comment 37 Heimen Stoffels 2023-07-26 11:34:10 UTC
It used to work with the workaround, as I reported last month, but somewhere in the past few weeks, it stopped working. Still openSUSE Tumbleweed with Plasma 5.27.
Comment 38 Matej Mrenica 2023-07-26 11:48:14 UTC
You need to set QT_QPA_PLATFORM=xcb for Lokalize, then it works. In Edit app->App->Environment variables.
Comment 39 Heimen Stoffels 2023-07-26 11:49:25 UTC
(In reply to Matej Mrenica from comment #38)
> You need to set QT_QPA_PLATFORM=xcb for Lokalize, then it works. In Edit
> app->App->Environment variables.

I have done that and like I said, it used to work, but it stopped working for me.
Comment 40 auxsvr 2023-08-22 05:51:33 UTC
Is https://bugs.kde.org/show_bug.cgi?id=456908 a duplicate of this?
Comment 41 alberic89 2023-08-29 10:36:04 UTC
I use Lokalize 22.12.3 (KDE env 5.103.0 and Qt 5.15.8) on Debian 12 stable with GNOME and Wayland, and I have the same bug.
Add the argument `-platform xcb` have solved also the problem, but it was not easy to go here to find the solution
Comment 42 Adrián Chaves (Gallaecio) 2024-03-09 15:07:08 UTC
“QT_QPA_PLATFORM=xbc lokalize” did not work.
“env -u DISPLAY_WAYLAND lokalize” did not work either (idea from https://www.reddit.com/r/swaywm/comments/jivv8n/comment/ga90583/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button).
No idea where to set “-platform xbc”, but I am guessing that if the options above did not work this one will not help either. Feels like with or without XWayland, Localize repaints poorly in a Wayland session.
Having X11 in Plasma 6 seems like it is not an option (based on https://fedoraproject.org/wiki/Changes/KDE_Plasma_6#Feedback).
I‘m sad.
Comment 43 Heimen Stoffels 2024-03-09 15:24:59 UTC
Still having this issue as well. I'm waiting for Plasma 6 and all of its apps to land on Tumbleweed, but I'm not holding my breath for this to be actually fixed.
Comment 44 Vincenzo Reale 2024-03-09 15:32:43 UTC
After Plasma 6.0 upgrade, I removed the environment variable.
It seems that the problem has been fixed.
Comment 45 Adrián Chaves (Gallaecio) 2024-03-09 15:57:58 UTC
I am on an up-to-date Arch Linux, and the last upgrade brought Plasma 6 in and forced Wayland, which is how I found out about this issue with Lokalize.
Comment 46 alberic89 2024-03-09 16:32:19 UTC
(In reply to Adrián Chaves (Gallaecio) from comment #42)
> “QT_QPA_PLATFORM=xbc lokalize” did not work.
> “env -u DISPLAY_WAYLAND lokalize” did not work either (idea from
> https://www.reddit.com/r/swaywm/comments/jivv8n/comment/ga90583/
> ?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=s
> hare_button).
> No idea where to set “-platform xbc”, but I am guessing that if the options
> above did not work this one will not help either. Feels like with or without
> XWayland, Localize repaints poorly in a Wayland session.
> Having X11 in Plasma 6 seems like it is not an option (based on
> https://fedoraproject.org/wiki/Changes/KDE_Plasma_6#Feedback).
> I‘m sad.

First, be sure that you try `QT_QPA_PLATFORM=xcb lokalize` and not `QT_QPA_PLATFORM=xbc lokalize`
It works on my machine™ (Debian 12 Gnome).
If it works, you can also add the line `export QT_QPA_PLATFORM=xcb` at the start of your `.profile` file.
Another option is to edit your lokalize's desktop file to run `QT_QPA_PLATFORM=xcb lokalize` rather than just `lokalize` (for this, DuckDuckGo is your friend !).

If it doesn't work, try to launch `lokalize -platform xcb` rather than just `lokalize`.
Hope this help.
Comment 47 Vincenzo Reale 2024-03-09 16:34:00 UTC
(In reply to Adrián Chaves (Gallaecio) from comment #45)
> I am on an up-to-date Arch Linux, and the last upgrade brought Plasma 6 in
> and forced Wayland, which is how I found out about this issue with Lokalize.

Yes, you're right.
It seems I still have something forcing xcb for lokalize.
Be aware that the right platform is xcb not xbc.
Comment 48 Adrián Chaves (Gallaecio) 2024-03-10 09:00:59 UTC
Using “QT_QPA_PLATFORM=xcb lokalize” or “lokalize -platform xcb” does not make a difference to me, the behavior is the same as with plain “lokalize”, where eventually something does not repaint. In fact, it’s a bit weirder than “does not repaint”, it is like a constant, ~1-second flickering between 2 painting states, some old one, and the one that should be.

I tried to record this with OBS Studio. But I couldn’t. It turns out, while OBS Studio is recording, the issue does not happen. It feels like OBS Studio forces the latest, right painting. It’s a nasty workaround, but it beats the months it would take me to fix this issue myself.
Comment 49 Xavier Besnard 2024-09-10 19:48:07 UTC
Issue already present in Kubuntu 24.10 (Dev), under a wayland session and Plasma 6.1.4.:
* Some parts are not repainted,
* Sometimes lokalize crashed with an unexpected closure on the Wayland session.

Feel free to contact me for further detailed information.
So, translating KDE in French under a X11 session.
Regards. Xavier
Comment 50 Bug Janitor Service 2024-10-20 23:08:12 UTC
A possibly relevant merge request was started @ https://invent.kde.org/sdk/lokalize/-/merge_requests/163