-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Browser Environment fails to initialize on macOS with Chromium headless mode
π Bug Description
AutoAgent fails to start on macOS because Playwright's Chromium browser crashes immediately in headless mode. The error occurs during browser environment initialization.
π» Environment
- OS: macOS 26.0 (Build 25A354)
- Python: 3.12.11 (via pyenv)
- AutoAgent: 0.1.0
- Playwright: 1.39.0
- BrowserGym: 0.13.0
- browsergym-core: 0.13.0
- Architecture: ARM64 (Apple Silicon)
π΄ Error Output
____________________Browser Env____________________
[2025-10-07 00:49:22]
Starting browser env...
Process Process-1:
Traceback (most recent call last):
File "/Users/vladislaviskov/.pyenv/versions/3.12.11/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/Users/vladislaviskov/.pyenv/versions/3.12.11/lib/python3.12/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/Users/vladislaviskov/Desktop/agent/AutoAgent/autoagent/environment/browser_env.py", line 475, in browser_process
obs, info = env.reset()
^^^^^^^^^^^
File "/Users/vladislaviskov/.pyenv/versions/3.12.11/lib/python3.12/site-packages/browsergym/core/env.py", line 221, in reset
self.browser = pw.chromium.launch(
^^^^^^^^^^^^^^^^^^^
playwright._impl._api_types.Error: Browser closed.
==================== Browser output: ====================
<launching> /Users/vladislaviskov/Library/Caches/ms-playwright/chromium-1084/chrome-mac/Chromium.app/Contents/MacOS/Chromium --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --enable-use-zoom-for-dsf=false --use-angle --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/var/folders/rn/gym3bnf52pg94rdfjjxy6ryw0000gn/T/playwright_chromiumdev_profile-K7Uemr --remote-debugging-pipe --no-startup-window
<launched> pid=79873
π Steps to Reproduce
-
Install AutoAgent on macOS (Apple Silicon):
git clone https://github.com/HKUDS/AutoAgent.git cd AutoAgent pip install -e . playwright install
-
Create
.envfile with OpenAI API key:cp .env.template .env # Add OPENAI_API_KEY=your_key -
Run AutoAgent:
COMPLETION_MODEL=gpt-4o auto main
-
Browser environment fails to initialize
π§ͺ Additional Testing
β What Works:
- Chromium launches successfully in non-headless mode
- Running Chromium binary directly:
/Users/.../chromium-1084/.../Chromium --versionβ - Firefox launches successfully in headless mode
- Docker containers created successfully
- All other components work fine
β What Doesn't Work:
- Chromium in headless mode (
--headlessflag) - Trying Firefox as alternative fails because BrowserGym requires CDP (Chrome DevTools Protocol), which is Chromium-only
Test Results:
# Firefox works but CDP not available
python3 -c "from playwright.sync_api import sync_playwright; p = sync_playwright().start(); browser = p.firefox.launch(headless=True); print('OK'); browser.close()"
# β
Output: OK
# But CDP fails with Firefox
playwright._impl._api_types.Error: CDP session is only available in Chromiumπ‘ Potential Causes
This appears to be a macOS security issue with Playwright's Chromium in headless mode on newer macOS versions (especially Apple Silicon). Similar issues reported:
- [BUG] No tests found using the test explorer - pw/[email protected]Β microsoft/playwright#17500
- [BUG] Using libsoup2 and libsoup3 in the same process is not supported.Β microsoft/playwright#27313
π§ Attempted Workarounds
1. Removed quarantine attribute:
xattr -d com.apple.quarantine ~/Library/Caches/ms-playwright/chromium-1084/chrome-mac/Chromium.app
# Already no quarantine attribute2. Tried Firefox:
- Patched
browsergym/core/env.pyandbrowsergym/core/chat.pyto usepw.firefox.launch() - Firefox launches successfully but fails with:
CDP session is only available in Chromium
3. Updated Playwright:
- Attempted upgrade to 1.55.0 but incompatible with libwebarena/libvisualwebarena requirements
π Proposed Solutions
Option 1: Add Firefox Support to BrowserGym
Make BrowserGym work without CDP for Firefox compatibility
Option 2: Optional Browser Environment
Add a flag to disable browser environment for users who don't need web browsing:
web_env = BrowserEnv(..., disable=True) # Skip browser initOption 3: Use headed mode on macOS
Add OS detection and use headed mode (with virtual display) on problematic macOS versions
Option 4: Documentation Update
Add clear documentation about:
- Known issue with macOS 25.0+
- Recommend Linux/Windows WSL2 for browser-based tasks
- Workarounds or limitations
π Workaround for Users
Currently, users on affected macOS versions cannot run AutoAgent with browser environment. Temporary solutions:
- Use Linux VM or Docker
- Use Windows with WSL2
- Wait for fix
π€ Questions
- Is there a way to run AutoAgent without browser environment for non-web tasks?
- Could we add an environment variable like
AUTOAGENT_DISABLE_BROWSER=true? - Any plans to support newer macOS versions or alternative browsers?
Would love to help test any fixes! π