0
Fork 0
mirror of https://github.com/zeronsh/comet.git synced 2026-11-16 18:57:19 +00:00
comet/docs/reference/linux-browser.md
Alexandre V.L c31124aa91
Linux browser: WPE WebKit at the display's rate, frames shared with GPUI as dma-bufs (#1039)
* Linux browser: WPE WebKit at the display's rate, frames shared with GPUI as dma-bufs

The sidebar browser on Linux ran WebKitGTK in an offscreen window: every
frame went through the CPU, over a pipe, into a new GPUI image, so pages
topped out near 60 fps whatever the display, and large ones fell well below.

Zeron now carries its own WPE WebKit platform (browser/linux/wpe.c) and runs
it in the helper when the build and the system have WPE WebKit 2.50+:

- WebKit renders on the GPU GPUI draws with, into dma-bufs in a DRM format
  modifier GPUI's Vulkan device imports. GPUI copies only each frame's
  damaged regions into the page's atlas tile, on the GPU (zeronsh/zui#18).
- Where the driver renders no layout Vulkan imports, the helper reads frames
  back with OpenGL ES into a sealed memfd. Without a GPU, WebKit renders on
  the CPU into shared memory. Both update the tile in place.
- GPUI's frame callbacks are the pages' vblank: WebKit hears a frame is on
  screen at most once per display refresh, so pages run at 60, 144 or 240 Hz
  and never render frames the display won't show. Hidden pages, and pages
  replaced by their error, get none.
- WebKit runs copy, cut and paste itself, sets the pointer's cursor, and sees
  click counts and the pointer leaving the page.

If the WPE helper can't start, the session uses WebKitGTK. Its helper now
renders at the output's scale (it rendered 4x the pixels at 1.5x on Wayland
and downscaled them) and sends Cairo's surface as-is instead of converting it
through GdkPixbuf, which took most of its CPU.

A helper that crashes, sends a message Zeron can't read or is still being
written by a forked child (ETXTBSY) is stopped, replaced or retried; the
tests run the real helper on every render node, in every layout its driver
renders, read back and in shared memory, at 60, 144 and 240 Hz.

* Linux browser bench: shown frames, pacing, copies, press latency, memory

`ZERON_BROWSER_BENCH` measured one page's frame rate and CPU. It now loads
a fresh document for each of a 2D canvas, WebGL 2, scrolling, a CSS spinner
and, with `ZERON_BROWSER_BENCH_VIDEO`, a 60 fps video, and records for each:
the page's frame rate, when GPUI painted every new frame, the bytes copied
into the page's tile from CPU memory and between GPU buffers, CPU, PSS and
NVIDIA GPU memory for Zeron and for WebKit's processes, and a capture. It
then times 40 presses from GPUI's input to the frame showing them, and
measures an idle page. `ZERON_BROWSER_BENCH_WIDTH` sizes the browser.

The counts are kept only in fixture builds (`browser-fixture`), for both
engines, so WebKitGTK and every WPE path are measured the same way.

`ZERON_BROWSER_DMABUF=readback` keeps WebKit on the GPU but reads its frames
back, the path GPUs that render no importable layout take.

* Linux browser bench: WebGL page checks a WebGL 1 context too

The WebGL page's benchInfo() clears a WebGL 1 context and reads a pixel back, so a bench run records that both WebGL versions render.

* Linux browser: rustfmt the WPE engine and its tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>

* Linux browser: a paste without text clears WPE's clipboard copy

The WPE helper kept the last clipboard text Zeron shared, and Zeron shared
only text. Pasting with an image or nothing on the system clipboard then
inserted that earlier text, possibly into another page. Zeron now shares
the clipboard on every paste, and empty text clears the helper's copy.

build.rs embeds an empty WPE helper, as when WPE is missing, if wpe.c does
not compile against the installed development files (an older GBM), and
detects them again when PKG_CONFIG_PATH changes. probe_gpu releases the GBM
device and render node it opened when the GPU is unusable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>

* Linux browser fixture: rustfmt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>

* Linux browser docs: the WPE vblank check needs a compositor that answers idle frame callbacks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>

---------

Co-authored-by: Wing <44917547+wingleeio@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
2026-10-27 06:08:25 +00:00

89 lines
6.5 KiB