Skip to content

Severe KWin display lag with VirGL acceleration since UTM 5.x #8197

Open
utmapp/vd_agent
#7

Description

@rearnsha

What happened?

Since upgrading from UTM 4.x to 5.x, my Kubuntu 24.04 VM experiences severe display lag under KDE Plasma/X11. Screen updates occur roughly once per second, despite glxgears reporting ~3700 FPS.

The lag begins after logging into KDE but is not apparent at the graphical login screen. Moving or resizing windows makes it particularly noticeable.

Configuration:

Host: Apple M4 Max, macOS 26.7.3, UTM 5.0.9

Guest: Kubuntu 24.04, X11, KWin 5.27.11

Mesa: 25.2.8

Display: virtio-gpu-gl-pci, VirGL acceleration

OpenGL: VirGL 2.1, GLX

Findings:

Suspending KWin compositing eliminates the lag.

Disabling KWin's blur and contrast effects makes no difference.

Setting KWIN_USE_BUFFER_AGE=0 completely resolves the lag while retaining accelerated OpenGL compositing.

This appears to be a regression introduced in UTM 5.x, potentially involving buffer-age reporting or damage tracking between KWin, VirGL and UTM.

UTM version

5.0.9

Mac and macOS version

MacBook M4 Max, OS 26.7.3

VM type

QEMU

Guest operating system

Ubuntu 24.04 AArch64

Did this work before?

Worked in 4.x

Where did you get UTM?

GitHub release or getutm.app

Logs

No response

VM configuration

Backend QEMU ConfigurationVersion 4 Display DownscalingFilter Linear DynamicResolution Hardware virtio-gpu-gl-pci NativeResolution UpscalingFilter Nearest Drive Identifier 184E6539-7CFD-41E4-A6A9-496ABB04A598 ImageType CD Interface USB InterfaceVersion 1 ReadOnly Identifier 565807B8-9F2F-4F63-8FC0-C74399917F59 ImageName 565807B8-9F2F-4F63-8FC0-C74399917F59.qcow2 ImageType Disk Interface VirtIO InterfaceVersion 1 ReadOnly Identifier 5349C857-DD6C-481C-A1B9-24181DF8F437 ImageName 5349C857-DD6C-481C-A1B9-24181DF8F437.qcow2 ImageType Disk Interface VirtIO InterfaceVersion 1 ReadOnly Identifier FD3274BB-8AEA-4E60-B8F7-85FDA00CA89E ImageName FD3274BB-8AEA-4E60-B8F7-85FDA00CA89E.qcow2 ImageType Disk Interface VirtIO InterfaceVersion 1 ReadOnly Information Icon ubuntu IconCustom Name j0cr3mj6jd-lin UUID F7698FFE-3025-426A-937F-92E0EF43D558 Input MaximumUsbShare 3 UsbBusSupport 3.0 UsbSharing Network Hardware virtio-net-pci IsolateFromHost MacAddress redacted Mode Emulated PortForward QEMU AdditionalArguments BalloonDevice DebugLog Hypervisor InterruptRemapping MemoryLock PS2Controller RNGDevice RTCLocalTime TPMDevice TSO UEFIBoot Serial Sharing ClipboardSharing DirectoryShareMode VirtFS DirectoryShareReadOnly Sound Hardware intel-hda System Architecture aarch64 CPU default CPUCount 8 CPUFlagsAdd CPUFlagsRemove ForceMulticore JITCacheSize 0 MemorySize 32768 Target virt

