Reverts the default half of 4b20b77. That commit raised Xvfb's root window
from 1x1x24 to 1920x1080x24 for #458, on the reasoning that a 1x1 root
"breaks anything that measures the screen".
That reasoning does not hold here:
- screen.* never comes from the root window. It comes from the generated
fingerprint, applied per context in the browser, and
clamp_screen_to_display() is skipped outright for virtual displays (the
`not virtual_display` guard in utils.py), so a 1x1 root cannot clamp a
generated screen down to 1x1.
- #458's actual symptom -- blank/dark screenshots -- does not reproduce on
152.0.4-beta.28. Measured at both geometries on the same build, same page:
Xvfb 1x1x24 493 distinct colours, 57.5% dominant -> renders
Xvfb 1920x1080x24 493 distinct colours, 55.8% dominant -> renders
Identical. Firefox composites offscreen, so the root window size does not
gate rendering. A full-page screenshot of example.com under 1x1x24 is
pixel-correct.
1x1x24 is Camoufox's long-standing default and has run that way for years.
CAMOUFOX_VIRTUAL_DISPLAY_SIZE is kept as an escape hatch for anyone who does
want a real framebuffer, and still validates its input.
The Composite half of 4b20b77 was already reverted separately in 75d09a3.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
After the screencastFrameAck/timestamp fix, recording worked headless but still
produced nothing usable anywhere else: `headless="virtual"` and plain headful
both emitted a valid .webm containing 24 pure-white frames -- Playwright's
filler for a screencast that never delivered a frame.
nsScreencastService only has a working source when the browser is headless
(HeadlessWindowCapturer). Outside headless, CreateWindowCapturer falls through
to libwebrtc's X11 window capturer, which fails three different ways:
* no XComposite -> startVideoRecording() succeeds and then never delivers a
frame. This is Camoufox's own Xvfb configuration, which passes
`-extension COMPOSITE`;
* XComposite enabled -> the browser segfaults during capture (reproduced on
the shipped 152.0.4-beta.28 as well, so it is not specific to this branch);
* Wayland -> nsWindow::GetNativeData(NS_NATIVE_WINDOW_WEBRTC_DEVICE_ID) is
documented as unhandled and returns null, so the service throws
NS_ERROR_FAILURE ("Failed to get native window id") and no capture starts.
Capture from the compositor instead when not headless, via
WindowGlobalParent.drawSnapshot() -- the same call Page.screenshot already
uses, which is why screenshots have always worked in every mode. It renders
page content directly and does not care about the windowing system.
The tick is ack-driven, mirroring nsScreencastService's kMaxFramesInFlight = 1,
so a slow consumer throttles capture rather than queueing JPEGs. Headless keeps
the native C++ capturer, which is cheaper and already correct.
Measured on the packaged Linux build, 3s recording of an animated page, frames
decoded to PNG and inspected rather than trusting file existence:
before after
headless 100 frames, real unchanged, real
headless="virtual" 24 frames, all white 100 frames, real
headful (Xvfb, X11) 24 frames, all white 99 frames, real
headful (Wayland env) no capture at all 99 frames, real
tests/async/test_video.py passes 5/5 both headless and headful. Enabling
Composite no longer crashes either, since X11 window capture is now unused.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
9654452 enabled Xvfb's Composite extension on the theory that #93 (no video
under headless="virtual") was caused by disabling it. Measurement disproves it:
composite off + record_video_dir -> valid .webm, 24 pure-white frames
composite ON + record_video_dir -> browser dies with SIGSEGV, no video
composite ON + no recording -> fine
So compositing does not fix#93, and defaulting it on turns a blank recording
into a crash for anyone recording under a virtual display. The segfault
reproduces on the shipped 152.0.4-beta.28 too, so it is a pre-existing fault in
the screencast capture path rather than something this branch introduced -- but
that is exactly why it should not be reached by default.
Kept as an opt-in (CAMOUFOX_VIRTUAL_DISPLAY_COMPOSITE=1) for hosts with real
GL, where it may behave differently. The real-screen-size half of 9654452 is
unaffected and stays.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Two hardcoded Xvfb arguments, both verified against a live Xvfb with xdpyinfo.
#458 -- `-screen 0 1x1x24`. A 1x1 root window is not a plausible desktop: it
breaks anything that measures the screen, and it is the reason
clamp_screen_to_display() has to special-case virtual displays (a generated
fingerprint would otherwise be clamped to 1x1). Default to 1920x1080x24;
the framebuffer cost is ~8MB. Overridable per-run with
CAMOUFOX_VIRTUAL_DISPLAY_SIZE="1920x1080[x24]", which is validated and rejects
malformed values rather than passing them to Xvfb.
#93 -- `-extension COMPOSITE`. Offscreen rendering needs Composite, which is
what Playwright's video recording uses, so disabling it silently broke
record_video_dir under headless="virtual". A real X server has the extension,
so enabling it is also the more faithful default. Set
CAMOUFOX_VIRTUAL_DISPLAY_COMPOSITE=0 to restore the old behaviour.
Verified with xdpyinfo against real Xvfb instances:
default -> dimensions 1920x1080, Composite present
screen="800x600x24", composite=False -> dimensions 800x600, Composite absent
CAMOUFOX_VIRTUAL_DISPLAY_SIZE=2560x1440 -> resolves to 2560x1440x24
CAMOUFOX_VIRTUAL_DISPLAY_SIZE=bogus -> VirtualDisplayNotSupported
xvfb_args becomes a property so the two settings can vary per instance; the
existing VirtualDisplay(debug=...) call sites are unaffected.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Replace the terminate→wait→kill fallback in VirtualDisplay.kill() with a
direct SIGKILL to prevent zombie Xvfb processes. After the process exits,
remove the stale /tmp/.X{n}-lock and /tmp/.X11-unix/X{n} files so future
display allocations are not blocked. Also set self.proc = None to mark the
display as fully cleaned up.
Replace the userspace lock-file scan + random-jitter retry loop with
Xvfb's own -displayfd mechanism. Xvfb scans up from :0 and atomically
binds the first free X11 socket (kernel-mediated, no userspace race),
then writes the chosen display number back through an inherited pipe.
This eliminates the duplicate-display race that occurred when many
camoufox processes started concurrently and all observed the same set
of free display numbers before any of them bound.
Adds a 10s read timeout on the displayfd pipe so a hung Xvfb fails
fast instead of blocking forever, and adds tests covering single
launch, idempotent get(), 50 concurrent reservations with uniqueness,
and post-kill display reuse.
- Added window: Tuple[int, int] argument to set a fixed width and height #50
- Experimental fix to automatically terminate Xvfb on browser.close() #49
- Bump to 0.3.1
- Removed warnings for using headless mode
- Xvfb is now activated with headless='virtual'
- Correctly pass window.screenX & calculate window.screenY
- Update documentation on main README and pythonlib README
- Bumped pythonlib to 0.2.10