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

Puppeteer@14.1.0 #264

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Conversation

Sparticuz
Copy link

@Sparticuz Sparticuz commented Mar 8, 2022

This PR updates the build process for chromium and gets puppeteer support up to 14.1.0.

Closes: #240 #248 #258 #254 #242 #274 #275 #276

Notes:

  • Ignore the branch name, I originally created the PR for Puppeteer 13.5.0
  • I am not going to include the binaries in this PR. If you would like to use my binaries or my lambda layer, please see my latest comments
  • If you would like to use a scoped npm package that will be kept up to date until this PR is merged, check out @sparticuz/chrome-aws-lambda

Due to some changes in WebGL/SWAngle, this PR does not included the needed fixes for lambdafs. If you need WebGL, please use my scoped package.

Some of the args are already in /build/args/headless.gn
@Sparticuz Sparticuz mentioned this pull request Mar 8, 2022
@deldrid1
Copy link

deldrid1 commented Mar 9, 2022

@Sparticuz - do you mind to commit your bin/chromium.br and bin/swiftshader.tar.br? I'd love to test this in my build environment with Typescript and webpack but don't have the bandwidth to spin up the compilation side at the moment...

@Sparticuz
Copy link
Author

After cleaning everything up, I'm receiving the same WebGL error's that @alixaxel was getting. (I'm unsure why my initial compile seemed to work, but I haven't been able to reproduce that). It looks like in Chrome 96, swiftshader was dropped and replaced with swangle, so I'm doing some research into what needs to be done to switch to that. I even got vulkan working on my local box and got better performance, but I'm unsure if that would work on lambda or not.

@Sparticuz
Copy link
Author

I believe I've found the files needed to be bundled for Chrome 96+.

  • libEGL.so
  • libGLESv2.so
  • libvk_swiftshader.so
  • libvulkan.so.1
  • vk_swiftshader_icd.json
  • (obviously headless_shell as chromium as well)

Notice that the swiftshader/libEGL.so and swiftshader/libGLESv2.so are not included.

Also the cli flags that needed to be changed are:

  • --use-gl=angle
  • --use-angle=swiftshader

With those files and those flags, chromium runs without error and an inspect shows a working webgl.

I'm running a compile with the latest ansible instructions in order to bundle the needed files. I won't commit the brotli files. I'll let @alixaxel run a build for security reasons, but I will post them so they can be tested. The compile takes about an hour. @alixaxel I also won't commit the changes I made to the ec2 instance, but I'll tell you I upgraded to a c6i.12xlarge.

After I test this out I'll push the latest changes as Ready for review

Also need to change a few flags
@Sparticuz Sparticuz marked this pull request as ready for review March 9, 2022 20:48
@Sparticuz
Copy link
Author

Sparticuz commented Mar 9, 2022

@Sparticuz
Copy link
Author

Sparticuz commented Mar 10, 2022

Here is a Lambda layer: https://raw.githubusercontent.com/Sparticuz/chrome-aws-lambda/b4584a6c65e1c33d7a1afc1edbb825ee4f2509a6/chrome_aws_lambda.zip

I've tested it with the SAM application in the _/amazon folder and it worked. I'll be testing it internally as well.

EDIT: Please see my branch here for the latest layer: https://github.com/Sparticuz/chrome-aws-lambda/blob/13.5_bin/chrome_aws_lambda.zip

@deldrid1
Copy link

@Sparticuz - just to let you know, I've merged in with your _bin branch on top of my changes for webpack and so far so good! I'm doing some larger sized testing today, but nothing to complain about with the updates! (I don't require webgl so I can't speak to that, but basic functionality looks good!)

@ibqn
Copy link

ibqn commented Mar 22, 2022

@Sparticuz great contribution! I am looking forward to see this PR getting approved.

@owlyowl
Copy link

owlyowl commented Mar 22, 2022

@Sparticuz thanks so much for getting this up and running it will be a huge help to the community!

Are there any particular lambda config changes that are required to support the new layer/version?

@bestplay9384
Copy link

bestplay9384 commented Mar 26, 2022

Hey @Sparticuz,

I'm testing Your compilation on AWS Lambda and with DEBUG enabled i got this on chromium boot.

image

I have chromium flags you suggested above.
Any idea what can it be? :)

EDIT: flag that is not included in chrome-aws-lambda flags - --disable-software-rasterizer made errors disappear :) I thought it is an issue with webGL/driver changes you've made.

