Skip to content

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

Open
mvanhorn wants to merge 2 commits 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 2 commits 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 2 commits May 21, 2026 07:30
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.

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