High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: disable --in-process-gpu by default to avoid chrome 148 headless crash
Luigi Agostic05966391ed7
diff --git a/internal/bridge/bridge_lifecycle.go b/internal/bridge/bridge_lifecycle.goindex abbb6ae8..338900ea 100644--- a/internal/bridge/bridge_lifecycle.go+++ b/internal/bridge/bridge_lifecycle.go@@ -135,7 +135,7 @@ func (b *Bridge) EnsureChrome(cfg *config.RuntimeConfig) error {if b.BrowserCtx.Err() == nil {return nil}- slog.Warn("chrome context cancelled, re-initializing without in-process-gpu")+ slog.Warn("chrome browser context cancelled, re-initializing")b.initialized = falseb.BrowserCtx = nilb.BrowserCancel = nildiff --git a/internal/bridge/runtime/init.go b/internal/bridge/runtime/init.goindex 8ecdc6fd..860aadbb 100644--- a/internal/bridge/runtime/init.go+++ b/internal/bridge/runtime/init.go@@ -223,14 +223,15 @@ func setupAllocator(cfg *config.RuntimeConfig, bundle *stealth.Bundle, hooks Hoo// silently ignored and the compositor has no backend, which// manifests as Page.captureScreenshot/printToPDF hanging.opts = append(opts, chromedp.Flag("enable-unsafe-swiftshader", true))- // Collapse the GPU process into the browser process. Saves one- // OS process and ~50-150MB per Chrome instance, and avoids the- // GPU-process sandbox negotiation in our --no-sandbox containers.- // Trade-off: a GPU code crash takes the browser with it. Disabled- // automatically after a crash so the failure doesn't repeat.- if !cfg.DisableInProcessGPU {- opts = append(opts, chromedp.Flag("in-process-gpu", true))- }+ // --in-process-gpu used to be enabled here as a perf optimization+ // (saves one OS process and ~50-150MB per instance). Chrome stable+ // patch updates have repeatedly regressed it for the headless=new+ // + swiftshader combo: a GPU code crash takes the browser with it+ // ~500ms after init, surfacing as `context canceled` on the first+ // CreateTab. We now leave it off by default. Users who know their+ // Chrome build is healthy and want the memory savings can opt in+ // via `browser.extraFlags = "--in-process-gpu"`. DisableInProcessGPU+ // is still honored as a kill switch by the crash-recovery path.} else {opts = append(opts, chromedp.Flag("headless", false))}@@ -256,7 +257,13 @@ func setupAllocator(cfg *config.RuntimeConfig, bundle *stealth.Bundle, hooks Hooopts = append(opts, chromedp.Flag("tz", cfg.Timezone))}- opts = appendExecAllocatorFlags(opts, config.AllowedChromeExtraFlags(cfg.ChromeExtraFlags))+ extraFlags := config.AllowedChromeExtraFlags(cfg.ChromeExtraFlags)+ if cfg.DisableInProcessGPU {+ // Kill switch from the crash-recovery path: strip a user-supplied+ // --in-process-gpu so a crash loop can't repeat after retry.+ extraFlags = stripInProcessGPUFlag(extraFlags)+ }+ opts = appendExecAllocatorFlags(opts, extraFlags)for _, flag := range appendChromeCompatibilityFlags(nil) {opts = appendExecAllocatorFlag(opts, flag)}@@ -408,6 +415,18 @@ func applyStartupStealth(ctx context.Context, cfg *config.RuntimeConfig, bundlereturn injectedScript(ctx, script)}+func stripInProcessGPUFlag(flags []string) []string {+ out := flags[:0]+ for _, f := range flags {+ name := strings.SplitN(f, "=", 2)[0]+ if strings.EqualFold(name, "--in-process-gpu") {+ continue+ }+ out = append(out, f)+ }+ return out+}+func missingBrowserBinaryError(cfg *config.RuntimeConfig) error {browserID := config.NormalizeBrowser(cfg.DefaultBrowser)if b, ok := browsers.Get(browserID); ok {diff --git a/internal/config/config_types.go b/internal/config/config_types.goindex c95b9d4d..9d4a0136 100644--- a/internal/config/config_types.go+++ b/internal/config/config_types.go@@ -48,7 +48,7 @@ type RuntimeConfig struct {// Browser/instance settingsHeadless boolHeadlessSet bool // true when explicitly set via config or flag- DisableInProcessGPU bool // runtime-only: set after a GPU crash to avoid repeating the failure+ DisableInProcessGPU bool // runtime-only: kill switch for --in-process-gpu when a user opted in via browser.extraFlags and the browser then crashedNoRestore boolProfileDir stringProfilesBaseDir string