@Sparticuz
Copy link
Author

It looks like it can't find libglesv2.so. are you using the zip image, or did you build and upload?

@bestplay9384
Copy link

bestplay9384 commented Mar 27, 2022

It looks like it can't find libglesv2.so. are you using the zip image, or did you build and upload?

I was using brotli compressed archives from Your fork :) Those You have linked above :) I have it all packed to lambda layer and then attached to lambda.

EDIT: I've just found out that my custom decompression code for lambda layer build extracts swiftshader libnraries to bin/swiftshader directory - not in bin itself. It is probably an issue - paths mismatch :)

EDIT 2: Yup, fixed paths, removed --disable-software-rasterizer flag and it works as it should :)

@Sparticuz Sparticuz changed the title Puppeteer@13.5.0 Puppeteer@13.6.0 Apr 20, 2022
@Sparticuz
Copy link
Author

I've updated my PR to be Puppeteer 13.6.0, and my _bin branch to have 13.6.0 as well as chromium 101. Layer here. I have not tested it

@lewisl9029
Copy link

lewisl9029 commented Apr 21, 2022

I gave the 13.6.0 layer a shot, and first few invocations seem to work fine (albeit quite a bit slower than the version on main for some reason), but afterwards I get errors that look like this when trying to take a screenshot:

2022-04-21T02:06:48.862Z pw:browser [pid=103][err] [0421/020648.861048:ERROR:shared_image_representation.cc(219)] Attempt to read from an uninitialized SharedImage. Initialized region: (0, 0, 0, 0) Size: (1280, 256)
2022-04-21T02:06:48.864Z pw:browser [pid=103][err] [0421/020648.864208:ERROR:shared_image_representation.cc(219)] Attempt to read from an uninitialized SharedImage. Initialized region: (0, 0, 0, 0) Size: (832, 192)
2022-04-21T02:06:48.864Z pw:browser [pid=103][err] [0421/020648.864616:ERROR:shared_image_representation.cc(219)] Attempt to read from an uninitialized SharedImage. Initialized region: (0, 0, 0, 0) Size: (1280, 64)
2022-04-21T02:06:48.930Z pw:browser [pid=103][err] [0421/020648.929945:ERROR:validation_errors.cc(117)] Invalid message: VALIDATION_ERROR_DESERIALIZATION_FAILED
2022-04-21T02:06:48.930Z pw:browser [pid=103][err] [0421/020648.929974:WARNING:network_service.cc(202)] Mojo error in NetworkService: Validation failed for viz.mojom.CopyOutputResultSender.0  [VALIDATION_ERROR_DESERIALIZATION_FAILED]
2022-04-21T02:06:48.930Z pw:browser [pid=103][err] [0421/020648.929983:ERROR:interface_endpoint_client.cc(664)] Message 500872390 rejected by interface viz.mojom.CopyOutputResultSender
2022-04-21T02:06:48.954Z pw:browser [pid=103][err] [0421/020648.954338:ERROR:shared_image_representation.cc(219)] Attempt to read from an uninitialized SharedImage. Initialized region: (0, 0, 0, 0) Size: (576, 192)
2022-04-21T02:06:48.955Z pw:browser [pid=103][err] [0421/020648.955260:ERROR:shared_image_manager.cc(227)] SharedImageManager::ProduceSkia: Trying to Produce a Skia representation from a non-existent mailbox.
2022-04-21T02:06:48.956Z pw:browser [pid=103][err] [0421/020648.956010:ERROR:shared_image_manager.cc(227)] SharedImageManager::ProduceSkia: Trying to Produce a Skia representation from a non-existent mailbox.
2022-04-21T02:06:48.957Z pw:browser [pid=103][err] [0421/020648.957278:ERROR:shared_image_manager.cc(227)] SharedImageManager::ProduceSkia: Trying to Produce a Skia representation from a non-existent mailbox.
2022-04-21T02:06:48.963Z pw:browser [pid=103][err] [0421/020648.963574:ERROR:shared_image_manager.cc(227)] SharedImageManager::ProduceSkia: Trying to Produce a Skia representation from a non-existent mailbox.
2022-04-21T02:06:48.964Z pw:browser [pid=103][err] [0421/020648.964137:ERROR:shared_image_representation.cc(219)] Attempt to read from an uninitialized SharedImage. Initialized region: (0, 0, 0, 0) Size: (1280, 64)
2022-04-21T02:06:49.026Z pw:browser [pid=103][err] [0421/020649.026090:ERROR:validation_errors.cc(117)] Invalid message: VALIDATION_ERROR_DESERIALIZATION_FAILED
2022-04-21T02:06:49.026Z pw:browser [pid=103][err] [0421/020649.026117:WARNING:network_service.cc(202)] Mojo error in NetworkService: Validation failed for viz.mojom.CopyOutputResultSender.0  [VALIDATION_ERROR_DESERIALIZATION_FAILED]
2022-04-21T02:06:49.026Z pw:browser [pid=103][err] [0421/020649.026127:ERROR:interface_endpoint_client.cc(664)] Message 500872390 rejected by interface viz.mojom.CopyOutputResultSender
2022-04-21T02:06:49.047Z	eb6fc018-3b22-4243-b9f3-743a206c7cdc	ERROR	Invoke Error 	{"errorType":"Error","errorMessage":"page.screenshot: Protocol error (Page.captureScreenshot): Unable to capture screenshot\n=========================== logs ===========================\ntaking page screenshot\n============================================================","name":"Error","stack":["page.screenshot: Protocol error (Page.captureScreenshot): Unable to capture screenshot","=========================== logs ===========================","taking page screenshot","============================================================","    at /var/task/main.cjs:174:10","    at measure (/var/task/main.cjs:35:24)","    at Runtime.module.exports.handler (/var/task/main.cjs:173:28)"]}
END RequestId: eb6fc018-3b22-4243-b9f3-743a206c7cdc

