Skip to content

Desktop: re-enable GPU compositing on NVIDIA X11 with driver 610 or newer - #15546

Merged
oobabooga merged 6 commits into
unslothai:mainfrom
oobabooga:studio/linux-nvidia-x11-page-compositing
Oct 28, 2026
Merged

oobabooga merged 6 commits into
unslothai:mainfrom
oobabooga:studio/linux-nvidia-x11-page-compositing

Conversation

@oobabooga

@oobabooga oobabooga commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

On Linux with NVIDIA on X11, Desktop turns WebKit accelerated compositing off for the whole app (#10214, #10964). Composited WebKit leaked one sync_file descriptor per frame on the 580 driver until the web process hit its fd limit and the window went blank (#10795). With compositing off, a generated game opened as an HTML preview in the browser panel drags the whole UI down: at 2x scale on a 4384x2466 screen, the main UI and a small three.js game both run at about 22 fps, and scrolling the chat stutters at 10 to 18 fps even without a game.

Fix

On NVIDIA X11 with driver branch 610 or newer, Desktop now uses the plan that the UNSLOTH_WEBKIT_DISABLE_COMPOSITING=0 opt-out already selects: the shared-memory transport with compositing on. Older or unreadable branches keep compositing off. The branch comes from /proc/driver/nvidia/version, which the app already probes, for both the open and the proprietary module strings. UNSLOTH_WEBKIT_DISABLE_COMPOSITING=1 still turns compositing off, and operator WEBKIT_* variables are still left alone.

When compositing stays on in the AppImage, Desktop also sets WEBKIT_GST_DISABLE_GL_SINK=1. Composited WebKit plays video through GStreamer GL, and the AppImage's bundled GStreamer cannot create a GL context on NVIDIA, so every video stayed black. The non-GL sink is the one main already uses. Native packages use system GStreamer, where the GL sink works, and keep it. This also fixes black video under the existing =0 opt-out in the AppImage.

Why branch 610

NVIDIA has not published a version that fixes the leak. The evidence for a version cutoff:

So the no-leak side of the cutoff rests on one workstation, not on a fix NVIDIA has confirmed. If a host on 610 or newer still leaks, UNSLOTH_WEBKIT_DISABLE_COMPOSITING=1 restores the current behavior for that host. 580 is the last branch for Maxwell, Pascal and Volta GPUs, so those hosts keep the current fallback.

Reproduction on 580

To check that the driver is the cause, I ran this PR's AppImage on a laptop with a GeForce MX150 on 580.178.04 (Cinnamon X11, display on the Intel iGPU), scrolling a full-window page every frame at the stock soft fd limit of 1024.

Plan Log sync_file fds in the web process UI
Default (this PR) main's plan, compositing off 0 about 59 fps throughout
UNSLOTH_WEBKIT_DISABLE_COMPOSITING=0 shared-memory transport, compositing on grew steadily to 977 of 1,023 open fds in under 4 minutes stopped drawing once fds ran out

These match #10214 (1,023 fds, 949 sync files) and the failure in #10795. The web process loaded NVIDIA's libEGL_nvidia.so.580.178.04 even though the display runs on the Intel iGPU, so PRIME laptops take the same driver path and need the same gate.

On 615.71.09 the same AppImage held 6 to 16 sync_file fds over 10 minutes of the same scrolling, and 6 to 12 over a 12-minute run with the game preview open and wheel scrolling every second, with no fd errors. Web-process memory in that run peaked at 1.36 GB and fell back.

Live A/B results

Both AppImages were built with the Linux x64 steps of release-desktop.yml in ubuntu:22.04 and ran on a headless NVIDIA X server (RTX 3090, 615.71.09, 4384x2466, 2x scale) with Studio's own backend. The test case is a real conversation in which the model generated a three.js driving game, opened from its HTML preview card; scrolling was 40 wheel clicks over the chat. Values are medians.

Case Main This PR
Game preview open: main UI / game fps 23.2 / 22.4 62.0 / 31.0
Game preview open: CPU of the UI and web processes 103% 37%
Scrolling with the game open: main UI fps / worst timer lag 10.3 / 224 ms 61.9 / 5 ms
Scrolling a long chat, no game: main UI fps / worst timer lag 17.0 / 108 ms 61.3 / 7 ms
Idle, no game: main UI fps / CPU 61.9 / 2% 61.9 / 5%

The cost is memory. The web process for that conversation used 981 MB instead of 674 MB, in line with #10214's note that compositing off saves web-process memory.

Behavior boundaries

  • Wayland, non-NVIDIA X11 and NVIDIA branches below 610 keep their current plans.
  • On a PRIME laptop that presents through the iGPU, the app takes the same shared-memory transport that the =0 opt-out already uses.

Validation

  • Rust tests: all 777 studio/src-tauri binary tests pass, including new cases for the branch gate, the fallback for branches 0, 470, 580, 595 and 609, the precedence of overrides, Wayland ignoring the branch, version parsing for both module flavours, and the AppImage video sink (default, opt-out, operator value, relaunch).
  • App sweep: with the same AppImage on its default plan and forced back to main's plan, every page reachable without a GPU loaded the same images and text with identical logs. Canvas, WebGL, <audio>, Web Audio and the browser panel's screenshots of the app, of native pages and of the game preview worked on both. Screenshots differed only in text antialiasing and animated content.
  • Video: the build before the sink change played gallery videos black. With it, frames show as on main with no GStreamer GL failures; in my live Cinnamon session, 198 gallery videos opened over 10 minutes all played, with no media errors and no crash.
  • Browser panel pages, main UI idle: WebGL 60 vs 62 fps and canvas 60 vs 62 fps at about half the web-process CPU, and a CSS blur page 62 vs 13 fps.
  • Formatting and build: rustfmt is clean on the changed file, and verify-complete-appimage.sh passed.
  • Not tested: 590 or 595 hardware, Wayland, a PRIME laptop on 610 or newer, the Train tab (the test backend had no GPU), microphone input, and clippy.
  • Open: during manual testing of the build before the sink change, the UI process aborted once inside the bundled WebKitGTK 2.50.4 (SIGABRT, no symbols available) while gallery videos were failing to play. Automated gallery browsing, 13 minutes on that build and 10 on this one, did not reproduce it, so the cause is not established.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-28T22:46:33.702038Z b71502e Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@oobabooga

Copy link
Copy Markdown
Member Author

Reached Codex review convergence at oobabooga#420.

@oobabooga
oobabooga marked this pull request as draft October 27, 2026 13:19
@oobabooga oobabooga changed the title Desktop: re-enable GPU compositing for browser pages on NVIDIA X11 Desktop: re-enable GPU compositing on NVIDIA X11 with driver 610 or newer Oct 27, 2026
@oobabooga

Copy link
Copy Markdown
Member Author

Reached Codex review convergence again on 4cb4120 at oobabooga#420.

@oobabooga
oobabooga marked this pull request as ready for review October 28, 2026 13:28
@oobabooga
oobabooga marked this pull request as draft October 28, 2026 13:43
@oobabooga

Copy link
Copy Markdown
Member Author

Reached Codex review convergence again on afe492a at oobabooga#420.

@oobabooga

Copy link
Copy Markdown
Member Author

Reached Codex review convergence again on b71502e at oobabooga#420.

@oobabooga
oobabooga marked this pull request as ready for review October 28, 2026 22:46
@oobabooga
oobabooga merged commit c3879b1 into unslothai:main Oct 28, 2026
24 of 25 checks passed
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 18, 2026
…othai#18267)

Fixes unslothai#18259

## Problem

On Linux hosts where WebKit does not composite (NVIDIA on X11 with a
driver below 610, the GPU rendering Off setting, hosts with no usable
GPU path), wheel scrolling in the chat stalls and then jumps. The
reporter is on NVIDIA 595.99.02 on X11, where Desktop keeps compositing
off because older drivers leak a file descriptor per frame (unslothai#10214,
unslothai#10795, unslothai#15546).

Without compositing WebKit also turns threaded scrolling off
(`webkit_settings_set_hardware_acceleration_policy(NEVER)` clears
`ThreadedScrollingEnabled`), so its smooth scrolling animation runs on
the web process main thread. Each animation step is a full CPU repaint.
When a repaint takes around 100 ms, the time based animation shows
nothing for a few frames and then lands far ahead, which matches the
report: "when I start to scroll, there's a delay where nothing happens
at all, and then it suddenly jumps forward a huge amount".

## Fix

When the main webview is created on Linux, Desktop reads WebKit's own
answer (`hardware_acceleration_policy() == Never`, which WebKitGTK
derives from whether compositing is enabled, 2.50 and 2.54 alike) plus
`WEBKIT_DISABLE_COMPOSITING_MODE` (on 2.54 the policy stays `Always`
when only compositing is off). If WebKit is not compositing, smooth
scrolling is turned off, so each wheel notch is applied on the next
paint instead of being animated across several slow ones. Composited
hosts keep smooth scrolling unchanged.

No setting, UI or rendering plan changes. The value is set per launch
from that launch's state, so it is idempotent and a driver upgrade to
610+ brings smooth scrolling back on its own.

## Measurements

### The real Desktop binary

Debug builds of this branch and of its merge base (`efe3797`), built
with `--no-default-features` so the window loads a local chat-like page
(60 messages, code blocks, blurred header and composer). Ran under Xvfb
at `GDK_SCALE=2` with a 1400x900 window. The host has the NVIDIA 590
kernel module and WebKitGTK 2.50.4 (the version Mint 22.3 ships), so the
app chose the reporter's plan by itself: `NVIDIA driver loaded (no
Wayland session); set WEBKIT_DMABUF_RENDERER_FORCE_SHM=1
WEBKIT_FORCE_DMABUF_RENDERER=1 WEBKIT_DISABLE_COMPOSITING_MODE=1`. Real
X11 wheel clicks via XTest, base and head alternated ABBA, 4 runs each.
"Reach" is the time from a wheel click until the page has scrolled that
click's distance.

| Plan | Wheel input | Base reach median (per run) | Head reach median
(per run) | Largest jump base / head |
| --- | --- | --- | --- | --- |
| NVIDIA X11 below 610, compositing off (the report) | 20 clicks, 50 ms
apart | 546, 538, 551, 529 ms | 36, 42, 46, 34 ms | 537 to 699 px / 186
px |
| same | 8 clicks, 200 ms apart | 150, 117, 129, 131 ms | 0 ms (each
click lands on the next paint) | 90 px / 93 px |
| `UNSLOTH_WEBKIT_DISABLE_COMPOSITING=0`, compositing on (software GL),
2 runs each | 20 clicks, 50 ms apart | 192, 196 ms | 203, 193 ms | 140
to 186 px / 171 to 199 px |

The last row is the control: when WebKit composites, head keeps smooth
scrolling and matches base.

### NVIDIA GPU VM (Colab L4)

Same driver and page, both trees built on the VM: NVIDIA L4, driver
580.82.07 (the leaking branch), WebKitGTK 2.52.6, Xvfb. The app read the
real driver and picked its NVIDIA X11 below-610 plan by itself. 3 runs
per plan and tree.

| Plan | Base reach median (per run) | Head reach median (per run) |
Largest jump base / head |
| --- | --- | --- | --- |
| Default (NVIDIA X11 below 610, compositing off) | 565, 545, 523 ms |
53, 44, 44 ms | 791 to 886 px / 186 px |
| `UNSLOTH_WEBKIT_DISABLE_COMPOSITING=1` | 528, 536, 548 ms | 46, 48, 42
ms | 757 to 787 px / 186 px |
| `UNSLOTH_WEBKIT_DISABLE_COMPOSITING=0` (compositing on) | 194, 203,
200 ms | 196, 213, 202 ms | 138 to 203 px / 199 to 211 px |

### AMD GPU (gfx1151 AMD CI runner)

Both trees built in an `ubuntu:24.04` container (WebKitGTK 2.52.6) with
the Radeon render node passed through, Xvfb, 3 runs per plan and tree
(run 44322215922; the base and head binary hashes differ).

| Plan | Base reach median (per run) | Head reach median (per run) |
Largest jump base / head |
| --- | --- | --- | --- |
| Default (WebKit composites on the GPU) | 157, 164, 156 ms | 165, 156,
165 ms | 39 to 41 px / 40 to 43 px |
| `UNSLOTH_WEBKIT_DISABLE_COMPOSITING=1` | 289, 277, 280 ms | 0 ms (next
paint) | 144 to 189 px / 93 px |

With a GPU present, repaints with compositing off are fast, so the base
delay there is the animation itself (about 280 ms) rather than the 550
ms stall of a CPU-bound host. The harness gate I set before the run
(base median above 300 ms) therefore reads VOID; the numbers are above.

### Standalone WebKitGTK harness

GTK3 window with a `WebKitWebView` (system WebKitGTK 2.50.4), Xvfb, the
exact environment Desktop applies for NVIDIA X11 below 610 on WebKitGTK
< 2.54 (`WEBKIT_DMABUF_RENDERER_FORCE_SHM=1
WEBKIT_FORCE_DMABUF_RENDERER=1 WEBKIT_DISABLE_COMPOSITING_MODE=1`),
`GDK_SCALE=2` so CPU paints take about 100 ms like a 4K panel. Real X11
wheel clicks via XTest into a chat-like page (60 messages, code blocks,
blurred header and composer). "Reach" is the time from a wheel click
until the page has scrolled that click's distance. Arms alternated ABBA.

| Wheel input | Arm | Reach median | Reach max | Largest single-frame
jump |
| --- | --- | --- | --- | --- |
| 20 clicks, 50 ms apart (4 runs each) | smooth on (today) | 578 to 656
ms | 848 to 961 ms | 746 to 1067 px |
| | smooth off (this PR) | 56 to 78 ms | 129 to 203 ms | 279 to 372 px |
| 8 clicks, 200 ms apart (2 runs each) | smooth on (today) | 121 to 172
ms | 190 to 226 ms | 90 to 92 px |
| | smooth off (this PR) | 0 to 1 ms | 0 to 10 ms | 93 px |

The same harness applying this PR's predicate read `policy=NEVER` and
turned smooth scrolling off, giving the smooth off numbers.
`WEBKIT_DISABLE_DMABUF_RENDERER=1` (the plan on 2.54+) behaves the same:
559 to 564 ms reach with smooth on, 61 to 62 ms with it off. At 1x scale
with fast paints the stall does not appear, which is why composited
hosts are left alone.

## Tests

- New `smooth_scrolling_is_off_only_without_compositing` in
`linux_webkit.rs`: policy `Never` or a compositing-off value (`1`, `00`,
`false`, as WebKit reads it) turns smooth scrolling off; unset, `0` and
empty keep it.
- All 870 `studio/src-tauri` tests pass on Linux. Staging CI is green on
Linux, macOS and Windows (Tauri CI, Desktop app clean machine, Backend,
Lint, Wheel).

## Not tested

A physical NVIDIA X11 desktop session, WebKitGTK 2.54 inside the full
app, and the AppImage build. Browser panel webviews are unchanged.

## Before and after

Same Desktop binaries, reporter's plan, same 20 wheel clicks. Stills
taken at the same moments after the first click: AFTER is already
further down the chat while BEFORE is still catching up.

![Filmstrip: BEFORE (main) vs AFTER (this PR) at t=1.0, 1.4, 1.8 and 2.2
s](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/18267/filmstrip-94632724dc46.png)

![Side by side recording of the same wheel burst, BEFORE (main) left,
AFTER (this PR)
right](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/18267/scroll_side_by_side-a8f6b70181e6.gif)
danielhanchen pushed a commit that referenced this pull request Nov 24, 2026
…d newer (#19186)

Reported on
[Reddit](https://www.reddit.com/r/unsloth/comments/1xythhf/comment/19ssk4qntqisk/?context=3)
(#18259): on Linux Mint X11 with an RTX 5090 and driver 595.99.02, chat
scrolling in the desktop app stalls and then jumps ahead. Below driver
610, Desktop turns WebKit compositing off on NVIDIA X11, and without
compositing WebKit has no threaded scrolling. #18267 made wheel
scrolling step instead of animate on that path. With this PR, 590 and
595 hosts like this one get compositing back, and with it smooth
scrolling.

The 610 cutoff comes from #15546, which had data only for 580
(composited WebKit leaks one `sync_file` fd per frame) and 610/615
(clean). 590 and 595 were never tested.

This PR lowers the cutoff to 590, based on live measurements: each
driver below was installed on a real machine, booted, and tested.

## How it was measured

- **Hardware and OS:** one workstation with an RTX 6000 Ada and an RTX
3090, running an Ubuntu 24.04-based distribution.
- **Driver installs:** each driver was the full Ubuntu noble package set
from Launchpad, installed with apt and built with DKMS.
- **Load check:** after each reboot, nothing ran unless
`/proc/driver/nvidia/version` showed the expected version and module
flavor.

Each boot ran two tests:

1. **The minimal EGL reproducer** from [NVIDIA forum thread
384832](https://forums.developer.nvidia.com/t/linux-drivers-egl-bug-sync-file-fd-leaked-when-two-eglwaitsync-calls-are-issued-on-one-context/384832).
One context issues two `eglWaitSync` calls per frame, one of them on an
imported native fence, and the test counts the fds left after 200
frames. It ran three times per boot. A control mode with a single wait
ran once and leaked 0 fds on every driver, leaking or not.
2. **The Unsloth desktop app itself.** It was a build of main with a
test-only scrolling hook, on the bundled WebKitGTK 2.50.4, with
`UNSLOTH_WEBKIT_DISABLE_COMPOSITING=0`. That variable selects the same
composited shared-memory plan this gate turns on. The app ran on an Xvfb
display and scrolled continuously for 150 seconds while the web
process's `sync_file` fds were counted every 5 seconds.

## Results

| Driver | Module | Kernel | Reproducer (leaked fds per 200 frames, 3
runs) | App `sync_file` fds at 150 s | Verdict |
| --- | --- | --- | --- | --- | --- |
| 580.178.04 | proprietary | 7.0.0-42 | 199, 199, 199 | 326 | leak |
| 580.178.04 | open | 7.0.0-42 | 199, 199, 199 | 376 | leak |
| 580.178.04 | open | 6.8.0-147 | 199, 199, 199 | 336 | leak |
| 580.196.07 | open | 7.0.0-42 | 199, 199, 199 | 508 | leak |
| 590.48.01 | open | 6.8.0-147 | 0, 0, 0 | 4 (max 5) | no leak |
| 590.48.01 | proprietary | 6.8.0-147 | 0, 0, 0 | 4 | no leak |
| 595.58.03 | open | 7.0.0-42 | 0, 0, 0 | 4 (max 7) | no leak |
| 595.91.07 | open | 7.0.0-42 | 0, 0, 0 | 4 | no leak |
| 615.71.09 | open | 7.0.0-42 | 0, 0, 0 | 4 (max 7), two runs | no leak
|

The driver branch decides the outcome:

- **The 580 branch never received the fix.** 580.196.07, released in
October 2026 after 590 was already out, still leaks at the same rate as
580.178.04.
- **The kernel module flavor makes no difference.** On 580.178.04, the
open module leaks exactly like the proprietary one, and on 590.48.01
both are clean. This fits the leak being in NVIDIA's userspace EGL
library, which both flavors share.
- **The kernel is not the cause.** The 590.48.01 module does not compile
against kernel 7.0, so 590 was tested on 6.8.0-147, where 580.178.04
also leaked.
- **The app matches the reproducer every time.** Where the reproducer
leaks, the app gains 2 to 3 fds per second while scrolling; elsewhere it
stays flat at 2 to 7.

## Change

- `NVIDIA_COMPOSITING_MIN_BRANCH` in
`studio/src-tauri/src/linux_webkit.rs` goes from 610 to 590, with the
comment, log reason and tests updated to match. All 882
`studio/src-tauri` binary tests pass, and rustfmt is clean.
- The old-driver warning in settings says 590 instead of 610 in all 25
locales. Only the number changes.
- Nothing else moves: 580 and older (the last branch for Maxwell, Pascal
and Volta), unreadable branches, Wayland and non-NVIDIA hosts keep their
current plans, and `UNSLOTH_WEBKIT_DISABLE_COMPOSITING=1` still turns
compositing off.

## Not tested

- 590.44.01, the first 590 release. Ubuntu does not carry it, and the
module from NVIDIA's own repository did not build for either test
kernel.
- 595 with the proprietary module.
- CPU use. A [595.91.07
report](https://forums.developer.nvidia.com/t/595-91-07-webkitgtk-webprocess-spins-at-100-cpu-on-any-animated-page-regression-vs-595-84/384467)
of the web process spinning at 100% CPU reproduces with compositing off
on WebKitGTK 2.52.6, so it does not depend on this gate.
- The desktop X server; the app runs used Xvfb.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant