Skip to content

Connect worker process to compositor#10727

Merged
kalenikaliaksandr merged 2 commits into
LadybirdBrowser:masterfrom
kalenikaliaksandr:connect-webworker-to-compositor
Jul 17, 2026
Merged

Connect worker process to compositor#10727
kalenikaliaksandr merged 2 commits into
LadybirdBrowser:masterfrom
kalenikaliaksandr:connect-webworker-to-compositor

Conversation

@kalenikaliaksandr

Copy link
Copy Markdown
Member

Preparation work for OffscreenCanvas support.

The CompositorConnection and the CompositorHost implementation driving
it lived in Services/WebContent, which only WebContent can link. The
WebWorker process is about to need the same plumbing so OffscreenCanvas
contexts created in workers can stream canvas commands to the
Compositor process.

Move CompositorConnection into LibWebView unchanged, and pull the
reusable part of WebContentCompositorHost into a new
WebView::CompositorHostBase whose subclasses supply the connection.
WebContent keeps a thin subclass that routes context-destruction
notifications back to its client connection. LibWebView now links
LibMedia because the moved connection encodes Media::VideoFrame for
the video frame update messages. No behavior change.
OffscreenCanvas contexts in dedicated workers need to stream canvas
commands to the Compositor process, but worker processes only had
RequestServer and ImageDecoder connections, and WebWorker::PageHost
reported no compositor support, so every remote-canvas creation path
no-ops in a worker.

Mint a Compositor transport for each spawned worker in the UI process
(reusing the same control-channel handshake WebContent uses; the
returned connection id is only meaningful for navigable contexts, which
workers never create) and send it over the worker's control socket
before start_worker, so the connection exists before any worker script
can run. The worker wraps it in the shared WebView::CompositorConnection
and exposes it through a WebWorkerCompositorHost via the PageClient
compositor virtuals, making page.compositor_host() work in worker
realms the same way it does in WebContent. Minting failure is tolerated:
the worker then runs in the same degraded no-canvas mode WebContent
enters when the Compositor is unavailable.
@kalenikaliaksandr
kalenikaliaksandr merged commit f27b4da into LadybirdBrowser:master Jul 17, 2026
13 checks passed
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