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

[Regression]: Within VS Code, Firefox window does not open in headed mode and generate an error #30660

Closed
JMG74 opened this issue May 4, 2024 · 6 comments

Comments

@JMG74
Copy link

JMG74 commented May 4, 2024

Last Good Version

1.37.1

First Bad Version

1.38.1

Steps to reproduce

  1. Perform a fresh install for a given version: npm install @playwright/[email protected]

  2. Install the browsers: npx playwright install

  3. Run VS Code in the installation directory.

  4. In Playwright section, check the "Show browser" checkbox:
    image

  5. Select default profile "Chromium", and run the 1st test of the provided sample: tests/example.spec.js
    ==> test is successful:
    image

  6. Select default profile "Firefox", and run the 1st test of the provided sample: tests/example.spec.js
    ==> test fails:
    Test timeout of 30000ms exceeded while setting up "page".
    Error: browserContext.newPage: Target page, context or browser has been closed
    image

Expected behavior

When Firefox is selected as the default profile, the browser window should open and the test must pass correctly.
By the way, the same tests pass like a charm for Chromim and Webkit profiles.

Actual behavior

The Firefox browser window does not open but appears in the task bar:
image
When hovering over the Nightly browser icon, an empty window appears but nothing happen when clicking on it.

A timeout is generated with the following errors:
image

Additional context

I've already tested this issue with the following versions of Playwright:
v1.35.1, v1.36.1, and v1.37.1 ==> no error.
I've noticed that v1.37.1 is the latest release using Firefox browser v115.

v1.38.1, v1.39.1, v1.40.1, v1.41.2, v1.42.1, and 1.43.1 ==> the error occurs!

For Playwright v1.43.1, I've activated the debug mode (through env var DEBUG=pw:browser* ), and I got the following trace:

image

Environment

System:
  OS: Microsoft Windows 11 Éducation
  Version: 10.0.22631 Build 22631
  System Type: x64-based PC
  Processor: 13th Gen Intel(R) Core(TM) i7-1355U, 1700 Mhz, 10 Core(s), 12 Logical Processor(s)
  Installed Physical Memory (RAM): 16.0 GB
  Available Physical Memory: 4.06 GB
Binaries:
  node: v20.11.0
  npm: 10.7.0
@mxschmitt
Copy link
Member

I tried to reproduce on Windows 11 and macOS 14, both ran without any issues.

Is your machine managed or has cooperate software installed on it?

@JMG74
Copy link
Author

JMG74 commented May 6, 2024

Yes my machine is managed by our IT team and has corporate softwares on it (Microsoft Office 365 and many others).

@mxschmitt
Copy link
Member

Interesting! Could you please try the following?

  1. Create a file test.mjs with the content below
  2. Run it (node test.mjs) with having the DEBUG=pw:browser env var set (in PowerShell e.g. $Env:DEBUG="pw:browser")
import { chromium, expect } from '@playwright/test';

(async () => {
  const browser = await chromium.launch({ headless: false, slowMo: 100 });

  {
    const context = await browser._newContextForReuse();
    const page = await context.newPage();

    await page.goto('https://playwright.dev/');
    await expect(page).toHaveTitle(/Playwright/);
  }

  {
    const context = await browser._newContextForReuse();
    const page = context.pages()[0];

    await page.goto('https://playwright.dev/');

    await page.getByRole('link', { name: 'Get started' }).click();
    await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
  }

  await browser.close();
})();

This might give us more debug output while mimicking what we do inside the extension.

@JMG74
Copy link
Author

JMG74 commented May 7, 2024

Hi,

