Stabilize recorded Chrome startup

This commit is contained in:
2026-08-03 00:55:53 +03:30
parent 71790cf0ad
commit 061b03eee5
2 changed files with 14 additions and 7 deletions
+11 -6
View File
@@ -91,7 +91,6 @@ def _build_options(
chrome_binary: str,
profile_dir: str | None = None,
display: str | None = None,
initial_url: str | None = None,
) -> Options:
opts = Options()
opts.binary_location = chrome_binary
@@ -108,14 +107,17 @@ def _build_options(
opts.add_argument(f"--user-agent={user_agent}")
opts.add_argument("--no-sandbox")
opts.add_argument("--disable-gpu")
opts.add_argument("--disable-logging")
opts.add_argument("--no-first-run")
opts.add_argument("--no-default-browser-check")
opts.add_argument("--disable-background-networking")
opts.add_argument("--disable-component-update")
opts.add_argument("--disable-default-apps")
opts.add_argument("--disable-sync")
opts.add_argument("--renderer-process-limit=2")
opts.add_argument("--disable-blink-features=AutomationControlled")
opts.add_argument("--disable-infobars")
opts.add_argument("--window-size=1920,1080")
if initial_url and initial_url.startswith(("http://", "https://")):
# Opening the configured page as a Chrome process argument avoids
# waiting for the initial New Tab renderer before navigation begins.
opts.add_argument(initial_url)
return opts
@@ -135,7 +137,6 @@ def make_driver(
chrome_binary,
profile_dir,
display,
initial_url,
)
log.info(
@@ -150,6 +151,10 @@ def make_driver(
driver_executable_path=_local_driver_path(),
version_main=major,
use_subprocess=True,
# undetected-chromedriver captures Chrome stdout/stderr in pipes but
# does not drain them. Fatal-only logging prevents a full pipe from
# freezing Chrome during renderer startup in Docker.
log_level=3,
)
log.info("ChromeDriver connected")