Repository navigation
[BUG] Regression - chromium browser closes during test or debugging session on macos #12974
Description
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
devkat commentedon Mar 23, 2022
I am facing a similar issue:
PWDEBUG=1)mxschmitt commentedon Mar 23, 2022
I was able to repro on 1.20.0 but it seems fixed on ToT.
PWDEBUG=1 node test.jsExpected: 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@nextstr0zzapreti commentedon Mar 23, 2022
Nice, OK. For Python, this should be available in 1.21.0 then? Or will there be a 1.20.1 release?
Thanks!
klhex commentedon Mar 23, 2022
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!
mxschmitt commentedon Mar 23, 2022
Workaround for affected folks
Install latest beta:
npm install -D @playwright/test@betaWe'll release 1.20.1 soon.
Closing this since the fixes have been merged!
klhex commentedon Mar 23, 2022
PW 1.20.1 has fixed the issue on my side, thanks for the quick fix. 😄
str0zzapreti commentedon Mar 23, 2022
100% fixed on python-playwright 1.20.1. Thanks much!
mirao commentedon Mar 24, 2022
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
MrPowerGamerBR commentedon Aug 16, 2022
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 closedHowever 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
PWDEBUGto try to get more information about the issue.MrPowerGamerBR commentedon Aug 31, 2022
Small update: Even with
PWDEBUGenabled, 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.
Update dependency @playwright/test to v1.28.1 (#860)