hardkoded / puppeteer-sharp

Headless Chrome .NET API
https://www.puppeteersharp.com
MIT License
3.39k stars 442 forks source link

Puppeteer Hangs On CreateNewPageAsync, When More than One Process Opened. #1914

Closed omamoo closed 2 years ago

omamoo commented 2 years ago

Before you file a bug, have you:

Description

When I'm trying to open more than one chromium process simultaneously, the code is hangs while executing the following line of code:

_browserPage = await browser.NewPageAsync();

Complete minimal example reproducing the issue

var browser =
                await Puppeteer.LaunchAsync(
                    new LaunchOptions
                    {
                        Args =
                            new[]
                            {
                                "--disable-gpu",
                                "--incognito",
                                "--no-sandbox",
                                "--no-zygote",
                                "--single-process"
                            },
                        LogProcess = true
                    },
                    _loggerFactory);
            _browserPage = await browser.NewPageAsync();

Expected behavior:

New pages created and code continue to execute.

Actual behavior:

The code hangs, after some debugging I can observe that Puppeteer sends Traget.createTarget command via the web-socket

web-app-1_1  | {"EventId":0,"LogLevel":"Trace","Category":"PuppeteerSharp.Connection","Message":"Send { id :2, method : Target.createTarget , params :{ url : about:blank }}","State":{"Message":"Send   { id :2, method : Target.createTarget , params :{ url : about:blank }}","Message":"{ id :2, method : Target.createTarget , params :{ url : about:blank }}","{OriginalFormat}":"Send   {Message}"}}

And expecting the following messages from chromium: Target.targetCreated, Target.targetInfoChanged

But the message Target.targetInfoChanged never received.

Versions

micha-nerves commented 2 years ago

I guess I have the same or similar problem. If multiple threads are at "browser.NewPageAsync();" they all hang or timeout. Those which don't timeout continue at the same time.

omamoo commented 2 years ago

@micha-nerves As far as we know about this issue, it is chromium issue with new dependencies and should be solved in the near future (Chriomium 99). In addition we solved it be using number of workers of pupetteer,