microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.42k stars 3.63k forks source link

[BUG] Playwright takes long time to close browser #29460

Closed mumaguma closed 8 months ago

mumaguma commented 8 months ago

Version

1.41.2

Steps to reproduce

Dotnet: In Hooks.cs in [AfterScenario] binding I close page, contexts, browser and playwright. When using Edge or Chrome in headless=false, closing browser takes 30000-38000 ms. Closing Chromium takes 2000-3000 ms. In ticket #27679 @yury-s suggested, that this may be due to corporate policies imposed on browser and requested for logs. This happends in headed mode (headless=false)

Expected behavior

Closing Edge / Chrome in 2-3 seconds or not much longer than that.

Actual behavior

Closing Edge / Chrome in 30-38 seconds, when using headed mode

Additional context

Nothing logged after test finish with DEBUG=pw:api. With DEBUG=pw:browser:


2024-02-12T18:26:29.203Z pw:browser <launching> C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe --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,HttpsUpgrades,PaintHolding --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 --no-sandbox --user-data-dir=C:\Users\ny50456\AppData\Local\Temp\playwright_chromiumdev_profile-0cxX9J --remote-debugging-pipe --no-startup-window
2024-02-12T18:26:29.223Z pw:browser <launched> pid=18736
2024-02-12T18:26:29.560Z pw:browser [pid=18736][err] [18736:19388:0212/192629.559:ERROR:policy_logger.cc(156)] :components\enterprise\browser\controller\chrome_browser_cloud_management_controller.cc(161) Cloud management controller initialization aborted as CBCM is not enabled. Please use the --enable-chrome-browser-cloud-management command line flag to enable it if you are not using the official Google Chrome build.

2024-02-12T18:26:42.332Z pw:browser [pid=18736] <gracefully close start>

2024-02-12T18:27:12.339Z pw:browser [pid=18736] <kill>

2024-02-12T18:27:12.339Z pw:browser [pid=18736] <will force kill>
2024-02-12T18:27:12.734Z pw:browser [pid=18736] taskkill stdout: SUCCESS: The process with PID 8848 (child process of PID 18736) has been terminated.
SUCCESS: The process with PID 8468 (child process of PID 18736) has been terminated.
SUCCESS: The process with PID 8800 (child process of PID 18736) has been terminated.
SUCCESS: The process with PID 4972 (child process of PID 18736) has been terminated.
SUCCESS: The process with PID 18364 (child process of PID 18736) has been terminated.
SUCCESS: The process with PID 18736 (child process of PID 6620) has been terminated.
2024-02-12T18:27:12.965Z pw:browser [pid=18736] <process did exit: exitCode=1, signal=null>
2024-02-12T18:27:12.966Z pw:browser [pid=18736] starting temporary directories cleanup
2024-02-12T18:27:13.103Z pw:browser [pid=18736] finished temporary directories cleanup
2024-02-12T18:27:13.103Z pw:browser [pid=18736] <gracefully close end> 

edge://policy doesn't ahve somehting apparent, perhaps "AllowSyncXHRInPageDismissal"? obraz

Environment

(cannot run "npx envinfo --preset playwright" as suggested above this field, as I use dotnet)

System: 
    OS: Win 10 Enterprise 10.0.19045 build 19045   (22H2)
    CPU: virtualised with vmware, using 2 cores Intel Xeon Gold 6154
Binaries:
    dotnet 8.0.101
Playwright:
    1.41.2
Edge: 
    121.0.2277.112  x64
mumaguma commented 8 months ago

(however, AllowSyncXHRInPageDismissalpolicy was supposed to work on edge versions 79 to 99)

mxschmitt commented 8 months ago

Certain Enterprise Browser Policies may impact Playwright's ability to launch and control Google Chrome and Microsoft Edge. Running in an environment with browser policies is outside of the Playwright project's scope.

See https://playwright.dev/docs/browsers#google-chrome--microsoft-edge

We either recommend using Chromium instead or disabling policy after policy to find out which Policy causes it.