GTK4 gtk_window_present takes seconds on i.MX8MP with GPU gl renderer

with a simple test - only a window w/o other widgets, the time takes by the gtk_window_present takes almost 10 sec, visibly by time shown up on display and measured by:
g_print("PRESENT START %lld ms\n", g_get_monotonic_time()/1000);
gtk_window_present(GTK_WINDOW(data));
g_print("PRESENT END %lld ms\n", g_get_monotonic_time()/1000);

The env setup used:
export XDG_RUNTIME_DIR=/run/user/0
export WAYLAND_DISPLAY=wayland-1
export GDK_BACKEND=wayland
export GSK_RENDERER=gl

the GPU used is from nxp i.mx8mp Vivante Galcore, and the app is build on yocto 5.0.
There is no error logged during test, except strace debug finding one call blocks for almost exactly the same duration as the UI delay:
[pid 2035] 17:48:12.421569
ioctl(11, _IOC(_IOC_NONE, 0x75, 0x30, 0)
<unfinished …>
[pid 2035] 17:48:21.898782
<… ioctl resumed> = 0 <9.477188>

If changing renderer to cairo, the window shows up almost immediately w/ very little delay, but we do need GPU support for our app.

We are looking for guidance on known issues, configuration or env variable changes, or fixes for GTK4/OpenGL startup latency.

Hi,

The real problem is not gtk itself, but the fact that OpenGL support on ARM chips is usually very bad or nonexistent. Mesa is probably falling back to its software renderer.

The Vulkan renderer should work much better (GSK_RENDERER=vulkan), have you already tried it? Be sure to use a recent gtk4 version, at least 4.20.

although the vulkan is in the list of supported renderer of GSK_RENDERER, but when I tried to use it by export GSK_RENDERER=vulkan and run my app (lti-test), I got:
(lti-test:1428): Gdk-CRITICAL **: 18:45:39.464: Vulkan: Loader Message: loader_validate_device_extensions: Device extension VK_KHR_image_format_list not supported by selected physical device or enabled layers.

(lti-test:1428): Gdk-CRITICAL **: 18:45:39.465: Vulkan: Loader Message: vkCreateDevice: Failed to validate extensions in list
Gsk-Message: 18:45:39.467: Failed to realize renderer of type ‘GskVulkanRenderer’ for surface ‘GdkWaylandToplevel’: Could not find a Vulkan device with the required features.

The default build version of GTK4 from my NXP BSP for yocto 5.0 is 4.14.1. I’m not sure even if I update this to later 4.20, assuming no conflict with other BSP settings, whether it will resolve the issue? Do you think the GTK4 version is relevant here?

Thanks,

There have been many improvements in the renderers since version 4.14, I don’t remember in details, but using a recent version may be interesting to try, if not too much hassle with dependencies.

Back in 4.14 there was a ngl renderer, which you could also give a try (at some point it was actually made the same as gl but I can’t remember if that was before or after 4.14).

There are also a few env variables like GDK_DEBUG that can tweak rendering options.

Some old gitlab issues: