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] Chromium on Windows does not launch without --no-sandbox #3191

Closed
arjunattam opened this issue Jul 28, 2020 · 7 comments
Closed

[BUG] Chromium on Windows does not launch without --no-sandbox #3191

arjunattam opened this issue Jul 28, 2020 · 7 comments
Assignees

Comments

@arjunattam
Copy link
Contributor

Context:

  • Playwright Version: 1.2.1
  • Operating System: Windows 10 10.0.18363
  • Node.js version: 12.18
  • Browser: Chromium

Code Snippet

// @ts-check
const {chromium} = require("playwright");
 
(async () => {
 const browser = await chromium.launch();
 const context = await browser.newContext();
 const page = await context.newPage();
 await page.goto('http://whatsmyuseragent.org/');
 await page.screenshot({ path: `example.png` });
 await browser.close();
})();

Describe the bug

Chromium does not launch unless passed with args: ['--no-sandbox'] - in both headful and headless modes. --disable-gpu did not help, like in #2698. Logs seen without args are pasted below. "method":"Inspector.targetCrashed" seems to be the culprit.

 pw:browser => browserType.launch started +0ms
  pw:browser <launching> C:\Users\varsha\AppData\Local\ms-playwright\chromium-782078\chrome-win\chrome.exe --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=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies --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 --user-data-dir=C:\Users\varsha\AppData\Local\Temp\playwright_chromiumdev_profile-aaeAeW --remote-debugging-pipe --no-startup-window [] +5ms
  pw:browser <launched> pid=27324 [] +12ms
  pw:protocol SEND ► {"id":1,"method":"Target.setAutoAttach","params":{"autoAttach":true,"waitForDebuggerOnStart":true,"flatten":true}} [] +0ms
  pw:protocol ◀ RECV {"id":1,"result":{}} [] +276ms
  pw:browser <= browserType.launch succeeded +280ms
  pw:protocol SEND ► {"id":2,"method":"Target.createBrowserContext","params":{"disposeOnDetach":true}} [] +2ms
  pw:protocol ◀ RECV {"id":2,"result":{"browserContextId":"5B1F13D60AA0C378C3BA285F46503282"}} [] +17ms
  pw:protocol SEND ► {"id":3,"method":"Browser.setDownloadBehavior","params":{"behavior":"deny","browserContextId":"5B1F13D60AA0C378C3BA285F46503282","downloadPath":"C:\\Users\\varsha\\AppData\\Local\\Temp\\playwright_downloads-nyACpC"}} [] +2ms
  pw:protocol ◀ RECV {"id":3,"result":{}} [] +15ms
  pw:protocol SEND ► {"id":4,"method":"Target.createTarget","params":{"url":"about:blank","browserContextId":"5B1F13D60AA0C378C3BA285F46503282"}} [] +1ms
  pw:protocol ◀ RECV {"method":"Target.attachedToTarget","params":{"sessionId":"D9605E4C3C2964510BDFF025168112BE","targetInfo":{"targetId":"41E8DA22206090FB6519E846D54172B2","type":"page","title":"","url":"about:blank","attached":true,"browserContextId":"5B1F13D60AA0C378C3BA285F46503282"},"waitingForDebugger":true}} [] +52ms
  pw:protocol SEND ► {"id":5,"method":"Browser.getWindowForTarget","sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +3ms
  pw:protocol ◀ RECV {"id":4,"result":{"targetId":"41E8DA22206090FB6519E846D54172B2"}} [] +34ms
  pw:protocol ◀ RECV {"method":"Inspector.targetCrashed","params":{},"sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +10ms
  pw:protocol ◀ RECV {"id":5,"result":{"windowId":1,"bounds":{"left":10,"top":10,"width":1050,"height":1860,"windowState":"normal"}},"sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +10ms
  pw:protocol SEND ► {"id":6,"method":"Page.enable","sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +1ms
  pw:protocol SEND ► {"id":7,"method":"Page.getFrameTree","sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +0ms
  pw:protocol SEND ► {"id":8,"method":"Log.enable","params":{},"sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +1ms
  pw:protocol SEND ► {"id":9,"method":"Page.setLifecycleEventsEnabled","params":{"enabled":true},"sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +0ms
  pw:protocol SEND ► {"id":10,"method":"Runtime.enable","params":{},"sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +1ms
  pw:protocol SEND ► {"id":11,"method":"Page.addScriptToEvaluateOnNewDocument","params":{"source":"\n//# sourceURL=__playwright_evaluation_script__0\n","worldName":"__playwright_utility_world__"},"sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +0ms
  pw:protocol SEND ► {"id":12,"method":"Network.enable","sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +1ms
  pw:protocol SEND ► {"id":13,"method":"Target.setAutoAttach","params":{"autoAttach":true,"waitForDebuggerOnStart":true,"flatten":true},"sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +0ms
  pw:protocol SEND ► {"id":14,"method":"Emulation.setFocusEmulationEnabled","params":{"enabled":true},"sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +0ms
  pw:protocol SEND ► {"id":15,"method":"Emulation.setDeviceMetricsOverride","params":{"mobile":false,"width":1280,"height":720,"screenWidth":1280,"screenHeight":720,"deviceScaleFactor":1,"screenOrientation":{"angle":90,"type":"landscapePrimary"}},"sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +1ms
  pw:protocol SEND ► {"id":16,"method":"Browser.setWindowBounds","params":{"windowId":1,"bounds":{"width":1296,"height":808}},"sessionId":"D9605E4C3C2964510BDFF025168112BE"}
[] +0ms
  pw:protocol SEND ► {"id":17,"method":"Emulation.setGeolocationOverride","params":{},"sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +1ms
  pw:protocol SEND ► {"id":18,"method":"Network.setExtraHTTPHeaders","params":{"headers":{}},"sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +0ms
  pw:protocol SEND ► {"id":19,"method":"Network.emulateNetworkConditions","params":{"offline":false,"latency":0,"downloadThroughput":-1,"uploadThroughput":-1},"sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +5ms
  pw:protocol SEND ► {"id":20,"method":"Emulation.setEmulatedMedia","params":{"media":"","features":[{"name":"prefers-color-scheme","value":"light"}]},"sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +3ms
  pw:protocol SEND ► {"id":21,"method":"Runtime.runIfWaitingForDebugger","sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +0ms
  pw:protocol ◀ RECV {"id":13,"result":{},"sessionId":"D9605E4C3C2964510BDFF025168112BE"} [] +2ms
(node:904) UnhandledPromiseRejectionWarning: Error: Page closed
    at CRSession.<anonymous> (C:\Repo\OneAsk\CCRM\thanos\node_modules\playwright\lib\chromium\crPage.js:260:60)
    at Object.onceWrapper (events.js:421:28)
    at CRSession.emit (events.js:327:22)
    at C:\Repo\OneAsk\CCRM\thanos\node_modules\playwright\lib\chromium\crConnection.js:167:43
  -- ASYNC --
    at CRBrowserContext.newPage (C:\Repo\OneAsk\CCRM\thanos\node_modules\playwright\lib\helper.js:78:23)
    at C:\Repo\OneAsk\CCRM\thanos\src\e2eTests\aco\script.js:10:30
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:904) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:904) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  pw:browser <process did exit: exitCode=3221225477, signal=null> [] +606ms
@arjunattam
Copy link
Contributor Author

More info from @yingzhe who was running into this: this happens when Chromium is launched with admin privileges. Running without admin does not require the --no-sandbox flag. Confirmed with the other user who was faced this as well: their VS Code was running as admin, and they were launching Chromium via npm test called from the integrated terminal.

@aslushnikov: Can we handle this case? Seems similar to root user on Linux?

@yury-s
Copy link
Member

yury-s commented Jul 30, 2020

It may have something to do with launching from VS Code, npm run ctest -- evaluation.jest passes for me when run as Administrator.

@aslushnikov
Copy link
Collaborator

aslushnikov commented Jul 30, 2020

this happens when Chromium is launched with admin privileges. Running without admin does not require the --no-sandbox flag

@arjun27 I couldn't reproduce this: tried running under administrator in both MINGW and CMD terminals and launching simple script there - worked fine for me without --no-sandbox flag.

@yingzhe
Copy link

yingzhe commented Aug 4, 2020

Playwright: 1.2.1
OS: Windows 10
Node.js: 12.16.3
Browser: Chromium

Below is the error I get when running from non-admin mode command prompt:

(node:1708) UnhandledPromiseRejectionWarning: Error: Page closed
at CRSession. (E:\1\node_modules\playwright\lib\chromium\crPage.js:260:60)
at Object.onceWrapper (events.js:416:28)
at CRSession.emit (events.js:322:22)
at E:\1\node_modules\playwright\lib\chromium\crConnection.js:167:43
-- ASYNC --
at CRBrowserContext.newPage (E:\1\node_modules\playwright\lib\helper.js:78:23)
at E:\1\tests\test1.ts:6:32
(node:1708) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1708) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Code is the same as what was originally posted by @arjun27 above. I had to interrupt with ctrl+c, as the process never completes.

@aslushnikov
Copy link
Collaborator

@yingzhe can you please try with the latest Playwright v1.3.0? We have some nice logic there to detect missing libraries; I hope it will give us a hint on what's going on.

@yingzhe
Copy link

yingzhe commented Aug 11, 2020

(node:35404) UnhandledPromiseRejectionWarning: Error: Page closed
at CRSession. (E:\1\node_modules\playwright\lib\chromium\crPage.js:263:60)
at Object.onceWrapper (events.js:416:28)
at CRSession.emit (events.js:322:22)
at E:\1\node_modules\playwright\lib\chromium\crConnection.js:171:43
-- ASYNC --
at CRBrowserContext.newPage (E:\1\node_modules\playwright\lib\helper.js:79:23)
at E:\1\tests\tests1.ts:7:32
(node:35404) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:35404) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I updated Playwright to v1.3.0 but it looks like the error I get is still the same, with the process being stuck forever until I kill it.

@aslushnikov
Copy link
Collaborator

Sandbox configuration proved to be painful in various environments, and this issue is another example.
playwright v1.5.0 now runs --no-sandbox by default,
so this can be closed.

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

4 participants