Menu

Guides

GPU mode

Choose how Chromium renders your page and check what the GPU does on a machine.

App::gpu_mode sets how Chromium renders. GpuMode::Auto is the default:

use kurogane::{App, GpuMode};

fn main() {
    App::new("content")
        .gpu_mode(GpuMode::Software)
        .run_or_exit();
}

The modes

GpuMode What Chromium does
Auto picks Hardware or Software for the machine
Hardware renders on the GPU
Software renders on the CPU with SwiftShader
Disabled turns the GPU off; no WebGL and no canvas acceleration

Auto

On Linux Auto picks Software inside a virtual machine whose display is a virtual GPU (VirtualBox, VMware or QEMU and virtio). Everywhere else it picks Hardware.

Hardware on each platform

  • Windows. Without the sandbox GPU work runs inside the browser process. It waits there for a lost device to recover. Under SandboxMode::Chromium it runs in a GPU process of its own instead.
  • macOS. Chromium renders through Metal and Core Animation with no overrides.
  • Linux. Chromium chooses between X11 and Wayland. With an NVIDIA GPU in a Wayland session Kurogane runs Chromium on X11 under XWayland.

When to choose a mode yourself

  • Software for virtual machines Auto doesn’t recognize, CI and remote desktop sessions. Rendering is slower but doesn’t depend on a GPU driver.
  • Hardware to keep the GPU inside a virtual machine whose GPU is passed through.
  • Disabled for apps that draw nothing that needs a GPU, or to rule the GPU out while you debug a rendering problem.

Pick the mode at runtime when it depends on the machine:

use kurogane::{App, GpuMode};

fn main() {
    let mode = match std::env::var("APP_GPU").as_deref() {
        Ok("software") => GpuMode::Software,
        Ok("off") => GpuMode::Disabled,
        _ => GpuMode::Auto,
    };
    App::new("content").gpu_mode(mode).run_or_exit();
}

Check the GPU on a machine

kurogane doctor reports the machine’s graphics:

kurogane doctor

On Linux it reads OpenGL through glxinfo with the libraries your apps load. Install mesa-utils for that report on Debian and Ubuntu. The Nix flake brings its own glxinfo.

On NixOS an app built on an older nixpkgs can’t load the system’s drivers and renders without the GPU. See GPU drivers on NixOS.

Override Chromium’s switches

App::chromium_flag and App::chromium_flag_with_value override a switch the GPU mode sets. Keep Chromium on Wayland with an NVIDIA GPU, for example:

use kurogane::App;

fn main() {
    App::new("content")
        .chromium_flag_with_value("ozone-platform", "wayland")
        .run_or_exit();
}