question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`ignoreDefaultArgs` launch parameter is broken

See original GitHub issue

I’m trying to disable default launch arguments however when this parameter is set to True one of two things happen:

browser: Browser = chromium.launch(ignoreDefaultArgs=True)

will break with:

  File "/home/user/.local/lib/python3.8/site-packages/playwright/browser_type.py", line 66, in launch
    normalize_launch_params(params)
  File "/home/user/.local/lib/python3.8/site-packages/playwright/browser_type.py", line 140, in normalize_launch_params
    params["env"] = {name: str(value) for [name, value] in params["env"].items()}
KeyError: 'env'

I’ve made a hotfix patch here https://github.com/Granitosaurus/playwright-python/commit/2dc0e107719097e1105e36149a7fe8238c210e38 now the browser launches fine but timesout on launch() call:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/playwright/browser_type.py", line 68, in launch
    return from_channel(await self._channel.send("launch", params))
  File "/home/user/.local/lib/python3.8/site-packages/playwright/connection.py", line 39, in send
    result = await callback.future
  File "/usr/lib/python3.8/asyncio/futures.py", line 260, in __await__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.8/asyncio/tasks.py", line 349, in __wakeup
    future.result()
  File "/usr/lib/python3.8/asyncio/futures.py", line 178, in result
    raise self._exception
playwright.helper.TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
<launching> /home/user/.cache/ms-playwright/chromium-799411/chrome-linux/chrome 
<launched> pid=301672
[err] [301699:301699:0914/061714.839670:ERROR:sandbox_linux.cc(374)] InitializeSandbox() called with multiple threads in process gpu-process.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Granitosauruscommented, Sep 14, 2020

I thought it might be hanging because some of browser flags were required but I popped the defaults from playwright repo here https://github.com/microsoft/playwright/blob/ed3b00efdf0d2e44fc667ade8298ac6d504109bf/src/server/chromium/chromium.ts#L151 and passed them to launch(args=) and unfortunately it’s still timing out on launch:

browser_args = [
  '--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',
  # BlinkGenPropertyTrees disabled due to crbug.com/937609
  '--disable-features=TranslateUI,BlinkGenPropertyTrees,ImprovedCookieControls,SameSiteByDefaultCookies,LazyFrameLoading',
  '--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',
]
pw.chromium.launch(args=browser_args, ignoreDefaultArgs=True)
# or 
pw.chromium.launch(args=['--enable-automation'], ignoreDefaultArgs=True)
# alternatively passing this list to ignoreDefaultArgs doesn't seem to disable the flags.
pw.chromium.launch(ignoreDefaultArgs=browser_args)

From what I understand here:

pw.chromium.launch(args=browser_args, ignoreDefaultArgs=True)
# should be equivalent of 
pw.chromium.launch()
0reactions
mxschmittcommented, Nov 5, 2020

You can set the viewport when creating a context: https://playwright.dev/#version=v1.5.2&path=docs%2Fapi.md&q=browsernewcontextoptions--options-viewport-width

So

browser.newContext(viewport={
    "width": 1280,
    "height": 720,
})

should work. Is this what you want?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer and Chromium launch without flags - Stack Overflow
When ignoreDefaultArgs is set to true, puppeteer won't add any flags to the command line but the ones you set on the args...
Read more >
Troubleshooting | Puppeteer
Arguments ' list when launching pupepeteer. In gitlab-ci.yml we need to install some packages to make it possible to launch headless Chrome in...
Read more >
BrowserType.LaunchOptions (Playwright - javadoc.io
Dangerous option; use with care. Defaults to false . setIgnoreDefaultArgs. public BrowserType.LaunchOptions setIgnoreDefaultArgs(List<String> ignoreDefaultArgs).
Read more >
Launch Browser option not working - Google Groups
Just installed the latest ZAP 2.6 and updated the plugins. Running on Mac OS X 10.12.6. I saw Simon's video on the browser...
Read more >
launch([options]) - Grafana k6
Parameter Type Default args string null debug boolean false devtools boolean false
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found