FWIW, I'm using playwright instead of puppeteer, but curious if others had success with taking screenshots using this version (puppeteer or playwright)?

@bestplay9384
Copy link

Hey @Sparticuz,
I've got a chance to test quite much Your changes for 13.5.0/13.5.1. I'm using puppeteer 13.5.1 with chromium 100 (from Your fork). I'm doing around 100k invokes od lambda daily, doing work for me using puppeteer, none of these invokes failed because of chromium/puppeteer issues, so i'm pretty sure it works fine :) I'm just scraping websites so I'm not sure if any of webGL stuff had a chance to occur :/ Just givin' ya all info it works for my needs.

@Sparticuz
Copy link
Author

I gave the 13.6.0 layer a shot, and first few invocations seem to work fine (albeit quite a bit slower than the version on main for some reason), but afterwards I get errors that look like this when trying to take a screenshot:

2022-04-21T02:06:48.862Z pw:browser [pid=103][err] [0421/020648.861048:ERROR:shared_image_representation.cc(219)] Attempt to read from an uninitialized SharedImage. Initialized region: (0, 0, 0, 0) Size: (1280, 256)
2022-04-21T02:06:48.864Z pw:browser [pid=103][err] [0421/020648.864208:ERROR:shared_image_representation.cc(219)] Attempt to read from an uninitialized SharedImage. Initialized region: (0, 0, 0, 0) Size: (832, 192)
2022-04-21T02:06:48.864Z pw:browser [pid=103][err] [0421/020648.864616:ERROR:shared_image_representation.cc(219)] Attempt to read from an uninitialized SharedImage. Initialized region: (0, 0, 0, 0) Size: (1280, 64)
2022-04-21T02:06:48.930Z pw:browser [pid=103][err] [0421/020648.929945:ERROR:validation_errors.cc(117)] Invalid message: VALIDATION_ERROR_DESERIALIZATION_FAILED
2022-04-21T02:06:48.930Z pw:browser [pid=103][err] [0421/020648.929974:WARNING:network_service.cc(202)] Mojo error in NetworkService: Validation failed for viz.mojom.CopyOutputResultSender.0  [VALIDATION_ERROR_DESERIALIZATION_FAILED]
2022-04-21T02:06:48.930Z pw:browser [pid=103][err] [0421/020648.929983:ERROR:interface_endpoint_client.cc(664)] Message 500872390 rejected by interface viz.mojom.CopyOutputResultSender
2022-04-21T02:06:48.954Z pw:browser [pid=103][err] [0421/020648.954338:ERROR:shared_image_representation.cc(219)] Attempt to read from an uninitialized SharedImage. Initialized region: (0, 0, 0, 0) Size: (576, 192)
2022-04-21T02:06:48.955Z pw:browser [pid=103][err] [0421/020648.955260:ERROR:shared_image_manager.cc(227)] SharedImageManager::ProduceSkia: Trying to Produce a Skia representation from a non-existent mailbox.
2022-04-21T02:06:48.956Z pw:browser [pid=103][err] [0421/020648.956010:ERROR:shared_image_manager.cc(227)] SharedImageManager::ProduceSkia: Trying to Produce a Skia representation from a non-existent mailbox.
2022-04-21T02:06:48.957Z pw:browser [pid=103][err] [0421/020648.957278:ERROR:shared_image_manager.cc(227)] SharedImageManager::ProduceSkia: Trying to Produce a Skia representation from a non-existent mailbox.
2022-04-21T02:06:48.963Z pw:browser [pid=103][err] [0421/020648.963574:ERROR:shared_image_manager.cc(227)] SharedImageManager::ProduceSkia: Trying to Produce a Skia representation from a non-existent mailbox.
2022-04-21T02:06:48.964Z pw:browser [pid=103][err] [0421/020648.964137:ERROR:shared_image_representation.cc(219)] Attempt to read from an uninitialized SharedImage. Initialized region: (0, 0, 0, 0) Size: (1280, 64)
2022-04-21T02:06:49.026Z pw:browser [pid=103][err] [0421/020649.026090:ERROR:validation_errors.cc(117)] Invalid message: VALIDATION_ERROR_DESERIALIZATION_FAILED
2022-04-21T02:06:49.026Z pw:browser [pid=103][err] [0421/020649.026117:WARNING:network_service.cc(202)] Mojo error in NetworkService: Validation failed for viz.mojom.CopyOutputResultSender.0  [VALIDATION_ERROR_DESERIALIZATION_FAILED]
2022-04-21T02:06:49.026Z pw:browser [pid=103][err] [0421/020649.026127:ERROR:interface_endpoint_client.cc(664)] Message 500872390 rejected by interface viz.mojom.CopyOutputResultSender
2022-04-21T02:06:49.047Z	eb6fc018-3b22-4243-b9f3-743a206c7cdc	ERROR	Invoke Error 	{"errorType":"Error","errorMessage":"page.screenshot: Protocol error (Page.captureScreenshot): Unable to capture screenshot\n=========================== logs ===========================\ntaking page screenshot\n============================================================","name":"Error","stack":["page.screenshot: Protocol error (Page.captureScreenshot): Unable to capture screenshot","=========================== logs ===========================","taking page screenshot","============================================================","    at /var/task/main.cjs:174:10","    at measure (/var/task/main.cjs:35:24)","    at Runtime.module.exports.handler (/var/task/main.cjs:173:28)"]}
END RequestId: eb6fc018-3b22-4243-b9f3-743a206c7cdc

FWIW, I'm using playwright instead of puppeteer, but curious if others had success with taking screenshots using this version (puppeteer or playwright)?

Bfcache was disabled in puppeteer 13.6, Try that and see if you are getting the same results puppeteer/puppeteer#8182

@lewisl9029
Copy link

lewisl9029 commented Apr 21, 2022

A few more updates:

I gave disabling bfcache a try, but unfortunately it didn't change anything. Also tried an earlier version of the layer at #264 (comment), and it had the same issue.

Afterwards, I tried migrating the script to puppeteer, which worked (albeit with a screenshot time of ~1s compared to ~200ms with playwright on main)! So this seems to be a playwright specific thing. Going to dig into playwright's default flags to see if there's anything I'm missing that might resolve this.

EDIT: Another update:

Figured it out! Apparently this was caused by my custom pre-inflating layer I was using with the version on main to improve cold starts. Seems like that approach no longer worked with this version for some reason.

Everything started working again once I reverted back to using the standard await chromeAwsLambda.executablePath approach with the layer you provided. Apologies for the false alarm, and thank you so much for working on this!

@ferbs
Copy link

ferbs commented Apr 26, 2022

I'm using a build based on this fork and it seems to work perfectly. Am running it in a container image based on public.ecr.aws/lambda/nodejs:14. Thank you @Sparticuz!

Hard to know when this fork will get merged in, so in case anyone needs it, here are instructions for installing from the fork:

git clone https://github.com/Sparticuz/chrome-aws-lambda.git
# ^^^ note: almost 2GB. Maybe do a depth=1 clone of just the puppeteer@13.5.0 branch. (I don't remember that git command though) 

git checkout puppeteer@13.5.0
# ^^^ keep an eye for newer, in case it moves since this was posted. 

npm install
npm pack

# next, replace $your_branch below with actual path:
mv chrome-aws-lambda-13.6.0.tgz $your_branch && cd $your_branch 
npm i --save ./chrome-aws-lambda-13.6.0.tgz

@Sparticuz
Copy link
Author

git checkout puppeteer@13.5.0
# ^^^ keep an eye for newer, in case it moves since this was posted. 

I'll keep the branch the same for the purposes of this PR, but I'll update the PR title and comment when there is a new version of Puppeteer that requires a new build of chromium.

Ideally we can get this merged, then get some automated testing on it. I still don't know enough about the typescript that @alixaxel has written to be confident enough to say one way or the other if what I've done is production ready because of the lack of automated testing. There is only the one SAM test, but it's only testing that chromium takes a screenshot. It doesn't test any other functionality (webgl, etc...)

That said, a number of users ARE using it in production.

@ferbs
Copy link

ferbs commented Apr 26, 2022

@Sparticuz Maybe running the core puppeteer test suite against this build might be a good solution? From a skim of the code, it looks like puppeteer is using an integration test approach, hitting an actual browser for everything. It uses process.env.BINARY to set executablePath (in test/mocha-utils.ts) so plopping their entire repo into a Lambda and running BINARY=$chrome-aws-lambda npm run test might be a decent solution.

@aeristhy
Copy link

does this fix this issue #276 ?

@Sparticuz
Copy link
Author

does this fix this issue #276 ?

Yes

@aeristhy
Copy link

@Sparticuz Hi there, is there anyway to implement this on my codes/dep without manually copy pasting? Should i make a private npm package using this pr?

@Sparticuz
Copy link
Author

@aeristhy

If you would like to use a scoped npm package that will be kept up to date until this PR is merged, check out @sparticuz/chrome-aws-lambda

@bjassael
Copy link

bjassael commented Jun 6, 2022

@Sparticuz thanks for the PR. After updating my code to use these changes there is a drop in performance when taking screenshots with Puppeteer in AWS (from '< 1' to '~8' seconds). Also, total memory consumption almost double from ~450mb to ~800mb. Any clue of what could have trigger this problem or possible fixes?

@Sparticuz
Copy link
Author

After updating my code to use these changes there is a drop in performance

Are you using this PR or my fork? This branch does not have the updated swiftshader code, so chromium is likely searching for the right files and not finding them. I believe someone further up had similar problems.

I'm still trying to figure out how to update this PR with the needed changes.

My fork includes the needed changes to get webgl working.

That would be my guess, but I haven't measured anything.

juliusfitzhugh-ccpo added a commit to dod-ccpo/atat-web-api that referenced this pull request Jun 7, 2022
Implement lambda to generate documents (e.g., DOW) that returns
a base64 encoded string of the pdf binary. Template files are
contained in a layer and are under the /templates folder. Juice
is a third-party package to combine the html and css files.

Still troubleshooting trying to get puppeteer to run inside of
lambda using puppeteer-core and having a compressed chromium
binary added as a dependency or some alternative. The
chrome-aws-lambda package does not appear to be maintained
anymore, but someone has forked the repo and has been updating
recent versions of node (v16) and puppeteer (v14).
- https://acloudguru.com/blog/engineering/serverless-browser-automation-with-aws-lambda-and-puppeteer
- https://github.com/alixaxel/chrome-aws-lambda
- https://github.com/Sparticuz/chrome-aws-lambda
- alixaxel/chrome-aws-lambda#264
- alixaxel/chrome-aws-lambda#275

Tikcet: AT-7345
@bjassael
Copy link

bjassael commented Jun 7, 2022

Sorry, I didn't specified, I'm using the fork. So it does have the webGL changes.

@codykaup
Copy link

codykaup commented Jun 8, 2022

Thanks for putting this together! I tried using the binary from your v14.3.0 branch with Playwright v1.22.2 but I keep getting the following error whenever I try to create a new page:

[err] [ERROR:file_path_watcher_inotify.cc(329)] inotify_init() failed: Function not implemented (38)
[err] Received signal 11 SEGV_MAPERR XXXXXXXXXXXXX

Is anybody else hitting this? Am I doing something wrong?

juliusfitzhugh-ccpo added a commit to dod-ccpo/atat-web-api that referenced this pull request Jun 8, 2022
Implement lambda to generate documents (e.g., DOW) that returns
a base64 encoded string of the pdf binary. Template files are
contained in a layer and are under the /templates folder. Juice
is a third-party package to combine the html and css files.

