Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] WebKit: Browser randomly crashes since Playwright 1.33 #22790

Closed
mirao opened this issue May 3, 2023 · 7 comments
Closed

[BUG] WebKit: Browser randomly crashes since Playwright 1.33 #22790

mirao opened this issue May 3, 2023 · 7 comments

Comments

@mirao
Copy link

mirao commented May 3, 2023

System info

  • Playwright Version: v1.33
  • Operating System: Ubuntu 22.04
  • Browser: WebKit-1837
  • Other info: CodeceptJS 3.4.1 with Playwright helper

Steps
Unfortunately I'm not able to reproduce reliably. But it never happens with Playwright 1.32
It crashes on random places in various CodeceptJS tests, mostly when clicking on a button or on a sidebar menu item in our application.
It crashes in 100% of cases in the following test.

Example: (it's a CodeceptJS log with DEBUG=*browser*, but no browser message is shown near the crash)

2023-05-03T12:39:03.447Z pw:browser <launching> /home/node/ms-playwright/webkit-1837/pw_run.sh --inspector-pipe --headless --no-startup-window
2023-05-03T12:39:03.471Z pw:browser <launched> pid=3696
2023-05-03T12:39:03.599Z pw:browser [pid=3696][err] Could not determine the accessibility bus address
...
[2.dev:webkit]     konvajsFragment: verifyGameArea "DND_Player_Correct_Target_Position", 
[2.dev:webkit]       I wait for invisible .dimmed .loader
[2.dev:webkit]       I take screenshot "DND_Player_Correct_Target_Position_webkit_headless", "actual", ".content .konvajs-content"
[2.dev:webkit]       I check visual differences "DND_Player_Correct_Target_Position_webkit_headless"
[2.dev:webkit]       › Check differences in DND_Player_Correct_Target_Position_webkit_headless ...
[2.dev:webkit]       › Load image from /home/node/workspace/tests/s4w/output/dev_webkit_2/DND_Player_Correct_Target_Position_webkit_headless.png ...
[2.dev:webkit]       › Load image from /home/node/workspace/tests/s4w/screenshots/base/DND_Player_Correct_Target_Position_webkit_headless.png ...
[2.dev:webkit]       › Difference: 0% | 0 / 679662 pixels
[2.dev:webkit]   ✔ OK in 7263ms
[2.dev:webkit]
[2.dev:webkit]   Leave the game
[2.dev:webkit]     I wait 1
ERROR: Page has crashed, closing page!
ERROR: Page has crashed, closing page!
[2.dev:webkit]    Click "Continue" button
[2.dev:webkit]     I click ".content .konvajs-content", , {"position":{"x":469,"y":483}}
[2.dev:webkit]  › <screenshotOnFail> Test failed, try to save a screenshot
[2.dev:webkit]  › Screenshot is saving to /home/node/workspace/tests/s4w/output/dev_webkit_2/Leave_the__33370790-4a74-4f65-956b-6c8024a7d3d1.failed.png
[2.dev:webkit]  › <Error: page.screenshot: Target crashed
=========================== logs ===========================
taking page screenshot
============================================================> 
[2.dev:webkit]   ✖ FAILED in 50111ms
...
[2.dev:webkit]  › <screenshotOnFail> Test failed, try to save a screenshot
[2.dev:webkit]  › Screenshot is saving to /home/node/workspace/tests/s4w/output/dev_webkit_2/Leave_the__33370790-4a74-4f65-956b-6c8024a7d3d1.failed.png
[2.dev:webkit]  › <Error: page.screenshot: Target crashed
=========================== logs ===========================
taking page screenshot
============================================================> 
[2.dev:webkit]   ✖ FAILED in 50111ms

...

A test result summary with a stack:

1) AuthorTemplateDndGame
       Leave the game:
     page.$$: Target crashed
      at Playwright.findElements (/home/node/workspace/node_modules/.pnpm/[email protected]_o7lr63vpga6ylgrc3jy4rl4bhq/node_modules/codeceptjs/lib/helper/Playwright.js:2561:18)
      at Playwright.findClickable (/home/node/workspace/node_modules/.pnpm/[email protected]_o7lr63vpga6ylgrc3jy4rl4bhq/node_modules/codeceptjs/lib/helper/Playwright.js:2611:47)
      at Playwright.proceedClick (/home/node/workspace/node_modules/.pnpm/[email protected]_o7lr63vpga6ylgrc3jy4rl4bhq/node_modules/codeceptjs/lib/helper/Playwright.js:2584:35)
  
  Scenario Steps:
  - I.click(".content .konvajs-content", , {"position":{"x":469,"y":483}}) at Test.<anonymous> (./authorTemplates/AuthorTemplateDndGame_test.ts:231:7)
  - I.wait(1) at Test.<anonymous> (./authorTemplates/AuthorTemplateDndGame_test.ts:229:7)
