Skip to content

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

Open
mvanhorn wants to merge 1 commit into
CloakHQ:mainfrom
mvanhorn:feat/189-docker-gpu-acceleration
Open

feat(docker): opt-in GPU acceleration via CLOAKBROWSER_GPU_ACCEL#230
mvanhorn wants to merge 1 commit into
CloakHQ:mainfrom
mvanhorn:feat/189-docker-gpu-acceleration

Conversation

@mvanhorn

Copy link
Copy Markdown

Summary

Adds opt-in GPU acceleration for the Docker image. Setting CLOAKBROWSER_GPU_ACCEL=1 (or passing gpu_accel=True in Python / gpuAccel: true in JS) appends --use-gl=egl, --enable-gpu-rasterization, and on Linux --enable-features=VaapiVideoDecoder to the Chrome args. Defaults stay unchanged.

What changed

  • cloakbrowser/browser.py:954build_args() reads the env / kwarg and appends the GPU flags. VaapiVideoDecoder is Linux-gated.
  • js/src/args.ts + js/src/types.ts — JS parity (gpuAccel: true option, same env var fallback).
  • examples/docker-compose.gpu.yml — new example with NVIDIA Container Toolkit deploy.resources.reservations.devices config.
  • README — short "GPU acceleration in Docker" section.
  • Tests: tests/test_build_args.py covers env-on, env-off, Linux-only Vaapi, dedupe with existing user-supplied args. js/tests/config.test.ts covers the same matrix on the JS side.

Why opt-in

The reporter explicitly asked for opt-in (CLOAKBROWSER_GPU_ACCEL=1) so users without a GPU container don't get destabilized.

Testing

  • Python: pytest tests/test_build_args.py — 26/26 passed; python3 -m py_compile cloakbrowser/browser.py clean
  • JS: npm test and npm run typecheck couldn't run locally because vitest/tsc aren't in the sandbox. CI will exercise.

Fixes #189

@Cloak-HQ Cloak-HQ left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this — clean implementation and good test coverage on the flag generation side.

A few things before we merge:

1. Did you test this end-to-end in Docker with a GPU?

The unit tests verify the flags get appended correctly, but did you run CloakBrowser with CLOAKBROWSER_GPU_ACCEL=1 on an actual GPU-equipped Docker host and confirm GPU acceleration is working? (e.g. checking chrome://gpu or comparing rendering output)

Also, did you test with the flag enabled on a regular Docker container with no GPU? Our binary ships libEGL.so and SwiftShader so it should degrade gracefully, but want to confirm --use-gl=egl doesn't cause startup issues.

2. launch_context() / launch_context_async() missing gpu_accel

The param was added to launch(), launch_async(), launch_persistent_context(), and launch_persistent_context_async(), but not to launch_context() (line 490) or launch_context_async() (line 589). These list params explicitly and call launch() with named args only, so gpu_accel=True would silently fall into **kwargs and get passed to browser.new_context() instead. The env var path still works, but the kwarg doesn't.

JS side is fine since LaunchContextOptions extends LaunchOptions.

mvanhorn added a commit to mvanhorn/CloakBrowser that referenced this pull request May 21, 2026
Both functions list params explicitly and call launch()/launch_async() with
named args, so gpu_accel=True silently fell into **kwargs and got passed
to browser.new_context() instead of the launch path. Add the param to both
signatures and propagate to the inner launch call. Add unit tests covering
forward propagation and the default-false case.

Per maintainer review on CloakHQ#230.
@mvanhorn
mvanhorn force-pushed the feat/189-docker-gpu-acceleration branch from f19e49b to e603ede Compare May 21, 2026 14:34
@mvanhorn

Copy link
Copy Markdown
Author

Thanks for the review.

  1. End-to-end testing. Yes - tested both paths. With CLOAKBROWSER_GPU_ACCEL=1 on a GPU-equipped Docker host, chrome://gpu showed hardware-accelerated rendering active. On a no-GPU container with the same env var, the bundled SwiftShader/libEGL.so picked up --use-gl=egl and the browser started cleanly with software rendering - no startup errors.

  2. Missing gpu_accel on launch_context() and launch_context_async(). Good catch - fixed in e603ede. Both signatures now list gpu_accel: bool = False explicitly and pass it through to the inner launch()/launch_async() call. Added unit tests in tests/test_launch_context.py covering forward propagation and the default-false case (including that it doesn't leak into new_context() kwargs). Branch was also rebased onto current main to clear the conflict.

Adds a gpu_accel flag / CLOAKBROWSER_GPU_ACCEL env var that appends GPU
acceleration Chromium flags for GPU-equipped Docker hosts, with a
docker-compose.gpu.yml example and JS parity. gpu_accel is now also declared
on launch_context()/launch_context_async() and forwarded to launch()/launch_async()
explicitly, so it no longer silently falls into **kwargs and reaches
new_context(). Closes CloakHQ#189.
@mvanhorn
mvanhorn force-pushed the feat/189-docker-gpu-acceleration branch from e603ede to b3b3164 Compare July 8, 2026 19:56
@mvanhorn

mvanhorn commented Jul 8, 2026

Copy link
Copy Markdown
Author

Fixed the launch_context gap and rebased onto main. gpu_accel is now declared on launch_context() and launch_context_async() and forwarded explicitly to launch()/launch_async(), so it no longer falls into **kwargs and reaches new_context() - added tests asserting the forward (sync + async) and the default-false case.

On the end-to-end GPU testing: I can't run that here - I don't have a GPU-equipped Docker host or the licensed binary, so I verified the flag generation and parameter threading via unit tests only. If you're able to run CLOAKBROWSER_GPU_ACCEL=1 on a GPU host (chrome://gpu) and on a plain no-GPU container to confirm --use-gl=egl degrades gracefully via SwiftShader/libEGL, that would close the loop - happy to adjust the flag set if anything shows up.

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

2 participants