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

fix playwright._impl._errors.TargetClosedError: Target page, context or browser has been closed on Windows #259

Merged
merged 2 commits into from
Sep 12, 2024

Conversation

sakkyoi
Copy link
Contributor

@sakkyoi sakkyoi commented Sep 12, 2024

Fix #221

according to chromium-dev:
The code for chrome is split between two DLLs, but there's some code duplicated (base, etc.). Only one DLL is loaded into each chrome process (chrome.dll for the browser, chrome_child.dll for others). We didn't attempt to keep single process working in that mode as it was unnecessary and potentially tricky/confusing given two copies of the same code in the same processes.
Setting chrome_multiple_dll=0 at gyp time is probably the simplest solution for single process mode in Chrome.

The main issue is that Chromium on Windows is built with chrome_multiple_dll=0, which does not support the --single-process flag. This leads to failures when attempting to run Chromium in a single process mode on Windows, the browser crashes immediately after launch.

Fix:

If the platform is Windows, the --single-process flag will be automatically disabled to ensure compatibility. On non-Windows platforms, the flag will still be used as expected.

Testing Results:

Tested on my fork, and the following outcomes were observed:

  • On Windows: --single-process is disabled, and Chromium runs without issues.
  • On Linux/macOS: --single-process works as expected, with no failures.

All relevant test have passed successfully in both environments.

@eggplants eggplants merged commit 5550ad8 into eggplants:master Sep 12, 2024
4 checks passed
@eggplants
Copy link
Owner

@sakkyoi Thank you for your contribution!

@eggplants
Copy link
Owner

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

Successfully merging this pull request may close these issues.

playwright._impl._errors.TargetClosedError: Target page, context or browser has been closed
2 participants