Still troubleshooting trying to get puppeteer to run inside of
lambda using puppeteer-core and having a compressed chromium
binary added as a dependency or some alternative. The
chrome-aws-lambda package does not appear to be maintained
anymore, but someone has forked the repo and has been updating
recent versions of node (v16) and puppeteer (v14).
- https://acloudguru.com/blog/engineering/serverless-browser-automation-with-aws-lambda-and-puppeteer
- https://github.com/alixaxel/chrome-aws-lambda
- https://github.com/Sparticuz/chrome-aws-lambda
- alixaxel/chrome-aws-lambda#264
- alixaxel/chrome-aws-lambda#275

Tikcet: AT-7345
@Antoine-C
Copy link

Antoine-C commented Jun 9, 2022

@codykaup I had the same error when using Lambda docker image on Apple M1, you need to add the --platform linux/amd64 in order to get rid of this error 👍

@Antoine-C
Copy link

Antoine-C commented Jun 9, 2022

@Sparticuz I can confirm the issue @bjassael is having with performance degradation with the WebGL fix, I can see screenshots being 10x slower (I see numbers going from 150ms to 1.2s+). Maybe using angle with swiftshader is causing this degradation given without the webgl fix it was not using swiftshader libs right ?

juliusfitzhugh-ccpo added a commit to dod-ccpo/atat-web-api that referenced this pull request Jun 9, 2022
Implement lambda to generate documents (e.g., DOW) that returns
a base64 encoded string of the pdf binary. Template files are
contained in a layer and are under the /templates folder. Juice
is a third-party package to combine the html and css files.

Still troubleshooting trying to get puppeteer to run inside of
lambda using puppeteer-core and having a compressed chromium
binary added as a dependency or some alternative. The
chrome-aws-lambda package does not appear to be maintained
anymore, but someone has forked the repo and has been updating
recent versions of node (v16) and puppeteer (v14).
- https://acloudguru.com/blog/engineering/serverless-browser-automation-with-aws-lambda-and-puppeteer
- https://github.com/alixaxel/chrome-aws-lambda
- https://github.com/Sparticuz/chrome-aws-lambda
- alixaxel/chrome-aws-lambda#264
- alixaxel/chrome-aws-lambda#275

Tikcet: AT-7345
@codykaup
Copy link

codykaup commented Jun 9, 2022

Thanks for the heads up @Antoine-C, it's working locally now!

I tried running this in Lambda but it throws a different error for some reason. I tried multiple versions (v14.1.0, v14.1.1, and v14.3.0) but all of them throw this same error. Any ideas on why the binaries from @Sparticuz's fork does this with Playwright?

