Skip to content

[BUG] Regression - chromium browser closes during test or debugging session on macos #12974

Closed

Description

@str0zzapreti

Context:

  • Playwright Version: 1.20.0
  • Operating System: Macos 11.6.5
  • Python version: Python 3.10.2
  • Browser: Chromium

Code Snippet

The easiest way to replicate this issue is to just add a breakpoint in the following snippet after launching the browser, e.g. line 5, and then initialize the debugger and wait for it to reach the breakpoint. Then just wait and Chromium will suddenly close all on its own within a minute or two.

with sync_playwright() as p:
    browser = p.chromium.launch(headless=False)
    page = browser.new_page()
    page.goto("http://playwright.dev/")
    print(page.title())
    browser.close()

Describe the bug

This issue began to occur after upgrading playwright to version 1.20.0 on my local machine. We have ~30 playwright tests that get parameterized to run in both Firefox and Chromium and I validated that everything was working by running the full test suite inside an Ubuntu Focal Docker container. So far, so good. The issue started to occur when I was helping a colleague debug an issue in headed mode and my chromium browser kept quitting in the middle of the debug session. The Playwright process continued running.

Then I tried running our full test suite locally in MacOS and after about 15-17 tests, all of the remaining chromium tests would instantly fail with an error indicating the page was already closed. This is extremely consistent and persisted through reboots and rebuilding my venv (I had been testing a pytest-parallel plugin and wanted to make sure it wasn't interfering) and only stops occurring when I downgrade playwright to 1.18.2 which is the last stable version we were using. I've included the traceback from the first chromium test that fails during each session. Seems to be some kind of memory error.

TLDR

  • Playwright 1.20.0 Chromium appears to crash after running for a minute or two on MacOS
  • Firefox does not exhibit this issue (I haven't tested webkit)
  • This issue does not occur in Linux (haven't tested windows)
  • This is a regression since 1.18.2 which was the last version I tested (we skipped over 1.19.x)

Traceback

self = <playwright._impl._connection.Channel object at 0x1089be530>
method = 'click', params = {'selector': 'a[href="/app/edit-recruiter-profile"]'}
return_as_dict = False
    async def inner_send(
        self, method: str, params: Optional[Dict], return_as_dict: bool
    ) -> Any:
        if params is None:
            params = {}
        callback = self._connection._send_message_to_server(self._guid, method, params)
        if self._connection._error:
            error = self._connection._error
            self._connection._error = None
            raise error
        done, _ = await asyncio.wait(
            {
                self._connection._transport.on_error_future,
                callback.future,
            },
            return_when=asyncio.FIRST_COMPLETED,
        )
        if not callback.future.done():
            callback.future.cancel()
>       result = next(iter(done)).result()
E       playwright._impl._api_types.Error: Browser closed.
E       ==================== Browser output: ====================
E       <launching> /Users/silasj/Library/Caches/ms-playwright/chromium-978106/chrome-mac/Chromium.app/Contents/MacOS/Chromium --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,AcceptCHFrame,AutoExpandDetailsElement --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --enable-use-zoom-for-dsf=false --no-sandbox --user-data-dir=/var/folders/kv/d09mrzfj49l9yp6hqzg58v840000gn/T/playwright_chromiumdev_profile-ibOEpD --remote-debugging-pipe --no-startup-window
E       <launched> pid=2236
E       [pid=2236][err] Received signal 6
E       [pid=2236][err]  [0x000118efda79]
E       [pid=2236][err]  [0x000118e59d13]
E       [pid=2236][err]  [0x000118efd9d1]
E       [pid=2236][err]  [0x7fff208d1d7d]
E       [pid=2236][err]  [0x7ffee14fb5d8]
E       [pid=2236][err]  [0x7fff207e1406]
E       [pid=2236][err]  [0x7fff206c1165]
E       [pid=2236][err]  [0x7fff206c42aa]
E       [pid=2236][err]  [0x000118a4b0fc]
E       [pid=2236][err]  [0x00011628f6af]
E       [pid=2236][err]  [0x000115395f67]
E       [pid=2236][err]  [0x0001166f4d1e]
E       [pid=2236][err]  [0x000118ee42e9]
E       [pid=2236][err]  [0x000118eb8a60]
E       [pid=2236][err]  [0x000118ecd979]
E       [pid=2236][err]  [0x000118ecd69c]
E       [pid=2236][err]  [0x000118ecde72]
E       [pid=2236][err]  [0x000118f0f323]
E       [pid=2236][err]  [0x000118f09cf2]
E       [pid=2236][err]  [0x000118f0ed5f]
E       [pid=2236][err]  [0x7fff2098437c]
E       [pid=2236][err]  [0x7fff209842e4]
E       [pid=2236][err]  [0x7fff20984064]
E       [pid=2236][err]  [0x7fff20982a8c]
E       [pid=2236][err]  [0x7fff2098204c]
E       [pid=2236][err]  [0x7fff28bcaa83]
E       [pid=2236][err]  [0x7fff28bca7e5]
E       [pid=2236][err]  [0x7fff28bca583]
E       [pid=2236][err]  [0x7fff2318ad72]
E       [pid=2236][err]  [0x7fff23189545]
E       [pid=2236][err]  [0x000118a12ab0]
E       [pid=2236][err]  [0x000118f09cf2]
E       [pid=2236][err]  [0x000118a129e9]
E       [pid=2236][err]  [0x7fff2317b869]
E       [pid=2236][err]  [0x000118f0fa2c]
E       [pid=2236][err]  [0x000118f0e892]
E       [pid=2236][err]  [0x000118ece0dd]
E       [pid=2236][err]  [0x000118e9843d]
E       [pid=2236][err]  [0x00011661ff7b]
E       [pid=2236][err]  [0x000116621612]
E       [pid=2236][err]  [0x00011661d8dc]
E       [pid=2236][err]  [0x00011899d4e8]
E       [pid=2236][err]  [0x00011899e53a]
E       [pid=2236][err]  [0x00011899e0cb]
E       [pid=2236][err]  [0x00011899c84c]
E       [pid=2236][err]  [0x00011899d0d0]
E       [pid=2236][err]  [0x0001152271be]
E       [pid=2236][err]  [0x00010e7018d1]
E       [pid=2236][err]  [0x7fff208a7f3d]
E       [pid=2236][err]  [0x000000000020]
E       [pid=2236][err] [end of stack trace]
E       [pid=2236][err] [0322/180717.089119:WARNING:process_memory_mac.cc(93)] mach_vm_read(0x7ffee14fe000, 0x2000): (os/kern) invalid address (1)
E       [pid=2236][err] [0322/180717.250919:WARNING:crash_report_exception_handler.cc(235)] UniversalExceptionRaise: (os/kern) failure (5)
E       =========================== logs ===========================
E       waiting for selector "a[href="/app/edit"]"
E         selector resolved to visible <a data-v-d7081870="" data-v-1b7f802e="" href="/app…>Complete task</a>
E       attempting click action
E         waiting for element to be visible, enabled and stable
E           element is not stable - waiting...
E       ============================================================
../venv/lib/python3.10/site-packages/playwright/_impl/_connection.py:63: Error

Activity

  1. devkat commented on Mar 23, 2022

    @devkat
    Contributor

    I am facing a similar issue:

    • macOS 12.3 Monterey
    • Playwright 1.20.0 Chromium; inspector mode (PWDEBUG=1)
        locator.click: Browser closed.
        ==================== Browser output: ====================
        <launching> /Users/…/Library/Caches/ms-playwright/chromium-978106/chrome-mac/Chromium.app/Contents/MacOS/Chromium --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,AcceptCHFrame,AutoExpandDetailsElement --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --enable-use-zoom-for-dsf=false --no-sandbox --user-data-dir=/var/folders/k5/kg1jspx52tz3t_gmj8_cdpxh0000gn/T/playwright_chromiumdev_profile-8oWsSX --remote-debugging-pipe --no-startup-window
        <launched> pid=76314
        [pid=76314][err] objc[76325]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x7ffa5b3a1318) and /Users/…/Library/Caches/ms-playwright/chromium-978106/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/101.0.4929.0/Libraries/libGLESv2.dylib (0x113fafbf0). One of the two will be used. Which one is undefined.
        [pid=76314][err] Received signal 6
        [pid=76314][err]  [0x000128658a79]
        …
        [pid=76314][err] [end of stack trace]
        [pid=76314][err] [0323/125121.744605:WARNING:crash_report_exception_handler.cc(235)] UniversalExceptionRaise: (os/kern) failure (5)
        =========================== logs ===========================
        waiting for selector ".ant-select-item-option-content:has-text("admin")"
        ============================================================
    
  2. mxschmitt commented on Mar 23, 2022

    @mxschmitt
    Contributor

    I was able to repro on 1.20.0 but it seems fixed on ToT.

    PWDEBUG=1 node test.js

    const pw = require("playwright");
    
    (async () => {
      const browser = await pw.chromium.launch();
      const page = await browser.newPage();
      await page.goto("https://example.com");
    })()

    Expected: it works for 2-3 minutes
    Actual: it crashes after 1-2 minutes.

    As a workaround the current @next seems to be working: npm i -D @playwright/test@next

  3. str0zzapreti commented on Mar 23, 2022

    @str0zzapreti
    Author

    Nice, OK. For Python, this should be available in 1.21.0 then? Or will there be a 1.20.1 release?

    Thanks!

  4. klhex commented on Mar 23, 2022

    @klhex
    Contributor

    On my Mac (M1, MacOS Monterey 12.3) I get the same dump as Andreas Jim-Hartmann (@devkat). On our CI/CD system however (Linux #58~16.04.1-Ubuntu SMP Mon Jun 24 13:21:41 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux), running the same test produces the following dump:

    Click to expand!
    page.click: Browser closed.
    ==================== Browser output: ====================
    <launching> /ms-playwright/chromium-978106/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,AcceptCHFrame,AutoExpandDetailsElement --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --no-sandbox --disable-dev-shm-usage --disable-gpu --disable-setuid-sandbox --no-first-run --no-sandbox --no-zygote --user-data-dir=/tmp/playwright_chromiumdev_profile-urUX6S --remote-debugging-pipe --no-startup-window
    <launched> pid=215
    [pid=215][err] [215:231:0323/193028.962034:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
    [pid=215][err] [215:231:0323/193028.962125:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
    [pid=215][err] [215:230:0323/193028.964089:ERROR:bus.cc(397)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
    [pid=215][err] [215:230:0323/193028.964122:ERROR:bus.cc(397)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
    [pid=215][err] [215:230:0323/193028.998764:ERROR:bus.cc(397)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
    [pid=215][err] [215:230:0323/193028.998799:ERROR:bus.cc(397)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
    [pid=215][err] [215:254:0323/193029.008336:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
    [pid=215][err] [215:254:0323/193029.008362:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
    [pid=215][err] [215:254:0323/193029.008396:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
    [pid=215][err] [215:254:0323/193029.008425:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
    [pid=215][err] [215:254:0323/193029.008443:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
    [pid=215][err] libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
    [pid=215][err] [215:230:0323/193029.028426:ERROR:bus.cc(397)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
    [pid=215][err] [215:230:0323/193029.028449:ERROR:bus.cc(397)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
    [pid=215][err] [239:239:0323/193029.042071:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported.
    [pid=215][err] [215:215:0323/193045.128178:ERROR:page_load_metrics_update_dispatcher.cc(66)] Received null navigation_start.
    [pid=215][err] [0323/193129.432393:ERROR:scoped_ptrace_attach.cc(27)] ptrace: Operation not permitted (1)
    [pid=215][err] Received signal 11 <unknown> 000000000000
    [pid=215][err] #0 0x556261eb2369 base::debug::CollectStackTrace()
    [pid=215][err] #1 0x556261e188c3 base::debug::StackTrace::StackTrace()
    [pid=215][err] #2 0x556261eb1e71 base::debug::(anonymous namespace)::StackDumpSignalHandler()
    [pid=215][err] #3 0x7f0f8cd033c0 (/usr/lib/x86_64-linux-gnu/libpthread-2.31.so+0x143bf)
    [pid=215][err] #4 0x556261ece5f7 base::internal::PartitionFree()
    [pid=215][err] #5 0x556261a5391c component_updater::PKIMetadataComponentInstallerPolicy::UpdateNetworkServiceOnUI()
    [pid=215][err] #6 0x55625f51c0df base::internal::ReplyAdapter<>()
    [pid=215][err] #7 0x55625e65c637 base::internal::Invoker<>::RunOnce()
    [pid=215][err] #8 0x55625f9840ae base::internal::Invoker<>::RunOnce()
    [pid=215][err] #9 0x556261e99d79 base::internal::Invoker<>::RunOnce()
    [pid=215][err] #10 0x556261e70bb0 base::TaskAnnotator::RunTaskImpl()
    [pid=215][err] #11 0x556261e84a99 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl()
    [pid=215][err] #12 0x556261e847bc base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork()
    [pid=215][err] #13 0x556261e84f92 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork()
    [pid=215][err] #14 0x556261e33ecf base::MessagePumpGlib::Run()
    [pid=215][err] #15 0x556261e851fe base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run()
    [pid=215][err] #16 0x556261e523ed base::RunLoop::Run()
    [pid=215][err] #17 0x55625f8b52ad content::BrowserMainLoop::RunMainMessageLoop()
    [pid=215][err] #18 0x55625f8b6b62 content::BrowserMainRunnerImpl::Run()
    [pid=215][err] #19 0x55625f8b2d6c content::BrowserMain()
    [pid=215][err] #20 0x5562619ca8a8 content::RunBrowserProcessMain()
    [pid=215][err] #21 0x5562619cbd0f content::ContentMainRunnerImpl::RunBrowser()
    [pid=215][err] #22 0x5562619cb89f content::ContentMainRunnerImpl::Run()
    [pid=215][err] #23 0x5562619c8cb4 content::RunContentProcess()
    [pid=215][err] #24 0x5562619c95ce content::ContentMain()
    [pid=215][err] #25 0x55625e4e9fed ChromeMain
    [pid=215][err] #26 0x7f0f8be2e0b3 __libc_start_main
    [pid=215][err] #27 0x55625e4e9dea _start
    [pid=215][err]   r8: 00003b30028a9400  r9: 00007ffc61ed0767 r10: bb31e949bf7562f8 r11: 0000000000000000
    [pid=215][err]  r12: 22656d6172467473 r13: 00003b30028a9400 r14: 00003b3002958cb0 r15: 0000000000000008
    [pid=215][err]   di: 0000556267509910  si: 22656d6172467473  bp: 00007ffc61ed0800  bx: 22656d6172400000
    [pid=215][err]   dx: 0000000000000000  ax: 0000556261ece5d0  cx: 00003b30002caa7a  sp: 00007ffc61ed07d0
    [pid=215][err]   ip: 0000556261ece5f7 efl: 0000000000010206 cgf: 002b000000000033 erf: 0000000000000000
    [pid=215][err]  trp: 000000000000000d msk: 0000000000000000 cr2: 0000000000000000
    [pid=215][err] [end of stack trace]
    
  5. mxschmitt commented on Mar 23, 2022

    @mxschmitt
    Contributor

    Workaround for affected folks

    Install latest beta: npm install -D @playwright/test@beta

    We'll release 1.20.1 soon.

    Closing this since the fixes have been merged!

  6. klhex commented on Mar 23, 2022

    @klhex
    Contributor

    PW 1.20.1 has fixed the issue on my side, thanks for the quick fix. 😄

  7. str0zzapreti commented on Mar 23, 2022

    @str0zzapreti
    Author

    100% fixed on python-playwright 1.20.1. Thanks much!

  8. mirao commented on Mar 24, 2022

    @mirao

    I had the same issue on Ubuntu 21.10, with CodeceptJS + Playwright 1.20.0 and headed Chromium only (headless Chromium worked fine). Chromium was crashing almost in every test.
    Now it seems to be fine, with Playwright 1.20.1

  9. MrPowerGamerBR commented on Aug 16, 2022

    @MrPowerGamerBR

    While this was fixed, I'm experiencing issues with Headed Chromium on Playwright 1.24.1 (Windows 10, Java) where the browser just closes by itself with Target page, context or browser has been closed

    However this seems to be very random, and it takes way more time to get to the point where the browser closes by itself (in my last run, it took 27 minutes until Chromium closed by itself)

    Running headless Chromium does not have the same issue, and now I'm running the app with PWDEBUG to try to get more information about the issue.

  10. MrPowerGamerBR commented on Aug 31, 2022

    @MrPowerGamerBR

    Small update: Even with PWDEBUG enabled, there doesn't seem to be any errors that indicate anything.

    If I keep my app running, after a while Playwright Debugger closes by itself (the browser stays open), and sometimes both the Playwright Debugger and the browser closes by itself.

    However, this is hard to reproduce because there doesn't seem to be anything that could cause this, it just poofs, closes by itself after a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions