GtkGLArea appears capped at 60 FPS

Hello everyone :slight_smile:

I’m trying to combine GTK with OpenGL and I could use some help with an issue I’m seeing.

I’m using a 120Hz screen but I’m struggling to reach 120 fps (or exceed 60fps for that matter) in my GtkGLArea code. I’d like to get continuous rendering at full refresh rate.

Here’s the minimal sample which demonstrates my issue:

My results from the program are:

  • GTK 3 on X11:
    • 278 ticks in 4.623727 = 60.124657 FPS
  • GTK 4 on X11:
    • 424 ticks in 7.062998 = 60.031165 FPS
  • GTK 3 on Wayland (sway):
    • 299 ticks in 4.979353 = 60.047962 FPS
  • GTK 4 on Wayland (sway):
    • 598 ticks in 4.977516 = 120.140247 FPS

I’m only able to reach 120fps using GTK4 under Wayland. Why not in other configurations? Am I doing something wrong?

My screen is properly configured for high refresh rate. I can get 120fps in glxgears, weston-simple-egl or firefox.

What am I missing?

GTK’s redraw rate is typically capped by the compositor. On X11, it needs to support frame synchronisation, and on Wayland it must send timing information. If the X11 compositor does not support frame synchronisation, then GTK uses a 60 fps source as a fallback.

GTK3 is likely less performant because GL rendering needs to integrate with the existing Cairo-based rendering pipeline; GTK4, on the other hand, uses GL natively for its internals, so the toolkit will take the texture backing the GLArea’s FBO and put it into the final pipeline as is.

In general, you’ll likely only ever achieve more than 60 fps with GTK4 on Wayland, or with a compositor like GNOME Shell on X11. GTK3 is simply not built for that.

Thank you @ebassi for the clarification! This is very helpful :pray: