Anvil drawing performance stuttery and laggy with winit and X11 backends on X11
When I run Anvil using the winit backend on X11 (Debian testing, Xfce, Intel integrated graphics), the graphics drawing is laggy and slow. For example, if I hit super+enter to launch a terminal, and then type into the terminal, the typed characters will display somewhere between 500ms and 1s after I type. If I run a command that causes a bunch of output on the terminal, the output is again delayed and stutters. I do not see this problem when running Anvil on a TTY with the udev backend. (The X11 backend does not work for me; will report that issue separately.)
A bisect led me to this (fairly old) commit as the problem:
commit 11f6ce65dd2084106179218b16c0f4b062a3ff3b
Author: Christian Meissl <[email protected]>
Date: Mon Jan 6 23:05:54 2025 +0100
anvil: update the primary scan-out output before presentation feedback
the presentation feedback is calculated using the primary scan-out output,
so we have to make sure we have the correct one to not introduce an
unnecessary delay during client startup and output migration.
anvil/src/state.rs | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
anvil/src/udev.rs | 4 +++-
2 files changed, 64 insertions(+), 29 deletions(-)
Here's the Anvil output for the session (built from the offending commit):
2026-01-20T00:16:33.159001Z INFO anvil: Starting anvil with winit backend
2026-01-20T00:16:33.159905Z INFO backend_winit: smithay::backend::winit: Initializing a winit backend
2026-01-20T00:16:33.193493Z INFO backend_winit: winit::platform_impl::linux::x11::window: Guessed window scale factor: 2.3333333333333335
2026-01-20T00:16:33.262985Z INFO backend_winit: smithay::backend::egl::display: Successfully selected EGL platform: PLATFORM_X11_KHR window=109051908
2026-01-20T00:16:33.328395Z INFO backend_winit: smithay::backend::egl::display: EGL Initialized window=109051908
2026-01-20T00:16:33.328494Z INFO backend_winit: smithay::backend::egl::display: EGL Version: (1, 5) window=109051908
2026-01-20T00:16:33.328601Z INFO backend_winit: smithay::backend::egl::display: Supported EGL display extensions: ["EGL_ANDROID_blob_cache", "EGL_ANDROID_native_fence_sync", "EGL_CHROMIUM_sync_control", "EGL_ANGLE_sync_control_rate", "EGL_EXT_buffer_age", "EGL_EXT_config_select_group", "EGL_EXT_create_context_robustness", "EGL_EXT_image_dma_buf_import", "EGL_EXT_image_dma_buf_import_modifiers", "EGL_EXT_protected_content", "EGL_EXT_query_reset_notification_strategy", "EGL_EXT_surface_compression", "EGL_EXT_swap_buffers_with_damage", "EGL_IMG_context_priority", "EGL_KHR_cl_event2", "EGL_KHR_config_attribs", "EGL_KHR_context_flush_control", "EGL_KHR_create_context", "EGL_KHR_create_context_no_error", "EGL_KHR_fence_sync", "EGL_KHR_get_all_proc_addresses", "EGL_KHR_gl_colorspace", "EGL_KHR_gl_renderbuffer_image", "EGL_KHR_gl_texture_2D_image", "EGL_KHR_gl_texture_3D_image", "EGL_KHR_gl_texture_cubemap_image", "EGL_KHR_image", "EGL_KHR_image_base", "EGL_KHR_image_pixmap", "EGL_KHR_no_config_context", "EGL_KHR_partial_update", "EGL_KHR_reusable_sync", "EGL_KHR_surfaceless_context", "EGL_KHR_swap_buffers_with_damage", "EGL_EXT_pixel_format_float", "EGL_KHR_wait_sync", "EGL_MESA_configless_context", "EGL_MESA_gl_interop", "EGL_MESA_image_dma_buf_export", "EGL_MESA_query_driver", "EGL_MESA_x11_native_visual_id", "EGL_NOK_texture_from_pixmap", ""] window=109051908
2026-01-20T00:16:33.329725Z INFO backend_winit:egl:egl_context: smithay::backend::egl::display: Selected color format: PixelFormat { hardware_accelerated: true, color_bits: 24, alpha_bits: 8, depth_bits: 24, stencil_bits: 8, stereoscopy: false, multisampling: None, srgb: false } window=109051908 platform="PLATFORM_X11_KHR" version=(1, 5)
2026-01-20T00:16:33.332939Z INFO backend_winit:egl:egl_context: smithay::backend::egl::context: EGL context created priority=Some(Medium) window=109051908 platform="PLATFORM_X11_KHR" version=(1, 5) ptr=94865647160688
2026-01-20T00:16:33.335748Z INFO backend_winit:egl:egl_context:renderer_gles2: smithay::backend::renderer::gles: Initializing OpenGL ES Renderer window=109051908 platform="PLATFORM_X11_KHR" version=(1, 5) ptr=94865647160688
2026-01-20T00:16:33.335844Z INFO backend_winit:egl:egl_context:renderer_gles2: smithay::backend::renderer::gles: GL Version: "OpenGL ES 3.2 Mesa 25.3.3-1" window=109051908 platform="PLATFORM_X11_KHR" version=(1, 5) ptr=94865647160688
2026-01-20T00:16:33.335888Z INFO backend_winit:egl:egl_context:renderer_gles2: smithay::backend::renderer::gles: GL Vendor: "Intel" window=109051908 platform="PLATFORM_X11_KHR" version=(1, 5) ptr=94865647160688
2026-01-20T00:16:33.335926Z INFO backend_winit:egl:egl_context:renderer_gles2: smithay::backend::renderer::gles: GL Renderer: "Mesa Intel(R) Iris(R) Xe Graphics (RPL-P)" window=109051908 platform="PLATFORM_X11_KHR" version=(1, 5) ptr=94865647160688
2026-01-20T00:16:33.335959Z INFO backend_winit:egl:egl_context:renderer_gles2: smithay::backend::renderer::gles: Supported GL Extensions: ["GL_EXT_blend_minmax", "GL_EXT_multi_draw_arrays", "GL_EXT_texture_filter_anisotropic", "GL_EXT_texture_compression_s3tc", "GL_EXT_texture_compression_dxt1", "GL_EXT_texture_compression_rgtc", "GL_EXT_texture_format_BGRA8888", "GL_OES_compressed_ETC1_RGB8_texture", "GL_OES_depth24", "GL_OES_element_index_uint", "GL_OES_fbo_render_mipmap", "GL_OES_mapbuffer", "GL_OES_rgb8_rgba8", "GL_OES_standard_derivatives", "GL_OES_stencil8", "GL_OES_texture_3D", "GL_OES_texture_float", "GL_OES_texture_float_linear", "GL_OES_texture_half_float", "GL_OES_texture_half_float_linear", "GL_OES_texture_npot", "GL_OES_vertex_half_float", "GL_EXT_draw_instanced", "GL_EXT_texture_sRGB_decode", "GL_OES_EGL_image", "GL_OES_depth_texture", "GL_AMD_performance_monitor", "GL_OES_packed_depth_stencil", "GL_EXT_texture_type_2_10_10_10_REV", "GL_NV_conditional_render", "GL_OES_get_program_binary", "GL_APPLE_texture_max_level", "GL_EXT_discard_framebuffer", "GL_EXT_read_format_bgra", "GL_EXT_texture_storage", "GL_NV_pack_subimage", "GL_NV_texture_barrier", "GL_EXT_frag_depth", "GL_NV_fbo_color_attachments", "GL_OES_EGL_image_external", "GL_OES_EGL_sync", "GL_OES_vertex_array_object", "GL_OES_viewport_array", "GL_ANGLE_pack_reverse_row_order", "GL_ANGLE_texture_compression_dxt3", "GL_ANGLE_texture_compression_dxt5", "GL_EXT_occlusion_query_boolean", "GL_EXT_robustness", "GL_EXT_sRGB", "GL_EXT_texture_rg", "GL_EXT_unpack_subimage", "GL_NV_draw_buffers", "GL_NV_read_buffer", "GL_NV_read_depth", "GL_NV_read_depth_stencil", "GL_NV_read_stencil", "GL_APPLE_sync", "GL_EXT_draw_buffers", "GL_EXT_instanced_arrays", "GL_EXT_map_buffer_range", "GL_EXT_shadow_samplers", "GL_KHR_debug", "GL_KHR_robustness", "GL_KHR_texture_compression_astc_ldr", "GL_NV_generate_mipmap_sRGB", "GL_NV_pixel_buffer_object", "GL_OES_depth_texture_cube_map", "GL_OES_required_internalformat", "GL_OES_surfaceless_context", "GL_EXT_color_buffer_float", "GL_EXT_debug_label", "GL_EXT_sRGB_write_control", "GL_EXT_separate_shader_objects", "GL_EXT_shader_framebuffer_fetch", "GL_EXT_shader_group_vote", "GL_EXT_shader_implicit_conversions", "GL_EXT_shader_integer_mix", "GL_EXT_tessellation_point_size", "GL_EXT_tessellation_shader", "GL_INTEL_conservative_rasterization", "GL_INTEL_performance_query", "GL_ANDROID_extension_pack_es31a", "GL_EXT_base_instance", "GL_EXT_compressed_ETC1_RGB8_sub_texture", "GL_EXT_copy_image", "GL_EXT_draw_buffers_indexed", "GL_EXT_draw_elements_base_vertex", "GL_EXT_gpu_shader5", "GL_EXT_multi_draw_indirect", "GL_EXT_polygon_offset_clamp", "GL_EXT_primitive_bounding_box", "GL_EXT_render_snorm", "GL_EXT_shader_io_blocks", "GL_EXT_texture_border_clamp", "GL_EXT_texture_buffer", "GL_EXT_texture_cube_map_array", "GL_EXT_texture_norm16", "GL_EXT_texture_view", "GL_KHR_blend_equation_advanced", "GL_KHR_blend_equation_advanced_coherent", "GL_KHR_context_flush_control", "GL_KHR_robust_buffer_access_behavior", "GL_NV_image_formats", "GL_NV_shader_noperspective_interpolation", "GL_OES_copy_image", "GL_OES_draw_buffers_indexed", "GL_OES_draw_elements_base_vertex", "GL_OES_gpu_shader5", "GL_OES_primitive_bounding_box", "GL_OES_sample_shading", "GL_OES_sample_variables", "GL_OES_shader_io_blocks", "GL_OES_shader_multisample_interpolation", "GL_OES_tessellation_point_size", "GL_OES_tessellation_shader", "GL_OES_texture_border_clamp", "GL_OES_texture_buffer", "GL_OES_texture_cube_map_array", "GL_OES_texture_stencil8", "GL_OES_texture_storage_multisample_2d_array", "GL_OES_texture_view", "GL_EXT_blend_func_extended", "GL_EXT_buffer_storage", "GL_EXT_float_blend", "GL_EXT_geometry_point_size", "GL_EXT_geometry_shader", "GL_EXT_shader_samples_identical", "GL_EXT_texture_sRGB_R8", "GL_KHR_no_error", "GL_KHR_texture_compression_astc_sliced_3d", "GL_NV_fragment_shader_interlock", "GL_OES_EGL_image_external_essl3", "GL_OES_geometry_point_size", "GL_OES_geometry_shader", "GL_OES_shader_image_atomic", "GL_EXT_clear_texture", "GL_EXT_clip_cull_distance", "GL_EXT_conservative_depth", "GL_EXT_disjoint_timer_query", "GL_EXT_texture_compression_s3tc_srgb", "GL_MESA_shader_integer_functions", "GL_EXT_clip_control", "GL_EXT_color_buffer_half_float", "GL_EXT_memory_object", "GL_EXT_memory_object_fd", "GL_EXT_protected_textures", "GL_EXT_semaphore", "GL_EXT_semaphore_fd", "GL_EXT_texture_compression_bptc", "GL_EXT_texture_mirror_clamp_to_edge", "GL_KHR_parallel_shader_compile", "GL_NV_alpha_to_coverage_dither_control", "GL_EXT_EGL_image_storage", "GL_EXT_shader_framebuffer_fetch_non_coherent", "GL_EXT_texture_shadow_lod", "GL_INTEL_blackhole_render", "GL_MESA_framebuffer_flip_y", "GL_NV_compute_shader_derivatives", "GL_EXT_demote_to_helper_invocation", "GL_EXT_depth_clamp", "GL_EXT_texture_query_lod", "GL_MESA_sampler_objects", "GL_EXT_EGL_image_storage_compression", "GL_EXT_texture_storage_compression", "GL_MESA_bgra", "GL_MESA_texture_const_bandwidth", "GL_EXT_shader_clock", ""] window=109051908 platform="PLATFORM_X11_KHR" version=(1, 5) ptr=94865647160688
2026-01-20T00:16:33.349367Z INFO new: smithay::output: Creating new Output name="winit" name="winit" physical=PhysicalProperties { size: Size<smithay::utils::geometry::Raw> { w: 0, h: 0 }, subpixel: Unknown, make: "Smithay", model: "Winit" }
2026-01-20T00:16:33.349487Z INFO smithay::wayland::output: Creating new wl_output output="winit"
2026-01-20T00:16:33.351325Z INFO smithay::wayland::socket: Created new socket name=Some("wayland-1")
2026-01-20T00:16:33.351406Z INFO anvil::state: Listening on wayland socket name="wayland-1"
2026-01-20T00:16:33.351682Z INFO input_seat:add_keyboard:input_keyboard: smithay::input::keyboard: Initializing a xkbcommon handler with keymap query name="winit" xkb_config=XkbConfig { rules: "", model: "", layout: "", variant: "", options: None } repeat_delay=200 repeat_rate=25
2026-01-20T00:16:33.355879Z INFO input_seat:add_keyboard:input_keyboard: smithay::input::keyboard: Loaded Keymap name="English (US)" name="winit" xkb_config=XkbConfig { rules: "", model: "", layout: "", variant: "", options: None } repeat_delay=200 repeat_rate=25
2026-01-20T00:16:33.356995Z INFO smithay::xwayland::xserver: spawning XWayland instance
2026-01-20T00:16:33.360381Z INFO anvil::winit: Initialization completed, starting the main loop.
2026-01-20T00:16:34.399388Z INFO anvil::input_handler: Starting program cmd="weston-terminal"
could not load cursor 'dnd-copy'
could not load cursor 'dnd-none'
Unknown OSC escape code 666, text vte.shell.postexec=0
Unknown OSC escape code 666, text vte.shell.precmd!
Unknown parameter: ?2004
Unknown parameter: ?2004
Unknown OSC escape code 133, text C
Unknown OSC escape code 666, text vte.shell.preexec!
Unknown OSC escape code 666, text vte.shell.postexec=0
Unknown OSC escape code 666, text vte.shell.precmd!
Unknown parameter: ?2004
Unknown parameter: ?2004
Unknown OSC escape code 133, text C
Unknown OSC escape code 666, text vte.shell.preexec!
Unknown OSC escape code 666, text vte.shell.postexec=0
Unknown OSC escape code 666, text vte.shell.precmd!
Unknown parameter: ?2004
Unknown parameter: ?2004
Unknown OSC escape code 133, text C
Unknown OSC escape code 666, text vte.shell.preexec!
Unknown OSC escape code 666, text vte.shell.postexec=0
Unknown OSC escape code 666, text vte.shell.precmd!
Unknown parameter: ?2004
Unknown parameter: ?2004
Unknown OSC escape code 133, text C
Unknown OSC escape code 666, text vte.shell.preexec!
Unknown OSC escape code 666, text vte.shell.postexec=0
Unknown OSC escape code 666, text vte.shell.precmd!
Unknown parameter: ?2004
Please let me know if there is any other info I can provide.
This also happens with the X11 backend, now that I've gotten it working properly on my hardware.
Huh, not sure if the bisect was incorrect somehow, but I managed to "fix" this by modifying this line to reduce the throttle duration. It was set to 1 second; I reduced it down to 16ms and that fixes the issue. I tried a few other values in between, to the tune of a few hundred milliseconds, but those gave me the same laggy rendering.
Not sure if that's the correct fix, and it's strange why 1 second doesn't impact the udev backend. (16ms also seems to be ok for the udev backend, at least...)
That throttle value is for windows not currently being drawn, which just points to a bug in anvils windowed backends setting their fake output as the active one.
Can you elaborate on that a bit? Sorry, I don't understand what kind of bug you're talking about. As I'm writing my own compositor and basing it on anvil, I would like the windowed backends to work well for testing purposes, but I'd rather not change that throttle since it would affect the udev backend as well. Happy to submit a PR for anvil to fix the issue if I can find it, so others don't run into this too.
I have the same issue. My laptop has Intel i7 1260P, which is similar to what @kelnos has (https://github.com/Smithay/smithay/issues/1909#issuecomment-3803246843). Whether the host session is X11 (e.g. xfce) or Wayland (e.g. KDE, COSMIC) doesn't seem to matter.
I also have this issue. Affects all windows (Wayland and XWayland) whilst running as a Winit app under wslg's wayland. Dropping the throttle duration also alleviated the issue.
Can confirm modifying the throttle duration or removing it "fixes" the issue on my system. I have tested on x11 and winit backends, where my host system is currently using Kwin (x11) on AMD discrete GPU. During my testing, it looks like this only affects windows rendered by non-vulkan sources; using konsole (with unset DISPLAY or unset WAYLAND_DISPLAY) or glxgears (x11 only) renders at ~1-2fps, while still without changes, vkcube works at full fps (60 as default here). I would assume this is because of vulkan somehow bypassing the normal render pipeline, but I am probably wrong. It may also be an issue with x11, but I am unsure because even when running konsole or vkcube with x11 WAYLAND_DISPLAY unset (force x11 rendering), they are both only at the 1-2fps. I would assume this might be because of x11 being copied / interpreted differently even when using vulkan rather than a direct shared memory buffer that I assume vulkan uses when able to be shared as a wayland surface...
I don't know much about how this compositor works or too much about how wayland is traditionally implemented, so sorry if I don't make any sense.
https://github.com/eirkkk/winland-Android
Can you elaborate on that a bit? Sorry, I don't understand what kind of bug you're talking about. As I'm writing my own compositor and basing it on anvil, I would like the windowed backends to work well for testing purposes, but I'd rather not change that throttle since it would affect the udev backend as well. Happy to submit a PR for anvil to fix the issue if I can find it, so others don't run into this too.
The only purpose of the throttle time is to lower the frequency of frame callbacks for non visible surfaces. In theory we could completely skip sending frame callbacks for obscured/offscreen surfaces. But some clients might get blocked in their main loop and become unresponsive when never receiving frame callbacks. The 1fps was taken as the minimum update rate from x11 iirc.
So what seems to happen is that the primary scan-out output never matches the embedded output leaving frame callbacks at this minimum rate.