Skip to content

Browser hangs in Docker/K8s with "No GPUs detected via PCI" error #25

Description

@StefanIgnjatovic12

Environment

  • Camoufox version: v142.0.1-fork.27
  • Platform: Kubernetes pods (Docker containers, python:3.13-slim base)

Problem

Firefox launches but hangs indefinitely during GPU detection, timing out after 120 seconds. The browser process never establishes the Playwright Juggler protocol connection.

Error output:

<launched> pid=92
[pid=92][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: No GPUs detected via PCI
[pid=92][out]  (t=0.251986) [GFX1-]: No GPUs detected via PCI
[pid=92][err] [Parent 92, Main Thread] WARNING: Failed to create DBus proxy for org.a11y.Bus: The connection is closed

Minimal Dockerfile

FROM python:3.13-slim

# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    xvfb \
    dbus \
    dbus-x11 \
    libgtk-3-0 \
    libasound2 \
    libx11-xcb1 \
    libdbus-glib-1-2 \
    libgl1-mesa-dri \
    libegl1 \
    libpci3 \
    libpci-dev \
    gosu

# Create non-root user
RUN groupadd -r django && useradd -r -g django django

# Install Camoufox
RUN pip install playwright && \
    pip install https://github.com/coryking/camoufox/archive/refs/tags/v142.0.1-fork.27.tar.gz#subdirectory=pythonlib && \
    playwright install-deps && \
    HOME=/app python -m camoufox fetch

# Entrypoint: Start Xvfb as root, then switch to django user
RUN echo '#!/bin/bash\n\
dbus-daemon --session --fork || true\n\
Xvfb :99 -screen 0 1920x1080x24 -ac +extension GLX +render -noreset &\n\
export DISPLAY=:99\n\
sleep 2\n\
exec gosu django env HOME=/app "$@"\n\
' > /entrypoint.sh && chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]

Camoufox launch configuration

Threw a lot at the wall here, at this point have no idea really if anything is doing anything cause the error persists relentlessly.

firefox_prefs = {
            # CRITICAL: Disable sandbox in headless mode (fixes GPU detection hang)
            'security.sandbox.content.headless': False,
            'security.sandbox.content.level': 0,

            # Disable WebRender completely (legacy, may not work in Firefox 93+)
            'gfx.webrender.all': False,
            'gfx.webrender.enabled': False,
            'gfx.webrender.compositor': False,
            'gfx.webrender.compositor.force-enabled': False,

            # Disable GPU and hardware acceleration
            'layers.acceleration.disabled': True,
            'layers.acceleration.force-enabled': False,
            'gfx.direct2d.disabled': True,

            # Force software rendering
            'webgl.disabled': True,
            'webgl.force-enabled': False,
            'media.hardware-video-decoding.enabled': False,

            # Disable various GPU-related features
            'layers.gpu-process.enabled': False,
            'gfx.canvas.azure.accelerated': False,
            'browser.tabs.remote.autostart': False,

            # Additional stability settings for headless
            'media.navigator.enabled': False,
            'media.peerconnection.enabled': False,
        }


async with AsyncCamoufox( 
    headless=False,  # Using Xvfb instead of native headless
    geoip=False,
    humanize=False,
    addons=[],
    args=['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'],
    timeout=120000,
    firefox_user_prefs=firefox_prefs,
    env={
        'MOZ_DISABLE_CONTENT_SANDBOX': '1',
        'MOZ_DISABLE_GPU_SANDBOX': '1',
        'EGL_LOG_LEVEL': 'fatal',
        'DISPLAY': ':99',
    }
) as browser:
    page = await browser.new_page()  # Hangs here

What we've tried

  • Installed libpci3/libpci-dev
  • Tried both Camoufox and AsyncCamoufox
  • Tried with and without geoip
  • Running Xvfb as root (no _XSERVTransmkdir errors)
  • Using headless=False with Xvfb instead of native headless mode
  • Using native headless with headless=True
  • All sandbox disabling (env vars + Firefox prefs)
  • All GPU/WebRender prefs disabled
  • Non-root user execution

Related issues

This appears to be the same issue as daijro/camoufox#296 which remains unresolved.

Question

Is there a known workaround for Firefox 142 in Docker containers without GPU access? The fork works great locally but consistently fails in containerized environments. Hoping that a good deal of the active people have moved over to this fork and someone has dealt with this cause it's been a struggle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions