Fix `wxGLCanvas` performance when using Wayland (PR #23554)

88 views
Skip to first unread message

VZ

unread,
May 17, 2023, 2:10:04 PM5/17/23
to wx-...@googlegroups.com, Subscribed

This should hopefully help with #23512, but I haven't actually tested it with Kicad itself (yet).

Note: when backporting to 3.2, the last commit should be omitted or constexpr in it changed.


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/23554

Commit Summary

  • fca2f53 Don't use wxGLCanvasEGL::m_readyToDraw for X11 windows
  • 4884727 Fix wxGLCanvasEGL refresh logic under Wayland
  • 31fa446 Add some tracing to wxGLCanvasEGL code

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23554@github.com>

VZ

unread,
May 18, 2023, 3:27:02 PM5/18/23
to wx-...@googlegroups.com, Push

@vadz pushed 3 commits.

  • 194a7be Improve wxGLCanvasEGL refresh logic under Wayland
  • f2214ff Don't draw on hidden X11 EGL windows
  • 54d44fc Add some tracing to wxGLCanvasEGL code


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23554/push/13684641367@github.com>

VZ

unread,
Jun 19, 2023, 3:21:28 PM6/19/23
to wx-...@googlegroups.com, Subscribed

There is not much time left for merging this and backporting it to 3.2 if we want this to be included in 3.2.3.

@imciner2 @kuon Please test this PR if you can.


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

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23554/c1597651605@github.com>

Nicolas Goy

unread,
Jun 20, 2023, 7:18:23 PM6/20/23
to wx-...@googlegroups.com, Subscribed

I'm sorry, I broke my leg and couldn't test this PR yet. It's on my list, I'll do it asap.


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

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23554/c1599703120@github.com>

Arti Zirk

unread,
Jul 24, 2023, 11:05:22 AM7/24/23
to wx-...@googlegroups.com, Subscribed

Hi @vadz, I have tested this PR by applying the patches to Arch Linux wxWindows 3.2.2.1 package. fca2f53 needed patch -F3 but other applied cleanly. I also built kicad-wayland that has patches that enable Wayland support. I am using Sway 1.8.1.

I can confirm that this PR fixes performance problems that happen when Cross-probing is enabled and one of the windows is hidden.

(Also KiCad under native Wayland is soo much smoother than under Xwayland)

If there is anything else I can build and test I will gladly help.


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

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23554/c1648088985@github.com>

VZ

unread,
Jul 24, 2023, 11:43:36 AM7/24/23
to wx-...@googlegroups.com, Subscribed

Great, thanks a lot for testing!

I'm going to merge this in master now and will cherry-pick it to 3.2 too.


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

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23554/c1648164837@github.com>

VZ

unread,
Jul 24, 2023, 4:16:25 PM7/24/23
to wx-...@googlegroups.com, Subscribed

Merged #23554 into master.


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

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23554/issue_event/9904312078@github.com>

Arti Zirk

unread,
Aug 22, 2023, 10:59:02 AM8/22/23
to wx-...@googlegroups.com, Subscribed

After thinking about this for a while I think I may have found a small oversight.
IsShownOnScreen() uses m_readyToDraw as one of the checks under Wayland. Before this PR, m_readyToDraw was set to true once after first wl_frame_callback_handler. After this PR now the m_readyToDraw is toggled after each frame.

IsShownOnScreen() probably shouldn't flap at 60hz?

I hacked it use gtk_window_is_visible() for IsShownOnScreen check and in my limited testing Kicad renders a bit better.

diff --git a/src/unix/glegl.cpp b/src/unix/glegl.cpp
index c35273caddaa..0f009e3f4fb8 100644
--- a/src/unix/glegl.cpp
+++ b/src/unix/glegl.cpp
@@ -697,12 +697,13 @@ bool wxGLCanvasEGL::SwapBuffers()
 bool wxGLCanvasEGL::IsShownOnScreen() const
 {
     wxDisplayInfo info = wxGetDisplayInfo();
+    GdkWindow* const window = GTKGetDrawingWindow();
     switch ( info.type )
     {
         case wxDisplayX11:
             return GetXWindow() && wxGLCanvasBase::IsShownOnScreen();
         case wxDisplayWayland:
-            return m_readyToDraw && wxGLCanvasBase::IsShownOnScreen();
+            return gtk_window_is_visible(window) && wxGLCanvasBase::IsShownOnScreen();
         default:
             return false;
     }


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

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23554/c1688358313@github.com>

VZ

unread,
Aug 24, 2023, 9:03:35 AM8/24/23
to wx-...@googlegroups.com, Subscribed

Thanks @artizirk, I think you're right and we shouldn't be using m_readyToDraw here, but I'm a bit confused as to how does it actually change anything for redrawing: we don't seem to use IsShownOnScreen() anywhere under Wayland (under X11 we use it in SwapBuffers()).

What am I missing here?


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

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23554/c1691635594@github.com>

ShalokShalom

unread,
Sep 24, 2023, 5:45:53 PM9/24/23
to wx-...@googlegroups.com, Subscribed

@vadz Open another issue for that?


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

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23554/c1732676686@github.com>

VZ

unread,
Sep 24, 2023, 6:15:11 PM9/24/23
to wx-...@googlegroups.com, Subscribed

@ShalokShalom Yes, you're right, we need to fix this. It looks easy, but I still don't understand how does it change anything for KiCad which only uses XWayland AFAIK.


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

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23554/c1732682102@github.com>

ShalokShalom

unread,
Sep 24, 2023, 6:53:27 PM9/24/23
to wx-...@googlegroups.com, Subscribed

They have a thread about Wayland support, and it looks like there is even an Arch package with it.


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

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23554/c1732689081@github.com>

Manolo-ES

unread,
Oct 27, 2023, 2:46:24 PM10/27/23
to wx-...@googlegroups.com, Subscribed

Sorry, I'm strongly against this PR (internally using eglSwapInterval). Other PRs I see affected are #23909 and #23512

Setting SwapInterval is a user decision, not a wx one. It may be good for some cases but not for others. See this Khronos wiki article and its discussion.
Be aware that any final user can override app's settings by directly selecting it at driver's configuration (some vendors provide it).

Any how, I think SwapInterval is a feature that wx should provide to the user.


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

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23554/c1783358566@github.com>

VZ

unread,
Oct 28, 2023, 1:06:20 PM10/28/23
to wx-...@googlegroups.com, Subscribed

@Manolo-ES I am not sure if you've followed the previous discussions and bug reports, but without this PR existing code working fine under the other platforms (Windows, Mac and even Linux with X11) makes the program completely unusable under Wayland, i.e. it's a fatal problem and not just something that can be ignored.

I don't think it's reasonable to require all wx programs using OpenGL to call eglSwapInterval() themselves and I think it's even less reasonable to expect all users of these programs to change some driver setting.


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

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/23554/c1783872378@github.com>

Reply all
Reply to author
Forward
0 new messages