browser.newPage: Browser closed.
==================== Browser output: ====================
<launching> /tmp/chromium --disable-field-trial-config --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 --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync --allow-pre-commit-input --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 --no-service-autorun --export-tagged-pdf --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --allow-running-insecure-content --autoplay-policy=user-gesture-required --disable-component-update --disable-domain-reliability --disable-features=AudioServiceOutOfProcess,IsolateOrigins,site-per-process --disable-print-preview --disable-setuid-sandbox --disable-site-isolation-trials --disable-speech-api --disable-web-security --disk-cache-size=33554432 --enable-features=SharedArrayBuffer --hide-scrollbars --ignore-gpu-blocklist --in-process-gpu --mute-audio --no-default-browser-check --no-pings --no-sandbox --no-zygote --use-gl=angle --use-angle=swiftshader --window-size=1920,1080 --single-process --font-render-hinting=slight --user-data-dir=/tmp/playwright_chromiumdev_profile-W8GLWJ --remote-debugging-pipe --no-startup-window
<launched> pid=476
[pid=476][err] Received signal 11 SEGV_MAPERR 0000000000b0
[pid=476][err] #0 0x5604b9191cb9 (/tmp/chromium+0x5938cb8)
[pid=476][err] #1 0x5604b9118af3 (/tmp/chromium+0x58bfaf2)
[pid=476][err] #2 0x5604b91917c1 (/tmp/chromium+0x59387c0)
[pid=476][err] #3 0x7fc617d898e0 (/usr/lib64/libpthread-2.26.so+0x118df)
[pid=476][err] #4 0x5604b7d6610a (/tmp/chromium+0x450d109)
[pid=476][err] #5 0x5604b7d65189 (/tmp/chromium+0x450c188)
[pid=476][err] #6 0x5604b7d9fb14 (/tmp/chromium+0x4546b13)
[pid=476][err] #7 0x5604b7d9f90e (/tmp/chromium+0x454690d)
[pid=476][err] #8 0x5604b7cbf8df (/tmp/chromium+0x44668de)
[pid=476][err] #9 0x5604b7ed846d (/tmp/chromium+0x467f46c)
[pid=476][err] #10 0x5604b7ecc5f6 (/tmp/chromium+0x46735f5)
[pid=476][err] #11 0x5604b90f8f9e (/tmp/chromium+0x589ff9d)
[pid=476][err] #12 0x5604bcdfcb18 (/tmp/chromium+0x95a3b17)
[pid=476][err] #13 0x5604bce06ce3 (/tmp/chromium+0x95adce2)
[pid=476][err] #14 0x5604bce06e49 (/tmp/chromium+0x95ade48)
[pid=476][err] #15 0x5604bce0d0c9 (/tmp/chromium+0x95b40c8)
[pid=476][err] #16 0x5604b8978a03 (/tmp/chromium+0x511fa02)
[pid=476][err] #17 0x5604bce04418 (/tmp/chromium+0x95ab417)
[pid=476][err] #18 0x5604bce020b8 (/tmp/chromium+0x95a90b7)
[pid=476][err] #19 0x5604b7a5b98e (/tmp/chromium+0x420298d)
[pid=476][err] #20 0x5604b7a5b37a (/tmp/chromium+0x4202379)
[pid=476][err] #21 0x5604b7a57622 (/tmp/chromium+0x41fe621)
[pid=476][err] #22 0x5604b9151c50 (/tmp/chromium+0x58f8c4f)
[pid=476][err] #23 0x5604b9165a20 (/tmp/chromium+0x590ca1f)
[pid=476][err] #24 0x5604b916572c (/tmp/chromium+0x590c72b)
[pid=476][err] #25 0x5604b9165fa2 (/tmp/chromium+0x590cfa1)
[pid=476][err] #26 0x5604b91aefcb (/tmp/chromium+0x5955fca)
[pid=476][err] #27 0x5604b9166226 (/tmp/chromium+0x590d225)
[pid=476][err] #28 0x5604b91391ed (/tmp/chromium+0x58e01ec)
[pid=476][err] #29 0x5604b79d588d (/tmp/chromium+0x417c88c)
[pid=476][err] #30 0x5604b79d6ed2 (/tmp/chromium+0x417ded1)
[pid=476][err] #31 0x5604b90fc4ce (/tmp/chromium+0x58a34cd)
[pid=476][err] #32 0x5604b812adb2 (/tmp/chromium+0x48d1db1)
[pid=476][err] #33 0x5604b812bfde (/tmp/chromium+0x48d2fdd)
[pid=476][err] #34 0x5604b812bb6f (/tmp/chromium+0x48d2b6e)
[pid=476][err] #35 0x5604b812915e (/tmp/chromium+0x48d015d)
[pid=476][err] #36 0x5604b8129b1e (/tmp/chromium+0x48d0b1d)
[pid=476][err] #37 0x5604b90f88ba (/tmp/chromium+0x589f8b9)
[pid=476][err] #38 0x5604b90f85e5 (/tmp/chromium+0x589f5e4)
[pid=476][err] #39 0x7fc61725c13a __libc_start_main
[pid=476][err] #40 0x5604b68a602a _start
[pid=476][err] r8: 0000000000000010 r9: 0000000000000000 r10: 0000000000000000 r11: 0000000000000246
[pid=476][err] r12: 00007ffedd13c800 r13: 0000173400edf0b8 r14: 0000173400edf930 r15: 00007ffedd13c7d0
[pid=476][err] di: 00001734002e4000 si: 0000000000000000 bp: 00007ffedd13c840 bx: 0000173400ede800
[pid=476][err] dx: d015f40034170000 ax: 00001734002e4000 cx: 0000000000000000 sp: 00007ffedd13c770
[pid=476][err] ip: 00005604b7d6610a efl: 0000000000010246 cgf: 002b000000000033 erf: 0000000000000004
[pid=476][err] trp: 000000000000000e msk: 0000000000000000 cr2: 00000000000000b0
[pid=476][err] [end of stack trace]