@yury-s
Copy link
Member

yury-s commented May 3, 2023

We need a repro to act on this. Can you provide a minimal example that we could run locally to reproduce the error?

@yury-s yury-s added the triaging label May 3, 2023
@thewilkybarkid
Copy link

thewilkybarkid commented May 4, 2023

I think I see the same problem using @playwright/test in the Docker image.

I can see some debug output related to the browser crashing around https://github.com/PREreview/prereview.org/blob/007ad855495d9c71e0e12de695e427f6172021bf/integration/publishing-a-prereview.spec.ts#L1936:

  pw:api => keyboard.press started +2ms
2023-05-04T08:46:09.500Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stepBegin","params":{"testId":"79b8dca29434021e61c1-c4864275367836bcbb43","stepId":"pw:[email protected](Tab)@11","location":{"file":"/app/integration/publishing-a-prereview.spec.ts","line":1936,"column":23},"category":"pw:api","title":"keyboard.press(Tab)","wallTime":1683189969498}}}
2023-05-04T08:46:09.500Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stdErr","params":{"text":"  \u001b[38;5;33;1mpw:channel:command \u001b[0m{\n  \u001b[38;5;33;1mpw:channel:command \u001b[0m  id: \u001b[33m15\u001b[39m,\n  \u001b[38;5;33;1mpw:channel:command \u001b[0m  guid: \u001b[32m'page@0054bc02d4deca844a923c6322f48b02'\u001b[39m,\n  \u001b[38;5;33;1mpw:channel:command \u001b[0m  method: \u001b[32m'keyboardPress'\u001b[39m,\n  \u001b[38;5;33;1mpw:channel:command \u001b[0m  params: { key: \u001b[32m'Tab'\u001b[39m }\n  \u001b[38;5;33;1mpw:channel:command \u001b[0m} \u001b[38;5;33m+142ms\u001b[0m\n"}}}
  pw:channel:command {
  pw:channel:command   id: 15,
  pw:channel:command   guid: 'page@0054bc02d4deca844a923c6322f48b02',
  pw:channel:command   method: 'keyboardPress',
  pw:channel:command   params: { key: 'Tab' }
  pw:channel:command } +142ms
2023-05-04T08:46:09.501Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stdErr","params":{"text":"  \u001b[38;5;34;1mpw:protocol \u001b[0m◀ RECV {\"result\":{},\"id\":337,\"browserContextId\":\"8000000000000002\",\"pageProxyId\":\"8\"} \u001b[38;5;34m+84ms\u001b[0m\n"}}}
  pw:protocol ◀ RECV {"result":{},"id":337,"browserContextId":"8000000000000002","pageProxyId":"8"} +84ms
2023-05-04T08:46:09.501Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stdErr","params":{"text":"  \u001b[38;5;34;1mpw:protocol \u001b[0m◀ RECV {\"method\":\"Target.dispatchMessageFromTarget\",\"params\":{\"targetId\":\"page-15\",\"message\":\"{\\\"result\\\":{\\\"result\\\":{\\\"type\\\":\\\"undefined\\\"},\\\"wasThrown\\\":false},\\\"id\\\":336}\"},\"browserContextId\":\"8000000000000002\",\"pageProxyId\":\"8\"} \u001b[38;5;34m+0ms\u001b[0m\n"}}}
  pw:protocol ◀ RECV {"method":"Target.dispatchMessageFromTarget","params":{"targetId":"page-15","message":"{\"result\":{\"result\":{\"type\":\"undefined\"},\"wasThrown\":false},\"id\":336}"},"browserContextId":"8000000000000002","pageProxyId":"8"} +0ms
2023-05-04T08:46:09.501Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stdErr","params":{"text":"  \u001b[38;5;34;1mpw:protocol \u001b[0m◀ RECV {\"method\":\"Target.targetDestroyed\",\"params\":{\"targetId\":\"page-15\",\"crashed\":true},\"browserContextId\":\"8000000000000002\",\"pageProxyId\":\"8\"} \u001b[38;5;34m+0ms\u001b[0m\n"}}}
  pw:protocol ◀ RECV {"method":"Target.targetDestroyed","params":{"targetId":"page-15","crashed":true},"browserContextId":"8000000000000002","pageProxyId":"8"} +0ms
2023-05-04T08:46:09.502Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stdErr","params":{"text":"  \u001b[38;5;34;1mpw:protocol \u001b[0mSEND ► {\"id\":338,\"method\":\"Input.dispatchKeyEvent\",\"params\":{\"type\":\"keyDown\",\"modifiers\":0,\"windowsVirtualKeyCode\":9,\"code\":\"Tab\",\"key\":\"Tab\",\"text\":\"\",\"unmodifiedText\":\"\",\"autoRepeat\":false,\"isKeypad\":false},\"pageProxyId\":\"8\"} \u001b[38;5;34m+1ms\u001b[0m\n"}}}
  pw:protocol SEND ► {"id":338,"method":"Input.dispatchKeyEvent","params":{"type":"keyDown","modifiers":0,"windowsVirtualKeyCode":9,"code":"Tab","key":"Tab","text":"","unmodifiedText":"","autoRepeat":false,"isKeypad":false},"pageProxyId":"8"} +1ms
2023-05-04T08:46:09.503Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stdErr","params":{"text":"  \u001b[38;5;34;1mpw:protocol \u001b[0mSEND ► {\"id\":339,\"method\":\"Input.dispatchKeyEvent\",\"params\":{\"type\":\"keyUp\",\"modifiers\":0,\"key\":\"Tab\",\"windowsVirtualKeyCode\":9,\"code\":\"Tab\",\"isKeypad\":false},\"pageProxyId\":\"8\"} \u001b[38;5;34m+0ms\u001b[0m\n"}}}
  pw:protocol SEND ► {"id":339,"method":"Input.dispatchKeyEvent","params":{"type":"keyUp","modifiers":0,"key":"Tab","windowsVirtualKeyCode":9,"code":"Tab","isKeypad":false},"pageProxyId":"8"} +0ms
2023-05-04T08:46:09.503Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stdErr","params":{"text":"  \u001b[38;5;207;1mpw:channel:event \u001b[0m{\n  \u001b[38;5;207;1mpw:channel:event \u001b[0m  guid: \u001b[32m'page@0054bc02d4deca844a923c6322f48b02'\u001b[39m,\n  \u001b[38;5;207;1mpw:channel:event \u001b[0m  method: \u001b[32m'crash'\u001b[39m,\n  \u001b[38;5;207;1mpw:channel:event \u001b[0m  params: \u001b[90mundefined\u001b[39m\n  \u001b[38;5;207;1mpw:channel:event \u001b[0m} \u001b[38;5;207m+274ms\u001b[0m\n"}}}
  pw:channel:event {
  pw:channel:event   guid: 'page@0054bc02d4deca844a923c6322f48b02',
  pw:channel:event   method: 'crash',
  pw:channel:event   params: undefined
  pw:channel:event } +274ms
2023-05-04T08:46:34.588Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stepBegin","params":{"testId":"79b8dca29434021e61c1-c4864275367836bcbb43","stepId":"hook@After Hooks@12","category":"hook","title":"After Hooks","wallTime":1683189994587}}}
2023-05-04T08:46:34.589Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stdErr","params":{"text":"  \u001b[32;1mpw:test \u001b[0mon-failure callback started \u001b[32m+30s\u001b[0m\n"}}}
  pw:test on-failure callback started +30s
2023-05-04T08:46:34.589Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stepBegin","params":{"testId":"79b8dca29434021e61c1-c4864275367836bcbb43","stepId":"hook@Screenshot on failure@13","parentStepId":"hook@After Hooks@12","category":"hook","title":"Screenshot on failure","wallTime":1683189994588}}}
2023-05-04T08:46:34.592Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stdErr","params":{"text":"  \u001b[38;5;45;1mpw:api \u001b[0m=> page.screenshot started \u001b[38;5;45m+25s\u001b[0m\n"}}}
  pw:api => page.screenshot started +25s
2023-05-04T08:46:34.593Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stepBegin","params":{"testId":"79b8dca29434021e61c1-c4864275367836bcbb43","stepId":"pw:[email protected]@14","parentStepId":"hook@Screenshot on failure@13","category":"pw:api","title":"page.screenshot","wallTime":1683189994592}}}
2023-05-04T08:46:34.593Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stdErr","params":{"text":"  \u001b[38;5;33;1mpw:channel:command \u001b[0m{\n  \u001b[38;5;33;1mpw:channel:command \u001b[0m  id: \u001b[33m16\u001b[39m,\n  \u001b[38;5;33;1mpw:channel:command \u001b[0m  guid: \u001b[32m'page@0054bc02d4deca844a923c6322f48b02'\u001b[39m,\n  \u001b[38;5;33;1mpw:channel:command \u001b[0m  method: \u001b[32m'screenshot'\u001b[39m,\n  \u001b[38;5;33;1mpw:channel:command \u001b[0m  params: { timeout: \u001b[33m5000\u001b[39m, type: \u001b[32m'png'\u001b[39m, caret: \u001b[32m'initial'\u001b[39m }\n  \u001b[38;5;33;1mpw:channel:command \u001b[0m} \u001b[38;5;33m+25s\u001b[0m\n"}}}
  pw:channel:command {
  pw:channel:command   id: 16,
  pw:channel:command   guid: 'page@0054bc02d4deca844a923c6322f48b02',
  pw:channel:command   method: 'screenshot',
  pw:channel:command   params: { timeout: 5000, type: 'png', caret: 'initial' }
  pw:channel:command } +25s
2023-05-04T08:46:34.595Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stdErr","params":{"text":"  \u001b[38;5;45;1mpw:api \u001b[0mtaking page screenshot \u001b[38;5;45m+2ms\u001b[0m\n"}}}
  pw:api taking page screenshot +2ms
2023-05-04T08:46:34.598Z pw:test:protocol ◀ RECV {"method":"__dispatch__","params":{"method":"stdErr","params":{"text":"  \u001b[38;5;202;1mpw:channel:response \u001b[0m{\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m  id: \u001b[33m16\u001b[39m,\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m  error: {\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m    error: {\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m      message: \u001b[32m'Target crashed\\n'\u001b[39m +\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m        \u001b[32m'=========================== logs ===========================\\n'\u001b[39m +\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m        \u001b[32m'taking page screenshot\\n'\u001b[39m +\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m        \u001b[32m'============================================================'\u001b[39m,\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m      stack: \u001b[32m'Error: Target crashed\\n'\u001b[39m +\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m        \u001b[32m'=========================== logs ===========================\\n'\u001b[39m +\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m        \u001b[32m'taking page screenshot\\n'\u001b[39m +\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m        \u001b[32m'============================================================\\n'\u001b[39m +\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m        \u001b[32m'    at WKSession.send (/app/node_modules/playwright-core/lib/server/webkit/wkConnection.js:127:30)\\n'\u001b[39m +\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m        \u001b[32m'    at WKPage.takeScreenshot (/app/node_modules/playwright-core/lib/server/webkit/wkPage.js:823:40)\\n'\u001b[39m +\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m        \u001b[32m'    at Screenshotter._screenshot (/app/node_modules/playwright-core/lib/server/screenshotter.js:262:47)\\n'\u001b[39m +\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m        \u001b[32m'    at /app/node_modules/playwright-core/lib/server/screenshotter.js:168:22'\u001b[39m,\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m      name: \u001b[32m'Error'\u001b[39m\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m    }\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m  }\n  \u001b[38;5;202;1mpw:channel:response \u001b[0m} \u001b[38;5;202m+25s\u001b[0m\n"}}}
  pw:channel:response {
  pw:channel:response   id: 16,
  pw:channel:response   error: {
  pw:channel:response     error: {
  pw:channel:response       message: 'Target crashed\n' +
  pw:channel:response         '=========================== logs ===========================\n' +
  pw:channel:response         'taking page screenshot\n' +
  pw:channel:response         '============================================================',
  pw:channel:response       stack: 'Error: Target crashed\n' +
  pw:channel:response         '=========================== logs ===========================\n' +
  pw:channel:response         'taking page screenshot\n' +
  pw:channel:response         '============================================================\n' +
  pw:channel:response         '    at WKSession.send (/app/node_modules/playwright-core/lib/server/webkit/wkConnection.js:127:30)\n' +
  pw:channel:response         '    at WKPage.takeScreenshot (/app/node_modules/playwright-core/lib/server/webkit/wkPage.js:823:40)\n' +
  pw:channel:response         '    at Screenshotter._screenshot (/app/node_modules/playwright-core/lib/server/screenshotter.js:262:47)\n' +
  pw:channel:response         '    at /app/node_modules/playwright-core/lib/server/screenshotter.js:168:22',
  pw:channel:response       name: 'Error'
  pw:channel:response     }
  pw:channel:response   }
  pw:channel:response } +25s

I'll keep digging and will see if I can isolate the issue (it fails more often than not for me, but only on 2 tests in the whole suite).

@thewilkybarkid
Copy link

thewilkybarkid commented May 4, 2023

I'm not been able to produce any more useful details other than disabling the screenshots in the test causes it to pass consistently.

Adding in a page.on('crash', () => { throw new Error('crash') }) listener (i.e. one that stops the test from running as soon as it crashes) allows me to see that the expect(page).toHaveScreenshot() passes successfully (https://github.com/PREreview/prereview.org/blob/007ad855495d9c71e0e12de695e427f6172021bf/integration/publishing-a-prereview.spec.ts#L1934), but it crashes shortly afterwards.

I have no idea at the moment why these two tests are failing and the others are fine; they're not doing anything obviously different to the others. And so I'm not sure how to create a small reproducible example, but you should be able to run this specific test with the following:

git clone --no-checkout https://github.com/PREreview/prereview.org
cd prereview.org/
git checkout 007ad855495d9c71e0e12de695e427f6172021bf
make test-integration TEST="--project 'iPhone 11' --grep 'might not authenticate with ORCID in time'"

(You'll need Git LFS installed to get the existing snapshots.)

@thewilkybarkid
Copy link

My test seems fine in WebKit when JavaScript is disabled:

make test-integration TEST="--project 'iPhone 11 (no JavaScript)' --grep 'might not authenticate with ORCID in time'"

@yury-s
Copy link
Member

yury-s commented May 4, 2023

@thewilkybarkid please file a separate bug with a reproducible example, it is likely unrelated. In the call stack above I don't see any playwright functions.

@yury-s
Copy link
Member

yury-s commented May 8, 2023

@mirao We need more information to act on this report. Please file a new one and link to this issue when you get back to it!

@mirao
Copy link
Author

mirao commented Jun 12, 2023

The crash seems to be fixed in Playwright 1.34.

Now I'm running the test mentioned in #22790 (comment)

  • Playwright 1.33 - browser crashes regularly 🐞
  • Playwright 1.34 - browser never crashes ✔️

Also Playwright 1.35 works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants