Skip to content

feat(docker): opt-in GPU acceleration via CLOAKBROWSER_GPU_ACCEL - #476

Open
cjangrist wants to merge 1 commit into
CloakHQ:mainfrom
cjangrist:fix/189-gpu-accel-angle-egl
Open

feat(docker): opt-in GPU acceleration via CLOAKBROWSER_GPU_ACCEL#476
cjangrist wants to merge 1 commit into
CloakHQ:mainfrom
cjangrist:fix/189-gpu-accel-angle-egl

Conversation

@cjangrist

@cjangrist cjangrist commented Jul 30, 2026

Copy link
Copy Markdown

Supersedes #230 by @mvanhorn — keeps that PR's flag/env/JS/test scaffolding and docker-compose example, rebased onto current main (resolves its conflict). Closes #189.

#230 stalled on the one thing it couldn't test: a real GPU. I ran it end-to-end on an NVIDIA RTX 3080 Ti (host + inside the built image); it doesn't work as written, so this fixes two defects:

1 — wrong Chrome flag. --use-gl=egl was removed from modern Chromium (the shipped binaries are 146/150); it silently disables WebGL instead of enabling the GPU. Correct: --use-gl=angle --use-angle=gl-egl (ANGLE over native EGL).

2 — image missing the GLVND loader. Even with the right flag, ANGLE fails with Could not dlopen native EGL: libEGL.so.1. The Dockerfile now installs libglvnd0 libegl1 libgles2 libglx0 libopengl0.

Testing — NVIDIA RTX 3080 Ti (CDP SystemInfo.getInfo == chrome://gpu; util from nvidia-smi)

launch(gpu_accel=True, headless=True) / CLOAKBROWSER_GPU_ACCEL=1:

Scenario WebGL Real backend GPU util
baseline (flag off) software SwiftShader 0%
#230 --use-gl=egl ❌ disabled none 0%
this PR --use-angle=gl-egl (host) ✅ hardware NVIDIA RTX 3080 Ti (OpenGL ES) 91%
this PR, inside the built image ✅ hardware NVIDIA RTX 3080 Ti 90–93%
flag on, no GPU ❌ disabled none 0% — starts, no crash
  • nvidia-smi during a WebGL load shows the Chrome GPU process at ~90% util (149 W).
  • Scope, tested honestly: acceleration engages on the headless launch() path (surfaceless EGL). Headed sessions rendered on the container's Xvfb stay on the software driver — Xvfb exposes no GPU display — so this is documented as headless-only rather than over-claimed for the CDP/session path.
  • On a no-GPU container the flag doesn't crash but WebGL goes dark (no SwiftShader fallback) — worth knowing before enabling it without a GPU.
  • The stealth WebGL-renderer spoof still holds with the GPU on (JS sees a Windows D3D11 string; real backend is Linux OpenGL ES), so it doesn't leak the real renderer.
  • Unit tests green: pytest (build_args flag matrix + gpu_accel forwarding, sync/async), vitest config matrix; tsc build clean.

Adds a gpu_accel flag / CLOAKBROWSER_GPU_ACCEL env var (gpuAccel in JS) that
appends GPU-acceleration Chromium flags, with a docker-compose.gpu.yml example
and Python/JS parity. gpu_accel is threaded explicitly through
launch_context()/launch_context_async() into launch()/launch_async() so it can
no longer fall into **kwargs and reach new_context().

Builds on and credits CloakHQ#230 by @mvanhorn, fixing the two defects that stopped it
working end-to-end (verified below):

- Flag: use --use-gl=angle + --use-angle=gl-egl (ANGLE over native EGL). The
  original --use-gl=egl is a value removed from modern Chromium (146/150); it
  silently disables WebGL instead of enabling the GPU.
- Image: install the GLVND EGL loader (libglvnd0/libegl1/...) so ANGLE can
  dlopen native EGL inside the container.

Tested on an NVIDIA RTX 3080 Ti, host and inside the built image: SystemInfo /
chrome://gpu report hardware WebGL + rasterization on the NVIDIA GL renderer, and
a WebGL load drives the GPU to ~90% (nvidia-smi). Unit tests cover flag emission
(Python + JS) and gpu_accel forwarding.

Closes CloakHQ#189.

Co-Authored-By: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

Chrome does not use GPU acceleration in Docker — causes video playback lag and tab crashes

1 participant