Bug 415839 - Resizing apps results in flickering or controls jumping around
Summary: Resizing apps results in flickering or controls jumping around
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: core (show other bugs)
Version: 5.17.90
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Vlad Zahorodnii
URL: https://phabricator.kde.org/D26914
Keywords:
: 413744 417719 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-01-03 12:52 UTC by postix
Modified: 2020-02-18 07:43 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.18.0
vlad.zahorodnii: Wayland-
vlad.zahorodnii: X11+
vlad.zahorodnii: ReviewRequest+


Attachments
Screenrecording of the Systemsettings being resized. (2.14 MB, video/mp4)
2020-01-03 12:52 UTC, postix
Details
Screenrecording of Dolphin being resized. (2.60 MB, video/mp4)
2020-01-03 12:53 UTC, postix
Details
Screenrecording of the Systemsettings being resized. (2.01 MB, video/mp4)
2020-01-03 12:55 UTC, postix
Details
Screenrecording of Dolphin being resized. (2.17 MB, video/mp4)
2020-01-03 12:57 UTC, postix
Details
An example of a bad window pixmap (27.52 KB, image/png)
2020-01-16 14:17 UTC, Vlad Zahorodnii
Details
Potential fix (7.51 KB, patch)
2020-01-24 23:54 UTC, Vlad Zahorodnii
Details
Screenrecording after applying the patch. (1.55 MB, video/mp4)
2020-01-25 16:52 UTC, postix
Details
Screenrecording before applying the patch. (1.85 MB, video/mp4)
2020-01-25 17:24 UTC, postix
Details
Screenrecording after applying the patch of D26914. (1.87 MB, video/mp4)
2020-01-25 18:08 UTC, postix
Details
Screenshot of a black part. (281.05 KB, image/png)
2020-01-25 20:03 UTC, postix
Details
Still present in 5.18.0 (3.72 MB, video/x-flv)
2020-02-17 20:53 UTC, Michał Dybczak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description postix 2020-01-03 12:52:56 UTC
Created attachment 124868 [details]
Screenrecording of the Systemsettings being resized.

If you resize an app like Dolphin or the Systemsettings, the control positions are updated frequently resulting in an annoying hopping and flickering like in the two sample screen recordings. 

I can't remember to have seen such flickering on other systems like Windows.

SOFTWARE/OS VERSIONS
Operating System: Manjaro Linux 
KDE Plasma Version: 5.17.4
KDE Frameworks Version: 5.66.0
Qt Version: 5.14.0
Kernel Version: 5.4.7-1-MANJARO
Comment 1 postix 2020-01-03 12:53:24 UTC
Created attachment 124869 [details]
Screenrecording of Dolphin being resized.
Comment 2 postix 2020-01-03 12:55:51 UTC
Created attachment 124870 [details]
Screenrecording of the Systemsettings being resized.

x264 version instead of x265 for compatibility reasons.
Comment 3 postix 2020-01-03 12:57:09 UTC
Created attachment 124871 [details]
Screenrecording of Dolphin being resized.

x264 instead of x265 for compatibility reasons.
Comment 4 postix 2020-01-03 13:18:27 UTC
*** Bug 413744 has been marked as a duplicate of this bug. ***
Comment 5 Vlad Zahorodnii 2020-01-16 14:12:16 UTC
Heh, I was looking into this issue just a few days ago and so far it seems like kwin gets bad window pixmaps. Not sure why. Perhaps we've messed up somewhere with synchronization or maybe clients are doing weird things...
Comment 6 Vlad Zahorodnii 2020-01-16 14:17:39 UTC
Created attachment 125172 [details]
An example of a bad window pixmap

Client-side drop-shadow is cut off on the right border.
Comment 7 Vlad Zahorodnii 2020-01-24 23:54:39 UTC
Created attachment 125382 [details]
Potential fix

