Sparticuz / chromium

Chromium (x86-64) for Serverless Platforms
MIT License
1.02k stars 71 forks source link

[BUG] Unable to open page with disabled setGraphicsMode #247

Open heaven opened 8 months ago

heaven commented 8 months ago

Once chromium.setGraphicsMode = false; open page times out.

Environment

Expected Behavior

Chromium 112 worked well, disabling graphics mode effectively reducing the launch time by 25-30%.

Current Behavior

Opening a new page freezes forever.

const page = await browser.newPage();

Steps to Reproduce

  chromium.setGraphicsMode = false;

  const browser = await puppeteer.launch({
    args:              chromium.args,
    defaultViewport:   { width: 1366, height: 4608 },
    executablePath:    await chromium.executablePath(),
    headless:          chromium.headless,
    ignoreDefaultArgs: false,
    ignoreHTTPSErrors: true,
    pipe:              true,
    dumpio:            false
  });

  const page = await browser.newPage();

Once setGraphicsMode is commented out things get back to life again.

heaven commented 8 months ago

Interestingly, if setting chromium.setGraphicsMode = true; in 112.02, it then freezes 😀

So this setup only works with Node 18 and with graphics mode disabled:

{
  "dependencies": {
    "puppeteer-core": "^19.8.5"
  },
  "devDependencies": {
    "@sparticuz/chromium": "^112.0.2"
  }
}

And this one works well on Node 20 with both graphics modes:

{
  "dependencies": {
    "puppeteer-core": "^22.4.1"
  },
  "devDependencies": {
    "@sparticuz/chromium": "^122.0.0"
  }
}

For us, the graphics mode makes the crawler twice slower. Our script normally finishes in 7.5-8.5 seconds, with the graphics mode enabled it takes 15-18 seconds.

Sparticuz commented 7 months ago
[0403/173006.716367:ERROR:check.cc(365)] Check failed: false. NOTREACHED log messages are omitted in official builds. Sorry!
[0403/173006.716370:ERROR:gpu_channel_manager.cc(968)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0403/173006.716373:ERROR:shared_image_stub.cc(728)] SharedImageStub: unable to create context
[0403/173006.716376:ERROR:gpu_channel.cc(767)] GpuChannel: Failed to create SharedImageStub
[0403/173006.716401:ERROR:check.cc(365)] Check failed: false. NOTREACHED log messages are omitted in official builds. Sorry!
[0403/173006.716407:ERROR:gpu_channel_manager.cc(957)] Failed to create GLES3 context, fallback to GLES2.
[0403/173006.716410:ERROR:check.cc(365)] Check failed: false. NOTREACHED log messages are omitted in official builds. Sorry!
[0403/173006.716412:ERROR:gpu_channel_manager.cc(968)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0403/173006.716414:ERROR:shared_image_stub.cc(728)] SharedImageStub: unable to create context
[0403/173006.716417:ERROR:gpu_channel.cc(767)] GpuChannel: Failed to create SharedImageStub
[0403/173006.716541:ERROR:check.cc(365)] Check failed: false. NOTREACHED log messages are omitted in official builds. Sorry!
[0403/173006.716565:ERROR:gpu_channel_manager.cc(957)] Failed to create GLES3 context, fallback to GLES2.
[0403/173006.716570:ERROR:check.cc(365)] Check failed: false. NOTREACHED log messages are omitted in official builds. Sorry!
[0403/173006.716574:ERROR:gpu_channel_manager.cc(968)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0403/173006.716575:ERROR:shared_image_stub.cc(728)] SharedImageStub: unable to create context
[0403/173006.716578:ERROR:gpu_channel.cc(767)] GpuChannel: Failed to create SharedImageStub
[0403/173006.716601:ERROR:check.cc(365)] Check failed: false. NOTREACHED log messages are omitted in official builds. Sorry!
[0403/173006.716608:ERROR:gpu_channel_manager.cc(957)] Failed to create GLES3 context, fallback to GLES2.
[0403/173006.716610:ERROR:check.cc(365)] Check failed: false. NOTREACHED log messages are omitted in official builds. Sorry!
[0403/173006.716613:ERROR:gpu_channel_manager.cc(968)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
[0403/173006.716615:ERROR:shared_image_stub.cc(728)] SharedImageStub: unable to create context
[0403/173006.716618:ERROR:gpu_channel.cc(767)] GpuChannel: Failed to create SharedImageStub
^[[1;2DFunction 'node20' timed out after 30 seconds  
Sparticuz commented 7 months ago

Until this bug gets fixed, I'm going to disable turning off accelerated graphics

Sparticuz commented 4 months ago

Sorry for the delay, there were other issues with 126 that needed to get fixed. This is now live, however, I'm going to keep the bug open.