Activity

  1. added theissue type on Nov 17, 2026
  2. UTMapp-bot commented on Nov 17, 2026

    @UTMapp-bot
    Collaborator

    Thanks for the detailed report. I tried to reproduce this here. The lag appears once the guest display is resized through dynamic resolution, and I found a guest-side bug that is part of it. The full chain is not pinned down yet, so some details from you would help.

    What I tested

    • UTM 5.0.9 (the GitHub release, and a development build of 5.0.9), on an Apple Silicon Mac running macOS 27.2.
    • Guest: Ubuntu 24.04 aarch64 (kernel 6.8, Xorg 21.1.12) with kde-plasma-desktop + kwin-x11 5.27.11, an X11 session, and Mesa 25.2.8. KWin reports OpenGL compositing on GLX with renderer virgl, OpenGL 2.1.
    • Display: virtio-gpu-gl-pci, dynamic resolution on, retina mode off, default renderer.
    • Load: a small window moved with xdotool at about 60 Hz. I counted the distinct frames the UTM window showed. Each resize was triggered by switching the guest to a larger mode with xrandr; UTM's dynamic resolution then fitted the guest to the window.

    Results (release 5.0.9)

    State Guest mode (current) UTM window, distinct fps Longest frozen frame
    Fresh login, no resize 1280x800 (kernel mode, 120 Hz) 48 (also 47 on the dev build) 100 ms
    After a resize that landed on the kernel's mode 1920x957 (kernel mode, 120 Hz) 47 27 ms
    After a resize, compositing on 1920x957-0 (created by spice-vdagent, 0.06 Hz) 0.5 3.4 s
    Same, compositing suspended (qdbus org.kde.KWin /Compositor suspend) 1920x957-0 48 28 ms
    Back on the kernel's mode in the same session (xrandr --output Virtual-1 --mode 1920x957) 1920x957 (120 Hz) 1.0 about 1 s, steady

    In the last state, windows moved normally inside X (xdotool round trips took 2 ms, glxgears ran at about 1100 fps), but the composited screen changed only once per second. That matches what you describe. With compositing suspended, updates were smooth.

    One guest-side bug found: spice-vdagent creates 0.06 Hz modes

    When UTM resizes the display, spice-vdagent in the guest applies the new size through XRandR. If no mode of that size exists yet, it creates one named <width>x<height>-<n>. set_reduced_cvt_mode() in its src/vdagent/x11-randr.c computes the pixel clock in kHz (the comment there says "kHz for xf86"), but XRRModeInfo.dotClock is in Hz. Every mode it creates therefore runs 1000 times too slowly (60 Hz becomes 0.06 Hz). xrandr --verbose showed this here: 1920x957-0 0.123MHz ... v: ... clock 0.06Hz.

    I checked this in spice-vdagent 0.22.1 (Ubuntu 24.04's 0.22.1-4ubuntu0.1), and current upstream master has the same code. Whether the agent's mode or the kernel's mode ends up current varies from one resize to the next.

    What does not match yet

    • Your workaround, KWIN_USE_BUFFER_AGE=0, did not bring updates back in my runs, and neither did restarting KWin. However, my runs after KWin restarts were not reliable (the screen sometimes stopped updating entirely), so I would not read much into that.
    • I could not compare with 4.7.5 on this guest. On 4.7.5 every guest mode change hung the X server here, so I can't say what changed between 4.x and 5.x.

    What would help

    While the lag is happening, please post:

    1. the output of xrandr --verbose | grep -A2 current in the guest. Is the mode's name of the form WxH-0, and does its v: line show about 0.06Hz?
    2. dpkg -l spice-vdagent;
    3. whether the lag also starts with dynamic resolution turned off in the VM's display settings (and the guest resolution set inside the guest), and whether it starts right after the UTM window is resized or the VM is first shown;
    4. the VM's Debug Log (VM settings → QEMU → Debug Log) from a session where the lag starts.
  3. rearnsha commented on Nov 17, 2026

    @rearnsha
    Author

    1: 1840x1010-0 (0x171) 0.124MHz *current
    h: width 1840 start 1888 end 1920 total 2000 skew 0 clock 0.06KHz
    v: height 1010 start 1013 end 1023 total 1039 clock 0.06Hz
    2: $apt search spice-vdagent
    Sorting... Done
    Full Text Search... Done
    spice-vdagent/noble-updates,noble-security,now 0.22.1-4ubuntu0.1 arm64 [installed]
    Spice agent for Linux

    $ dpkg -l spice-vdagent|catDesired=Unknown/Install/Remove/Purge/Hold
    | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
    |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
    ||/ Name Version Architecture Description
    +++-==============-=================-============-=================================
    ii spice-vdagent 0.22.1-4ubuntu0.1 arm64 Spice agent for Linux
    3: disabling dynamic resolution solves the issue (no lag, but you can't then arbitrarily resize the display - trying to do so leads to scaling of the blurred graphics due to interpolation)
    4: (github won't let me attach the debug file here, I'll see if I can attach it as a separate comment.)

  4. rearnsha commented on Nov 17, 2026

    @rearnsha
    Author

    https://pastebin.com/15BMcpF1
    I've had to remove the date from various lines to keep it under the patebin limit.

  5. UTMapp-bot commented on Nov 17, 2026

    @UTMapp-bot
    Collaborator

    Thanks, that confirms it. Your current mode, 1840x1010-0 at 0.124 MHz / 0.06 Hz, is the one spice-vdagent creates. The set_reduced_cvt_mode() of 0.22.1 produces exactly those timings for 1840x1010 (1888/1920/2000, 1013/1023/1039). It also fits that turning off dynamic resolution makes the lag go away.

    Fix: utmapp/vd_agent#7 (the agent's source tree in this organization). It computes the mode's clock in Hz, as XRandR expects. It also replaces broken 0.06 Hz modes an older agent left in the running X server instead of reusing them, and caps the clock for very large modes on 32-bit guests.

    Tested in the same Ubuntu 24.04 + KWin 5.27 X11 guest on UTM 5.0.9, with dynamic resolution on, counting the distinct frames the UTM window showed while a window moved:

    Agent Mode after a resize Distinct fps
    0.22.1 code 3840x957-0, 0.06 Hz 0.5 (frames held up to 3.4 s)
    patched 3840x961-0, 59.91 Hz (the old 0.06 Hz mode, replaced) 47.2

    Ubuntu's spice-vdagent package comes from the distribution, not from UTM, so this reaches your guest only once the fix is in the package Ubuntu ships. Until then, either of these avoids it:

    • leave dynamic resolution off, which you found works;
    • after a resize, switch to the kernel's mode of the same size, i.e. the name without -0, for example xrandr --output Virtual-1 --mode 1840x1010 if that mode is listed. This worked here once, before the guest had been on a 0.06 Hz mode. After it had been, KWin stayed at about 1 update per second even on the 120 Hz mode until the session was restarted, so you may need to log out and back in.

    There's no need to attach the debug log for this.

  6. rearnsha commented on Nov 17, 2026

    @rearnsha
    Author

    Many thanks. I built a local version of the ubuntu .dev with that patch applied and it seems to have resolved the issue.

  7. UTMapp-bot commented on Nov 17, 2026

    @UTMapp-bot
    Collaborator

    Thanks for testing it. Your result, from Ubuntu's 0.22.1 package rebuilt with the patch on your own setup, confirms the fix in utmapp/vd_agent#7 outside my test VM. This issue stays open until a maintainer has reviewed and merged that pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    externalIssue cannot be resolved by UTM

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions