Incomplete screen updates in VSCode when GLX_EXT_buffer_age is unsupported
Affected version
Ubuntu 22.04 + Mutter 42.5-0ubuntu1 + Xorg 1:7.7+23ubuntu2
Ubuntu 23.04 + Mutter 44.0-2ubuntu4 + Xorg 1:7.7+23ubuntu2
The problem DOES NOT happen on Ubuntu 20.04 + Mutter 3.36.9-0ubuntu0.20.04.2 + Xorg 1:7.7+19ubuntu14
I've been able to reproduce the issue on Xorg, but not on Wayland (tried Wayland 2:22.1.1-1ubuntu0.5 on Ubuntu 22.04 and Wayland 2:22.1.8-1ubuntu1 on Ubuntu 23.04)
Bug summary
When selecting text using random quick mouse movements, one part of the selected text won't show up as selected (colored) although it was properly selected.
It seems it's a bit easier to reproduce the problem by adding some "lag" to the Desktop connection (i.e. it's easier to trigger the bug in a Virtual Machine than in the local computer)
It's also easier to notice the problem if you have OBS Studio running, so you can add different sources, to show that the problem seems to happen only on XSHM (X Shared Memory)
Steps to reproduce
The sequence is:
- install visual studio code (.deb or .tar.gz) and obs-studio (from apt)
- open both vscode and obs. Load some text in vscode.
- add the following sources in obs: Screen Capture (XSHM) Windows Capture (XComposite)
- start recording
- randomly select the text in vscode using quick mouse movements: after some attempts, you should trigger the bug that shows the wrong selection in Screen Capture. Window Capture is correct.
What happened
The attached image shows the problem. You can see that the mouse cursor is in the 3rd paragraph in the middle of the word "master-builder", but the colored selection only shows up to the end of the second paragraph. If you check the OBS recording, which is capturing using PipeWire, it shows the proper text selection.
What did you expect to happen
The proper piece of text shows as selected
Relevant logs, screenshots, screencasts etc.
You actually don't need OBS to reproduce the problem. If you just "randomly select the text in vscode using quick mouse movements" you can still reproduce the problem, but OBS makes it easier for you to realize that the problem has been reproduced, because if you have this XComposite (or PipeWire) source being captured, you will see that the "selection" in vscode will be different than what's shown in XComposite (OBS), and XComposite is actually the correct one.
When the problem is reproduced (and there's a missing piece of text showing as selected), and you just hover the mouse over the text (after having already released the mouse button and without clicking again), eventually the selection will "correct itself" and show the missing block as also selected.
I've tested several scenarios and I'm:
1 - Unable to reproduce the problem in a local laptop running Ubuntu 22.04 + Xorg + Gnome + OBS + Visual Studio
2 - Able to reproduce the problem in a VM running Ubuntu 22.04 + Xorg + Gnome + OBS + Visual Studio
3 - Unable to reproduce the problem in a VM running Ubuntu 22.04 + Wayland + Gnome + OBS + Visual Studio
4 - Able to reproduce the problem in a VM running Ubuntu 23.04 + Xorg + Gnome + OBS + Visual Studio
5 - Unable to reproduce the problem in a VM running Ubuntu 23.04 + Wayland + Gnome + OBS + Visual Studio
My gut feeling says the "lag" added by remote access contributes to the issue and I guess it might still be possible to reproduce it with Wayland, but it seems much harder.
I also tried reproducing the issue with Xorg + Lxqt and Xorg + xfce and I'm unable to reproduce the problem (none of them use Mutter)
I did enable some debug by adding "MUTTER_DEBUG=all" in /etc/environment and this is all I see during the issue:
https://pastebin.ubuntu.com/p/tS8gCq9Nhj/
The "STACK" lines are logged when I'm selecting the text, and then I release the mouse and stop the selection movement (leaving the wrong block showing as selected -- with a missing piece) and then only those "BACKEND" messages are logged. Even if/when the selection "auto-corrects itself" after several seconds of me hovering the mouse again, nothing else gets logged.
Another important information is that by adding 'CLUTTER_PAINT=disable-clipped-redraws' to /etc/environment and rebooting the Desktop, seems to workaround the issue.