PathOnAI / LiteWebAgent

The Library for LLM-based web-agent applications
Other
25 stars 4 forks source link

"Browser Closed" Error Message #103

Closed zleung9 closed 1 day ago

zleung9 commented 2 days ago

The following error message appears when running python -m prompting_main --agent_type PromptAgent --starting_url https://www.google.com --goal 'search dining table' --plan 'search dining table' --log_folder log

System: Mac OS sequoia 15.0

* 'allow_population_by_field_name' has been renamed to 'populate_by_name'
* 'smart_union' has been removed
  warnings.warn(message, UserWarning)
Traceback (most recent call last):
  File "/Users/zhuliang/miniconda3/envs/agent/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/zhuliang/miniconda3/envs/agent/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/zhuliang/LiteWebAgent/prompting_main.py", line 42, in <module>
    main(args)
  File "/Users/zhuliang/LiteWebAgent/prompting_main.py", line 13, in main
    agent = setup_prompting_web_agent(args.starting_url, args.goal, model_name=args.model, agent_type=args.agent_type,
  File "/Users/zhuliang/LiteWebAgent/litewebagent/core/agent_factory.py", line 103, in setup_prompting_web_agent
    playwright_manager = setup_playwright(log_folder=log_folder, storage_state=storage_state, headless=headless)
  File "/Users/zhuliang/LiteWebAgent/litewebagent/utils/playwright_manager.py", line 71, in setup_playwright
    browser = playwright_manager.get_browser()
  File "/Users/zhuliang/LiteWebAgent/litewebagent/utils/playwright_manager.py", line 39, in get_browser
    self.initialize()
  File "/Users/zhuliang/LiteWebAgent/litewebagent/utils/playwright_manager.py", line 35, in initialize
    self.page = self.context.new_page()
  File "/Users/zhuliang/miniconda3/envs/agent/lib/python3.10/site-packages/playwright/sync_api/_generated.py", line 13095, in new_page
    return mapping.from_impl(self._sync(self._impl_obj.new_page()))
  File "/Users/zhuliang/miniconda3/envs/agent/lib/python3.10/site-packages/playwright/_impl/_sync_base.py", line 109, in _sync
    return task.result()
  File "/Users/zhuliang/miniconda3/envs/agent/lib/python3.10/site-packages/playwright/_impl/_browser_context.py", line 281, in new_page
    return from_channel(await self._channel.send("newPage"))
  File "/Users/zhuliang/miniconda3/envs/agent/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 61, in send
    return await self._connection.wrap_api_call(
  File "/Users/zhuliang/miniconda3/envs/agent/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 490, in wrap_api_call
    return await cb()
  File "/Users/zhuliang/miniconda3/envs/agent/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 99, in inner_send
    result = next(iter(done)).result()
playwright._impl._api_types.Error: Browser closed.
==================== Browser output: ====================
<launching> /Users/zhuliang/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 --no-sandbox --user-data-dir=/var/folders/nv/h5cfm2gd78v2d87kk61rn2140000gn/T/playwright_chromiumdev_profile-q0AcyR --remote-debugging-pipe --no-startup-window
<launched> pid=66672
[pid=66672][err] [66672:259:1019/104851.030023:ERROR:policy_logger.cc(157)] :components/enterprise/browser/controller/chrome_browser_cloud_management_controller.cc(163) Cloud management controller initialization aborted as CBCM is not enabled.
[pid=66672][err] Received signal 11 SEGV_ACCERR 000100000008
[pid=66672][err]  [0x00011522b2a4]
[pid=66672][err]  [0x000119313484]
[pid=66672][err]  [0x00011931fe2c]
[pid=66672][err]  [0x00018d828184]
[pid=66672][err]  [0x00019e7b19e0]
[pid=66672][err]  [0x00019e638634]
[pid=66672][err]  [0x00019e7d3a10]
[pid=66672][err]  [0x00019e7d4a64]
[pid=66672][err]  [0x00018ede6efc]
[pid=66672][err]  [0x00018ee74394]
[pid=66672][err]  [0x00018f032234]
[pid=66672][err]  [0x00018f0320f8]
[pid=66672][err]  [0x00018f035fa4]
[pid=66672][err]  [0x00018ef70524]
[pid=66672][err]  [0x00018d8a6fc4]
[pid=66672][err]  [0x00018dd58660]
[pid=66672][err]  [0x00018dd58070]
[pid=66672][err]  [0x00018dd557dc]
[pid=66672][err]  [0x00019414a29c]
[pid=66672][err]  [0x000194148ad0]
[pid=66672][err]  [0x00019213df9c]
[pid=66672][err]  [0x00019213ec94]
[pid=66672][err]  [0x00019213eaf8]
[pid=66672][err]  [0x0001921411e4]
[pid=66672][err]  [0x0001913e902c]
[pid=66672][err]  [0x0001913e6e80]
[pid=66672][err]  [0x0001913e69b4]
[pid=66672][err]  [0x000119329030]
[pid=66672][err]  [0x000119287e48]
[pid=66672][err]  [0x0001192e4fc4]
[pid=66672][err]  [0x0001182f70cc]
[pid=66672][err]  [0x000118717eb4]
[pid=66672][err]  [0x000118718bb4]
[pid=66672][err]  [0x0001187171b8]
[pid=66672][err]  [0x0001187175bc]
[pid=66672][err]  [0x000115200fd8]
[pid=66672][err]  [0x000102d4ca6c]
[pid=66672][err]  [0x00018d470274]
[pid=66672][err] [end of stack trace]
[pid=66672][err] [1019/104851.407888:WARNING:in_range_cast.h(38)] value -634136515 out of range
[pid=66672][err] Received signal 11 SEGV_ACCERR 000100000008
[pid=66672][err]  [0x00011e82f2a4]
[pid=66672][err]  [0x000122917484]
[pid=66672][err]  [0x000122923e2c]
[pid=66672][err]  [0x00018d828184]
[pid=66672][err]  [0x00019e7b19e0]
[pid=66672][err]  [0x00019e638634]
[pid=66672][err]  [0x00019e7d3a10]
[pid=66672][err]  [0x00019e7d4a64]
[pid=66672][err]  [0x00018ede6efc]
[pid=66672][err]  [0x00018ee74394]
[pid=66672][err]  [0x00018f032234]
[pid=66672][err]  [0x00018f0320f8]
[pid=66672][err]  [0x00018f035fa4]
[pid=66672][err]  [0x00018ef70524]
[pid=66672][err]  [0x00018d8a6fc4]
[pid=66672][err]  [0x00018dd58660]
[pid=66672][err]  [0x00018dd58070]
[pid=66672][err]  [0x00018dd557dc]
[pid=66672][err]  [0x00019414a29c]
[pid=66672][err]  [0x000194148ad0]
[pid=66672][err]  [0x00019213df9c]
[pid=66672][err]  [0x00019213ec94]
[pid=66672][err]  [0x00019213eaf8]
[pid=66672][err]  [0x0001921411e4]
[pid=66672][err]  [0x0001913e902c]
[pid=66672][err]  [0x0001913e6e80]
[pid=66672][err]  [0x0001913e69b4]
[pid=66672][err]  [0x00012292d030]
[pid=66672][err]  [0x00012288be48]
[pid=66672][err]  [0x0001228e8fc4]
[pid=66672][err]  [0x0001218fb0cc]
[pid=66672][err]  [0x000121d1beb4]
[pid=66672][err]  [0x000121d1cbb4]
[pid=66672][err]  [0x000121d1b1b8]
[pid=66672][err]  [0x000121d1b5bc]
[pid=66672][err]  [0x00011e804fd8]
[pid=66672][err]  [0x0001025cca6c]
[pid=66672][err]  [0x00018d470274]
[pid=66672][err] [end of stack trace]
[pid=66672][err] [1019/104851.776703:WARNING:in_range_cast.h(38)] value -634136515 out of range
[pid=66672][err] [1019/104851.976455:WARNING:in_range_cast.h(38)] value -634136515 out of range
[pid=66672][err] [1019/104852.047105:WARNING:crash_report_exception_handler.cc(235)] UniversalExceptionRaise: (os/kern) failure (5)
/Users/zhuliang/miniconda3/envs/agent/lib/python3.10/site-packages/playwright/driver/package/lib/server/chromium/crPage.js:492
    this._firstNonInitialNavigationCommittedReject(new Error('Page closed'));
                                                   ^

Error: Page closed
    at FrameSession.dispose (/Users/zhuliang/miniconda3/envs/agent/lib/python3.10/site-packages/playwright/driver/package/lib/server/chromium/crPage.js:492:52)
    at CRPage.didClose (/Users/zhuliang/miniconda3/envs/agent/lib/python3.10/site-packages/playwright/driver/package/lib/server/chromium/crPage.js:152:60)
    at CRBrowser._didDisconnect (/Users/zhuliang/miniconda3/envs/agent/lib/python3.10/site-packages/playwright/driver/package/lib/server/chromium/crBrowser.js:216:57)
    at CRConnection.<anonymous> (/Users/zhuliang/miniconda3/envs/agent/lib/python3.10/site-packages/playwright/driver/package/lib/server/chromium/crBrowser.js:94:81)
    at CRConnection.emit (node:events:517:28)
    at /Users/zhuliang/miniconda3/envs/agent/lib/python3.10/site-packages/playwright/driver/package/lib/server/chromium/crConnection.js:84:39

Node.js v18.18.0
Tata0703 commented 2 days ago

Based on what you've described, the issue might be due to browser corruption or outdated package version. You can try

Reinstall Playwright and browser binaries:

playwright install

Update Playwright and Chromium:

pip install --upgrade playwright
playwright install

These steps can help resolve crashes or unexpected behavior by ensuring you have the latest, uncorrupted versions of Playwright and its associated browser binaries.

Tata0703 commented 2 days ago

I didn't encounter SEGV_ACCERR issues, but I did some research and found that the signal SEGV_ACCERR is often linked to memory access violations. Make sure your system has sufficient memory and isn't experiencing issues like low disk space.

Tata0703 commented 2 days ago

I added a script for testing installation: https://github.com/PathOnAI/LiteWebAgent/blob/main/test_installation.py

Please test playwright & chromium installation by running this script

python /Users/danqingzhang/Desktop/test_installation.py 
zleung9 commented 1 day ago

Upgrading playwright and re-installing browsers worked for me. Thank you!