I would be very grateful if someone could test my patch.
Comment 8 postix 2020-01-25 11:07:19 UTC
(In reply to Vlad Zahorodnii from comment #7)
> Created attachment 125382 [details]
> Potential fix
> 
> I would be very grateful if someone could test my patch.

If you can tell what and how I can compile it, I may give it a try. :)
Comment 9 Vlad Zahorodnii 2020-01-25 11:17:27 UTC
You would have to download 5.18 tarball and apply the patch to it, then usual cmake and make sequence. You can run bin/kwin_x11 from build directory after that, no need to run make install.
Comment 10 postix 2020-01-25 11:59:01 UTC
(In reply to Vlad Zahorodnii from comment #9)
> You would have to download 5.18 tarball and apply the patch to it, then
> usual cmake and make sequence. You can run bin/kwin_x11 from build directory
> after that, no need to run make install.

I compiled and build it successfully, but when I try to start it it says:

> ./bin/kwin_x11 
> FATAL ERROR: could not instantiate the platform plugin

Any idea? ;)
Comment 11 Vlad Zahorodnii 2020-01-25 12:43:32 UTC
Urgh, kwin is not able to find the x11 platform plugin. I guess you could run make install (make sure that you've provided right CMAKE_INSTALL_PREFIX to the cmake command) and after you're done testing re-install kwin package (sudo pacman -Sy kwin), it will be much faster than trying to figure out why we can't locate the right plugin.
Comment 12 postix 2020-01-25 16:52:18 UTC
Created attachment 125403 [details]
Screenrecording after applying the patch.

(In reply to Vlad Zahorodnii from comment #11)
> Urgh, kwin is not able to find the x11 platform plugin. I guess you could
> run make install (make sure that you've provided right CMAKE_INSTALL_PREFIX
> to the cmake command) and after you're done testing re-install kwin package
> (sudo pacman -Sy kwin), it will be much faster than trying to figure out why
> we can't locate the right plugin.

I tested it in a virtual machine and the result is way better than before! Thanks! :)

Only a tiny remark: When I resize the kinfocenter window, you can see the systemsettings window in the background to wobble a little bit. I'm not sure if this is an effect of the graphics driver stuff in the virtual machine or if it were there before or if it comes from your patch. ;)
Comment 13 postix 2020-01-25 16:57:08 UTC
Two more notes: 
* The text of the Systemsettings still shakes a little when the window becomes resized.
* There was once a short case in the screen recording above where part of the system setting's window turned black for a glimpse while resizing.
Comment 14 Vlad Zahorodnii 2020-01-25 17:05:13 UTC
(In reply to Postix from comment #12)
> Only a tiny remark: When I resize the kinfocenter window, you can see the
> systemsettings window in the background to wobble a little bit. I'm not sure
> if this is an effect of the graphics driver stuff in the virtual machine or
> if it were there before or if it comes from your patch. ;)
Please check whether text shakes even without my patch, it is quite important.
Comment 15 Vlad Zahorodnii 2020-01-25 17:13:55 UTC
(In reply to Postix from comment #13)
> * There was once a short case in the screen recording above where part of
> the system setting's window turned black for a glimpse while resizing.
Most likely because it took too long for System Settings to repaint its contents.
Comment 16 Vlad Zahorodnii 2020-01-25 17:17:19 UTC
Also, please use the most recent version of the patch.
Comment 17 postix 2020-01-25 17:19:02 UTC
(In reply to Vlad Zahorodnii from comment #14)
> (In reply to Postix from comment #12)
> > Only a tiny remark: When I resize the kinfocenter window, you can see the
> > systemsettings window in the background to wobble a little bit. I'm not sure
> > if this is an effect of the graphics driver stuff in the virtual machine or
> > if it were there before or if it comes from your patch. ;)
> Please check whether text shakes even without my patch, it is quite
> important.

I guessed so, that's why (In reply to Vlad Zahorodnii from comment #16)
> Also, please use the most recent version of the patch.

Is this https://bugs.kde.org/attachment.cgi?id=125382 the most recent one?
Comment 18 postix 2020-01-25 17:21:20 UTC
(In reply to Vlad Zahorodnii from comment #16)
> Also, please use the most recent version of the patch.

I guess it's the diff from phabricator. I will check it out later!
Comment 19 postix 2020-01-25 17:24:02 UTC
Created attachment 125404 [details]
Screenrecording before applying the patch.

Just for reference, here's a screen recording before applying the patch. The shaking of the text of the systemsettings in the background appears here as well if you look closely.
Comment 20 Vlad Zahorodnii 2020-01-25 17:28:18 UTC
(In reply to Postix from comment #18)
> I guess it's the diff from phabricator. I will check it out later!
Yes, that one.

(In reply to Postix from comment #19)
> Just for reference, here's a screen recording before applying the patch. The
> shaking of the text of the systemsettings in the background appears here as
> well if you look closely.
Oh, that's "great!"
Comment 21 postix 2020-01-25 18:08:33 UTC
Created attachment 125407 [details]
Screenrecording after applying the patch of D26914.

Here's the recording of the latest patch.

* For the KInfocenter you see a tearing between the window title bar and the window itself
* If the KInfocenter is resized in front of the KSystemsettings there's a lot of tearing and wobbling in the Systemsettings
* Sometimes there are still frames missing where the window turns black while resizing

You may notice more if you look at the recording.
Comment 22 Vlad Zahorodnii 2020-01-25 19:25:35 UTC
(In reply to Postix from comment #21)
> * If the KInfocenter is resized in front of the KSystemsettings there's a
> lot of tearing and wobbling in the Systemsettings
It seems to be unrelated.

> * Sometimes there are still frames missing where the window turns black
> while resizing
Are those frames completely black? or only some parts?
Comment 23 postix 2020-01-25 20:03:52 UTC
Created attachment 125412 [details]
Screenshot of a black part.

(In reply to Vlad Zahorodnii from comment #22)
> > * Sometimes there are still frames missing where the window turns black
> > while resizing
> Are those frames completely black? or only some parts?

Only some parts as in the screenshot -- but as I just noticed, this was already the case before the patch. ;) 
So the patch neither made it worse nor better.
Comment 24 postix 2020-01-26 19:47:07 UTC
Vlad, I hope you target 5.18? :)
Comment 25 Vlad Zahorodnii 2020-01-27 10:54:46 UTC
Depends on how the code review will go.
Comment 26 Vlad Zahorodnii 2020-02-03 12:04:39 UTC
Git commit 56d5f3a4f61ce00a1abc4d3c315dcbe15c22efdb by Vlad Zahorodnii.
Committed on 03/02/2020 at 11:56.
Pushed by vladz into branch 'Plasma/5.18'.

[x11] Fix visual artifacts during interactive resize

Summary:
When a window is being interactively resized, its contents may jump. The
reason why that happens is because KWin renders partially resized client
window. Composite extension spec says that a window will get a new pixmap
each time it is resized or mapped. This applies to the frame window, but
not to the client window itself. If the client window is resized,
off-screen storage for the frame window won't be reallocated. Therefore,
KWin may render partially resized client window if the client doesn't
attempt to be in sync with our rendering loop. Currently, the only way
to do that is to use extended frame counters, which are not supported by
KWin.

So, in order to fix visual artifacts during interactive resize, we need
somehow forcefully re-allocate off-screen storage for the frame window.
Unfortunately, Composite extension doesn't provide any request to do
that, so the only option we have is to resize the frame window.
FIXED-IN: 5.18.0

Reviewers: #kwin

Subscribers: davidedmundson, ngraham, alexde, fredrik, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26914

M  +11   -1    scene.cpp
M  +2    -1    scene.h
M  +1    -1    toplevel.cpp
M  +39   -13   x11client.cpp
M  +2    -0    x11client.h

https://commits.kde.org/kwin/56d5f3a4f61ce00a1abc4d3c315dcbe15c22efdb
Comment 27 Vlad Zahorodnii 2020-02-17 08:38:06 UTC
*** Bug 417637 has been marked as a duplicate of this bug. ***
Comment 28 Vlad Zahorodnii 2020-02-17 13:37:51 UTC
*** Bug 417719 has been marked as a duplicate of this bug. ***
Comment 29 Michał Dybczak 2020-02-17 20:53:42 UTC
Created attachment 126107 [details]
Still present in 5.18.0

This isn't fixed. This is how it looks on Plasma 5.18.0
Comment 30 Nate Graham 2020-02-18 03:55:15 UTC
This bugfix primarily improved the behavior for QWidgets apps, AFAIK. QML apps will need other fixes, as I understand it.
Comment 31 Vlad Zahorodnii 2020-02-18 07:36:58 UTC
(In reply to Michał Dybczak from comment #29)
> This isn't fixed. This is how it looks on Plasma 5.18.0
This issue can't be really fixed on X11. We can only work around some cases. If an application uses a graphics API such as OpenGL or Vulkan to draw user interface, then the client contents may still be rendered unsynchronized. For what it's worth, one of the reasons why we have "resize" effect is because resizing windows on X11 is lame.

I also would like to point out that such visual artifacts can't be seen on Wayland because "each frame is perfect."
Comment 32 Vlad Zahorodnii 2020-02-18 07:43:30 UTC
*** Bug 417637 has been marked as a duplicate of this bug. ***