Double buffer of wxGLCanvas appears to always be active and has lag (Issue #22142)

30 views
Skip to first unread message

gsxruk

unread,
Feb 19, 2022, 7:04:15 AM2/19/22
to wx-...@googlegroups.com, Subscribed

Describe the bug
In v3.1.5, the double buffer of wxGLCanvas always appears to be active even when it hasn't been requested. This behaviour is certainly different to that of v3.1.4.

Both v3.1.4 and v3.1.5 show signs of lag when double buffer is used. This is observed when resizing the window.

Expected vs observed behaviour
I admit I'm assuming I'm correct when I state the expected behaviour but I'm not 100% sure. One thing is for certain, the behaviour between v3.1.4 and v3.1.5 is different.

Expected:

  1. When double buffering is not requested, double buffering is not used and there is no need to call SwapBuffers of the wxGLCanvas to display the scene. The glFlush() command is all that is required.
  2. Double buffering does not show signs of lag during resize (at least when displaying a simple scene).

Note: v3.1.4 provides the expected behaviour described in (1) but both v3.1.4 and v3.1.5 show the lag in (2).

Observed:

  1. The call to SwapBuffers is required to display the scene even when double buffering is not requested.
  2. Double buffering shows signs of lag during resize and this is apparent even when double buffering is not requested. This is what led me to believe double buffering is always active.

Patch or snippet allowing to reproduce the problem
This problem can be reproduced using the OpenGL "Cube" sample with a few small incremental changes as follows:

Test 1 Changes (adds red background to the scene to show lag):

  1. Add the line glClearColor(1.0f, 0.0f, 0.0f, 1.0f); to the TestGLContext constructor just before the CheckGLError(); statement.

Test 2 Changes (disables DoubleBuffer):

  1. Add int attribList[] = { WX_GL_RGBA, 0 }; under the int stereoAttribList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_STEREO, 0 }; statement of MyFrame constructor.
  2. Amend the statement new TestGLCanvas(this, stereoWindow ? stereoAttribList : NULL); to read new TestGLCanvas(this, stereoWindow ? stereoAttribList : attribList); of the MyFrame constructor.

Test 3 Changes (removes SwapBuffers):

  1. Comment out SwapBuffers() from the TestGLCanvas::OnPaint function.

To Reproduce
Test 1 (shows lag in both v3.1.4 and v3.1.5):

  1. Make the changes described in "Test 1 Changes".
  2. Build the sample using v3.1.5.
  3. Launch the sample and resize the window.
  4. Observe the right and bottom edges of the background lag behind the window resize.
  5. Clean and build the sample using v3.1.4.
  6. Observe the right and bottom edges of the background lag behind the window resize.

Test 2 (shows lag in v3.1.5 only and that double buffer still seems to be active/v3.1.4 is not effected by this issue):

  1. Make the changes described in "Test 1 Changes" and "Test 2 Changes".
  2. Build the sample using v3.1.5.
  3. Launch the sample and resize the window.
  4. Observe the right and bottom edges of the background lag behind the window resize.
  5. Clean and build the sample using v3.1.4.
  6. Launch the sample and resize the window.
  7. Observe the scene is displayed and there is no lag during the resize.

Test 3 (shows SwapBuffers is required when double buffer is disabled in v3.1.5 and not v3.1.4):

  1. Make the changes described in "Test 1 Changes" and "Test 2 Changes" and "Test 3 Changes".
  2. Build the sample using v3.1.4.
  3. Launch the sample and resize the window.
  4. Observe the scene is displayed.
  5. Clean and build the sample using v3.1.5.
  6. Launch the sample.
  7. Observe the scene is not displayed.

Platform and version information

  • wxWidgets version you use: 3.1.5
  • wxWidgets port you use: wxGTK
  • OS and its version: Ubuntu 21.10
  • For wxGTK only, please specify GTK version: 3.24.30

Additional information
I ran a git bisect between v3.1.4 and v3.1.5 and the result is shown below.

7cd12a2bd6566b36be5579a370b52ac18f986863 is the first bad commit
commit 7cd12a2bd6566b36be5579a370b52ac18f986863
Author: Scott Talbert <s...@techie.net>
Date: Fri Aug 28 11:59:27 2020 -0400


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22142@github.com>

VZ

unread,
Feb 19, 2022, 8:46:55 AM2/19/22
to wx-...@googlegroups.com, Subscribed

7cd12a2 (Add EGL-based backend for wxGLCanvas, 2020-08-28) wasn't supposed to change the behaviour when not using Wayland, so if it did, this would be indeed a regression. And I guess you use X11 and not Wayland, because otherwise wxGLCanvas wouldn't work at all for you with 3.1.4, but, just to be sure, could you please confirm this?

cc @swt2c


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22142/1046022055@github.com>

gsxruk

unread,
Feb 19, 2022, 9:40:32 AM2/19/22
to wx-...@googlegroups.com, Subscribed

No. I'm using Wayland.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22142/1046032974@github.com>

VZ

unread,
Feb 19, 2022, 9:44:39 AM2/19/22
to wx-...@googlegroups.com, Subscribed

But 3.1.4 definitely didn't support OpenGL at all under Wayland, see https://github.com/wxWidgets/wxWidgets/blob/6cdaedd42ba59331b3dc4ead50e0bac76ae14c19/src/gtk/glcanvas.cpp#L164-L169

Do you use 3.1.5 with Wayland and 3.1.4 with X11 or am I missing something here?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22142/1046033747@github.com>

gsxruk

unread,
Feb 19, 2022, 9:54:24 AM2/19/22
to wx-...@googlegroups.com, Subscribed

Now you have mentioned it, I did remember having to use GDK_BACKEND=x11 when I used v3.1.4 originally under Ubuntu 21.04. But I haven't seen the error I got when using it with Ubuntu 21.10.

With Ubuntu 21.10, I started with wxWidgets v3.1.5 and observed this issue. I then downloaded v3.1.4 and tested that.

But I'm definitely using Wayland. I just switched to X11 and it worked exactly the same. The results were also the same as described in the initial text above.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22142/1046035764@github.com>

Scott Talbert

unread,
Feb 19, 2022, 2:51:37 PM2/19/22
to wx-...@googlegroups.com, Subscribed

Yeah, I can confirm that when using the EGL backend, disabling double buffering doesn't do anything (currently). It's not clear to me how to disable double buffering, though, or even if it is possible with EGL.

@gsxruk, if you would prefer to use the GLX backend, you can compile wxWidgets with configure --disable-glcanvasegl and you should see the 3.1.4 behavior. However, it won't work with Wayland (without forcing XWayland).


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22142/1046091727@github.com>

VZ

unread,
Sep 20, 2026, 4:56:04 PM (yesterday) Sep 20
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#22142)

With recent wx versions it's possible to use GLX implementation even in the builds with Wayland/EGL support by calling wxGLCanvas::PreferGLX() so you can do this if EGL really doesn't work for you without recompiling.

I don't think it's possible to avoid double buffering with EGL, the closest thing I can see is setting EGL_SWAP_BEHAVIOR to EGL_BUFFER_PRESERVED, but I haven't tried it.

I'm not sure if wx should, or could, do anything about it, but in any case it's not a regression.


Reply to this email directly, view it on GitHub, or unsubscribe.

Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22142/5752600139@github.com>

Reply all
Reply to author
Forward
0 new messages