@jznadams
Copy link

jznadams commented Jun 9, 2022

I had the same error when using Lambda docker image on Apple M1, you need to add the --platform linux/amd64 in order to get rid of this error 👍

@Antoine-C Where do you add that flag?

@rehanvdm
Copy link

rehanvdm commented Jun 9, 2022

I'm wondering if it might not be better to run puppeteer in a container now that Lambda supports it? This PR has been open and struggling for months now :( or will the same issues be present running it in a container?

PS. I am currently running this on a Lambda in production and don't want to go the container route.

@Antoine-C
Copy link

I had the same error when using Lambda docker image on Apple M1, you need to add the --platform linux/amd64 in order to get rid of this error 👍

@Antoine-C Where do you add that flag?

In your Dockerfile next to the FROM statement or as a parameter when using docker run command

@Sparticuz
Copy link
Author

Any ideas on why the binaries from @Sparticuz's fork does this with Playwright?

I haven't used Playwright, but I also haven't changed anything that would affect it.

For people seeing slowness, does turning webgl off help? This may just be related to the new driver. If someone is running x-ray on their function, I'd love to see any info about what exactly is slow.

@yakirza17
Copy link

Hi @Sparticuz, I make tests for the page.screenshot issue and these are the numbers:

Puppeteer 14.3 with WebGL (based your repo, on tag v14.3.0, not contains the PR of decrease chrome size):
avg(duration): 1775.1579
min(duration): 485
max(duration): 15519
count(duration): 3693

Old puppeteer version (5.5, without this PR):
avg(duration): 275.1661
min(duration): 22
max(duration): 5097
count(duration): 3649

Puppeteer 14.3 without WebGL (--disable-webgl and remove --use-gl=angle, --use-angle=swiftshader):
avg(duration): 732.9199
min(duration): 283
max(duration): 5977
count(duration): 3672

@Sparticuz
Copy link
Author

Sparticuz commented Jun 14, 2022

My guess on the slowness would just be from Chrome's version creep? Those numbers are interesting @yakirza17, however, I'm looking more for a nodejs firegraph that could tell us whether the slowdown is occurring in chrome_aws_lambda, puppeteer, or chromium. FWIW, I really haven't changed any chrome_aws_lambda code besides the patch making it compatible with node16 and ts4.4+.

Edit: Puppeteer 5.5 is Chromium 88, Puppeteer 14.3 is Chromium 103. That being said, I would recommend running with webgl disabled if you don't need it.

@Antoine-C
Copy link

Antoine-C commented Jun 21, 2022

@Sparticuz I was able to run 0x in a Lambda docker container and the flamegraph doesn't show any unoptimized bits regarding the screenshot in playwright nor chrome_aws_lambda so IMO the slowdown is coming from chromium.

When I was using swiftshader directly --use-gl=swiftshader with chromium 99 I was already experiencing a slowness regarding the screenshots. Moving to --use-gl=angle --use-angle=swiftshader fixed it but the WebGL issue came up and it was, as you said, because swiftshader libs where not at the right place and then the slowness appeared again so I'm thinking Swiftshader with chromium 95+ might not be the right choice to use for headless (or maybe it's broken) ?

I came up across these possible flags for ANGLE : https://chromium.googlesource.com/angle/angle/+/main/doc/DebuggingTips.md, I don't have much knowledge here but do you think it's possible to use another renderer like Vulkan (given we're including some vk_* files) ? Or swiftshader is the only way to go ?

@Sparticuz
Copy link
Author

Sorry all, I'm out of the country at the moment. I will update to the latest puppeteer next week.

@Antoine-C
Copy link

@Sparticuz No worries, have you had the chance to look at it ? On my end I've noticed quite some "Browser closed" errors with [pid=348][err] [0626/041651.533068:ERROR:egl_util.cc(74)] Failed to load GLES library: /tmp/playwright/libGLESv2.so: /tmp/playwright/libGLESv2.so: cannot open shared object file: No such file or directory but this is linked to the issue above with WebGL and files not being in the right place but causing an unexpected slowness if they are.

@Sparticuz
Copy link
Author

Hello all, I've made a new package that breaks the link between puppeteer and chrome-aws-lambda.

@sparticuz/chromium no longer needs to be in lock-step with puppeteer. Try it out here

@willianfalbo
Copy link

It works for me @Sparticuz 🤘🏼

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.

None yet