Skip to content

Engines

PAM Crawl Browser renders pages with one of three engines: a headless Chrome (or Chromium) it launches, a Lightpanda process it launches, or a remote browser you already run and reach over the Chrome DevTools Protocol. By default it picks the lightest engine that can do what each request needs.

Chrome Lightpanda
What Google Chrome or Chromium, headless Lightpanda, a headless browser without a rendering engine
Found at /usr/bin/google-chrome, Playwright’s Chromium, PATH, PAM_CRAWL_CHROME ~/.local/share/pam-crawl/bin/lightpanda, PATH, PAM_CRAWL_LIGHTPANDA
Memory, 1 tab / 8 tabs (PSS) 355 MB / 469 MB (21 processes) 23 MB / 42 MB (1 process)
SPA render (fixture, warm) 0.85 s 0.84 s
16 SPAs, 8 tabs 1.9 s 1.7 s
JavaScript, waits, scrolling, virtual scroll, shadow DOM, consent removal, stealth Yes Yes
Headers, cookies, user agent, locale, time zone, viewport, resource blocking Yes Yes (images and CSS are never loaded)
Network and console capture, status, redirects Yes Yes
Screenshots, PDF, MHTML Yes Routed to Chrome
Geolocation, iframe inlining Yes Routed to Chrome
Downloads, persistent profiles Yes No
HTML form submission Yes No

The timings and memory figures come from the package’s own fixtures and describe that setup only; measure your own pages.

crawl.php
use Pam\Crawl\Crawl;
Crawl::urls($urls)->engine('auto')->render(); // the default
Crawl::urls($urls)->engine('lightpanda')->browser();
Crawl::urls($urls)->engine('chrome')->browser();
Crawl::urls($urls)->engine('ws://10.0.0.5:9222/devtools/browser/abc')->browser();
Engine Behaviour
auto Lightpanda when it is installed and the request needs nothing Lightpanda lacks; otherwise Chrome. A page Lightpanda fails is retried in Chrome.
chrome Always Chrome
lightpanda Lightpanda; unsupported features and failed renders fall back to Chrome per request
A CDP endpoint ws:// / wss://host:port/devtools/browser/..., or http:// / https://host:9222 (discovered through /json/version)

On the command line, use --engine auto|chrome|lightpanda or --cdp URL.

Each renderer starts at most one Chrome and one Lightpanda, lazily, on first use. close() (or the renderer’s destructor) stops exactly those processes by their own process handles; nothing else on the machine is touched. Browsers you reach through a CDP endpoint are never launched or killed.

use Pam\Crawl\Browser\BrowserConfig;
use Pam\Crawl\Browser\BrowserRenderer;
$renderer = BrowserRenderer::chrome(new BrowserConfig(
tabs: 4,
recycleAfter: 50,
chromeArgs: ['--lang=en-US'],
));
try {
// crawl with ->browser($renderer) or ->render($renderer)
} finally {
$renderer->close();
}
Property Default Description
chromePath auto-detected Chrome binary (PAM_CRAWL_CHROME overrides)
lightpandaPath auto-detected Lightpanda binary (PAM_CRAWL_LIGHTPANDA overrides)
headless true Run Chrome headless
gpu true GPU rendering in Chrome
gpuArgs, gpuEnv ANGLE over EGL Chrome switches and environment for GPU rendering
chromeArgs, lightpandaArgs [] Extra command-line switches
userDataDir null Persistent Chrome profile directory
proxy null http://user:pass@host:port or socks5://host:port
verifyTls true Verify TLS certificates of visited pages
tabs 4 Concurrent tabs per engine
recycleAfter 50 Close and reopen a tab after this many pages, to bound memory
launchTimeout 20.0 Seconds to wait for a browser to start
downloadsPath null Where downloads go; null cancels them
screenshotHeightThreshold 10000 Taller pages are captured in chunks
maxPayloadBytes 64 MiB Largest CDP message accepted
lightpandaCapture false Let Lightpanda produce screenshots and PDFs
fallbackToChrome true Retry a request in Chrome when Lightpanda fails it
cdpCaFile null Extra CA bundle for wss:// and https:// CDP endpoints

When the crawler creates the renderer for you, the same settings come from the crawl’s render options and their extra keys (tabs, chromePath, gpu…). Tabs default to min(8, concurrency). See the Options Reference.

Chrome runs on the GPU by default, with --use-gl=angle --use-angle=gl-egl --ignore-gpu-blocklist --enable-gpu, the NVIDIA EGL vendor file when it is present, and __NV_PRIME_RENDER_OFFLOAD=1. It never falls back to SwiftShader. On machines without a GPU (most servers and containers), turn it off:

Terminal window
export PAM_CRAWL_SOFTWARE_GL=1

or pass new BrowserConfig(gpu: false) / the extra['gpu' => false] render option.

Connect to a browser you run elsewhere, for example a Chrome container or a hosted browser service:

$renderer = BrowserRenderer::connect('wss://cdp.example.com/devtools/browser/abc');
// or discovery over HTTP(S):
$renderer = BrowserRenderer::connect('https://cdp.example.com');

TLS endpoints always verify certificates and host names (SNI). To trust a private certificate authority, set cdpCaFile in BrowserConfig or extra['cdpCaFile' => '/path/ca.pem'].

With captureNetwork() and extra['networkBodies' => true], each response entry in $page->network gets body (UTF-8 text), body_size and body_base64. The plugin requests bodies after the response finishes loading, at most 16 at a time, within these limits:

Option Default Limit
networkBodyMaxBytes 1 MiB Per body; longer bodies are cut and flagged body_truncated
networkBodyTotalBytes 16 MiB All bodies of one page
networkBinaryBodies false When true, binary bodies are kept as base64; otherwise they are skipped with body_skipped: "binary"

Responses larger than 32 MiB are never requested.

The processIframes option inlines iframes into the page HTML. Same-origin frames are inlined from page JavaScript; cross-origin frames are inlined over CDP, out-of-process frames through auto-attached sessions and same-site frames through an isolated world. Each becomes a div.extracted-iframe-content-N element (with data-cross-origin when applicable), and $page->response->artifacts['iframes'] reports what was inlined, skipped and crossOrigin.


This product includes software developed by UncleCode (https://x.com/unclecode) as part of the Crawl4AI project (https://github.com/unclecode/crawl4ai).