Here below is the output of the test program you asked me to run. By the way, a chromium window opened correctly:

  pw:browser <launching> C:\Users\xxxx\AppData\Local\ms-playwright\chromium-1112\chrome-win\chrome.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\xxxx\AppData\Local\Temp\playwright_chromiumdev_profile-aoNOCG --remote-debugging-pipe --no-startup-window +0ms
  pw:browser <launched> pid=3148 +34ms
  pw:browser [pid=3148][err] [3148:4124:0507/064126.456:ERROR: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. +454ms
  pw:browser [pid=3148] <gracefully close start> +2s
  pw:browser [pid=3148] <process did exit: exitCode=0, signal=null> +339ms
  pw:browser [pid=3148] starting temporary directories cleanup +1ms
  pw:browser [pid=3148] finished temporary directories cleanup +17ms
  pw:browser [pid=3148] <gracefully close end>

The test you ask me to run concerns the chromium browser but I do not have any problem with chromium... my problem is only with firefox... then I ran the same test program where I replaced the string "chromium" by "firefox" and here is the resulting output. During the test, no window opened for Firefox:

  pw:browser <launching> C:\Users\xxxx\AppData\Local\ms-playwright\firefox-1447\firefox\firefox.exe -no-remote -wait-for-browser -foreground -profile C:\Users\xxxx\AppData\Local\Temp\playwright_firefoxdev_profile-5EqNMJ -juggler-pipe -silent +0ms
  pw:browser <launched> pid=12764 +12ms
  pw:browser [pid=12764][err] JavaScript warning: resource://services-settings/Utils.sys.mjs, line 114: unreachable code after return statement +163ms
  pw:browser [pid=12764][out] console.warn: services.settings: Ignoring preference override of remote settings server +2ms
  pw:browser [pid=12764][out] console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment +0ms
  pw:browser [pid=12764][out] console.error: ({}) +305ms
  pw:browser [pid=12764][out]  +4ms
  pw:browser [pid=12764][out] Juggler listening to the pipe +0ms
  pw:browser [pid=12764][out] console.error: "Warning: unrecognized command line flag" "-foreground" +33ms
  pw:browser [pid=12764][out] console.error: SearchEngineSelector: "Received empty search configuration!" +2s
  pw:browser [pid=12764][out] console.error: SearchEngineSelector: "Received empty search configuration!" +109ms
  pw:browser [pid=12764][out] console.error: SearchService: "#init: failure initializing search:" ({}) +0ms
  pw:browser [pid=12764][err] JavaScript error: resource://gre/modules/SearchEngineSelectorOld.sys.mjs, line 118: NS_ERROR_UNEXPECTED: Failed to get engine data from Remote Settings +13ms
  pw:browser [pid=12764][out] console.error: "Received empty top sites configuration!" +1ms
  pw:browser [pid=12764][err] JavaScript error: resource://gre/modules/SearchEngineSelectorOld.sys.mjs, line 118: NS_ERROR_UNEXPECTED: Failed to get engine data from Remote Settings +0ms
  pw:browser [pid=12764][err] JavaScript error: resource://gre/modules/SearchEngineSelectorOld.sys.mjs, line 118: NS_ERROR_UNEXPECTED: Failed to get engine data from Remote Settings +0ms
  pw:browser [pid=12764][err] JavaScript error: resource://gre/modules/SearchEngineSelectorOld.sys.mjs, line 118: NS_ERROR_UNEXPECTED: Failed to get engine data from Remote Settings +4ms
  pw:browser [pid=12764][out] console.error: "Received empty top sites configuration!" +2ms
  pw:browser [pid=12764][out] console.error: WebExtensions:  +118ms
  pw:browser [pid=12764][out]   Message: [Exception... "Failed to get engine data from Remote Settings"  nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)"  location: "JS frame :: resource://gre/modules/SearchEngineSelectorOld.sys.mjs :: getEngineConfiguration :: line 118"  data: no] +0ms
  pw:browser [pid=12764][out]   Stack: +0ms
  pw:browser [pid=12764][out]     getEngineConfiguration@resource://gre/modules/SearchEngineSelectorOld.sys.mjs:118:24 +0ms
  pw:browser [pid=12764][out]  +0ms
  pw:browser [pid=12764][err] JavaScript error: , line 0: InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable +538ms
  pw:browser [pid=12764][err] JavaScript error: , line 0: TypeError: can't access dead object +8ms
  pw:browser [pid=12764][out] console.error: SearchSettings: "_write: Could not write to settings file:" (new Error("cannot write without any engine.", "resource://gre/modules/SearchSettings.sys.mjs", 277)) +154ms
  pw:browser [pid=12764] <gracefully close start> +461ms
  pw:browser [pid=12764] <process did exit: exitCode=0, signal=null> +730ms
  pw:browser [pid=12764] starting temporary directories cleanup +0ms
  pw:browser [pid=12764] finished temporary directories cleanup +20ms
  pw:browser [pid=12764] <gracefully close end>

@JMG74
Copy link
Author

JMG74 commented May 7, 2024

Based on previous test with firefox browser, I tried some complementary investigations by launching manually firefox browser window (based on the command appearing at the beginning of the debug trace):
With the command "C:\Users\xxxx\AppData\Local\ms-playwright\firefox-1447\firefox\firefox.exe -no-remote -wait-for-browser -foreground", a Nightly/Firefox window opens correctly.

The name of the directory used for the "-profile" parameter is currently "C:\Users\xxxx\AppData\Local\Temp\playwright_firefoxdev_profile-5EqNMJ", and I noticed that I have also a directory called "C:\Users\xxxx\AppData\Local\Temp\playwright_firefoxdev_profile" created a few days ago.
I thought I could have had a problem when removing those temporary directories, and I tried to remove them manually... and you know what ? now everything is working properly with firefox browser 👍👍👍
My problem seems fixed!!

I leave it to you to close this ticket and remain at your disposal for any further information you may require.

@mxschmitt
Copy link
Member

Impressive! I suspect that some anti-virus / policy software on your system didn't like our Firefox browser getting launched by Playwright initially but if you do it manually, it shows them that this is an intentional execution.

Closing by that.

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

2 participants