-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
Add WebGL Support #108
Comments
Hi @anvaka — That's interesting. When building chromium from source, it also produces a |
@anvaka do you have a repo containing a working setup for running webgl on AWS lambda? I'm trying to do the same thing without luck :( |
I just got this running using the steps @anvaka provided. Not sure if it's enough to just include a |
Yep, I can confirm, I got it working as well. The best option is to get the headless_shell binary and the libOSMesa.so in the AWS redHat distro and ship them together to the lambda. Note that all data paths needs to point to /tmp, otherwise it will crash because of write permissions. The webgl version Mesa provides is wegbl1 but it does the work, pretty slow but works. |
Hi Guys, I'm still having trouble, so I'm hoping someone could point me in the right direction.
Deploying it I still can't see rendered webgl content. Is there a step I am missing? Cheers |
To anyone looking for a working combination of Mesa and Headless shell for AWS, these are the binaries, it provides pretty slow webgl V1, but it works. Hope it helps! Headless Shell Mesa AWS Lambda Remember to put in your flags:
Otherwise it will crash due to write permissions. |
Hello, |
If anyone had the same PDF issue, rolling back to |
Has anyone had experience using |
I was hoping you still had that build somewhere. @mvoropaiev pointed out the link doesn't work. I tried what @anvaka suggested without any luck. I have a zip with both Here are my CLI args:
I'm actually firing this up with Puppeteer. The same command works locally, but I get errors on the lambda. My lambda works fine for non-webgl stuff. |
Sorry for the broken link guys. I re-uploaded the zip here: It has the libosmesa.so already in the directory, just point Puppeteer to it and everything should work fine. Disclaimer: I ended up using Software Based Rendering using array buffers(Threejs) because Mesa rendering is slow as a asphalt serum. Lambda CPU is pretty fast, so my rendering time went down from minutes to seconds(30 or less). |
Thanks!. This is helpful On a sidenote, do you have any idea how to get swiftshader-webgl on a lambda? Or if it's possible? I'm trying to render a mapbox map on a lambda, and I'm really not having luck. |
@rthomps7 I haven't deal with swiftshader yet, but if you get it working let me know! What I do is launch a Lambda EC2 image instance, compile everything there with static linking, and then try to get a screenshot of some Webgl render. To double check I try to use the static compiled library in a fresh CentOS VM locally. |
@rthomps7 did you had any luck trying swift shader? I'm searching online but without luck. I think it is possible to build headless chrome with swiftshader enabled. |
What about adding the following line after: build flags?
Afterwards a quick test can be done by adding:
In chromium command line arguments. |
I have not been able to dedicate the time to it, but I'd love to have it
figured out.
…On Mon, Aug 20, 2018 at 8:48 AM Victor O. Santos Uceta < ***@***.***> wrote:
What about adding the following line after: build flags
<https://github.com/adieuadieu/serverless-chrome/blob/master/packages/lambda/builds/chromium/build/build.sh#L90>
?
echo 'enable_swiftshader = true' >> out/Headless/args.gn && \
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#108 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABOMZKC8R7Q92IPwbZQhBq4-j8SyoHBUks5uSr4pgaJpZM4R5F2->
.
--
Bobby Thompson / *Co-Founder*
913.314.2520 <javascript:void(0);> / bobby@uhray.com
www.uhray.com
|
I can try doing a build with |
@adieuadieu I could easily to do it tomorrow morning my time |
@adieuadieu I volunteer to that. I already have some experiments setup there, I just need the binary to replace. |
Thank you! I've started a build. If it builds successfully, I'll provide a link to the binary in the morning (UTC+2). |
OK; binary is available here. It's also available in a Docker image: adieuadieu/headless-chromium-for-aws-lambda:experimental-swiftshader |
@adieuadieu it seems WebGL doesn't work with the provided binary in my case. |
@adieuadieu it does not seems like it is working for me either... I have not build headless chrome for Unix yet, but in Windows, chromium comes with a directory called swiftshader with two binaries:
I guess that for a lambda build will be something like:
If you can find some files like those in the build directory, we need to provide those in the same directory as headless_chrome binary at the time of launching with:
Which is the case with MESA lib. |
@vsantosu ah shoot. you're right. I'll get you those library binaries, as well. Need to do another build, though. The EC2 instance I built on was terminated. |
i've built Chromium using this instruction Here are the output files: They works for me and WebGL renders on the page. Unfortunately I didn't notice any benefits in comparison with |
Look forward to seeing this in action.
…On Wed, 22 Aug 2018 at 7:16 am, Andrei ***@***.***> wrote:
i've built Chromium using this instruction
<https://github.com/adieuadieu/serverless-chrome/blob/master/docs/chrome.md>
Here are the output files:
headless_shell
<https://s3-eu-west-1.amazonaws.com/apalchys-public/headless_shell>
swiftshader/libEGL.so
<https://s3-eu-west-1.amazonaws.com/apalchys-public/swiftshader/libEGL.so>
swiftshader/libGLESv2.so
<https://s3-eu-west-1.amazonaws.com/apalchys-public/swiftshader/libGLESv2.so>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#108 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAjVHvuPP_fhORSGC5gtCYYO77eMl6hrks5uTHiogaJpZM4R5F2->
.
|
Great! Thanks, I will try some benchmarks tonight as well. Last time I tried MESA it took about 3 minutes to render some Threejs scene with lights. We also need to check if swiftshader takes advantage of parallelism, if so in AWS lambda 1 core environment there will be not much difference. |
@vsantosu - any luck? |
@rthomps7 unfortunately not :(... I tried to setup the provided build by @apalchys but it does not seems to work for me in AWS Lambda... @apalchys , did you got to tried in an actual AWS lambda function or just docker? If so, what is your directory organization(do you leave the .o files for swiftshader in the /swiftshader directory or next to the headless chrome binary?). Also, can you provide your command line flags? Whenever I try to launch it, it does not even load the page. The build provided by @adieuadieu works for me and is pretty lightweight but I don't have the swiftshader binaries, I don't dare to mix them with the ones provided by @apalchys. I'm curious what version of WebGL is reported when using swiftshader.... |
@vsantosu actual AWS lambda. I will try to create a simple working repo for AWS Lambda by tomorrow |
Thanks so much, @apalchys ! |
I've created a repo: Also here is you can find zipped lambda code (please note it is over 50mb and you need to use s3 to upload): and here is a working demo which returns a screenshot of https://get.webgl.org/ page |
Thanks so much @apalchys, I will be testing and uploading some benchmarks tonight! |
Btw, this issue was marked as “Fixed” yesterday: https://bugs.chromium.org/p/chromium/issues/detail?id=873321 |
Ok guys, first of all thanks so much @apalchys for providing the binaries, I got the results we where looking for. First, the benchmark in rendering one scene using the BabylonJS library(uses WebGL v1 and WebGL 2 when available). The scene I'm rendering is one like this, which consists of: 1- Launching Puppeteer with the following flags:
2- Load the HTML page with the BabylonJS library, which will make a network call to load a 3D model.
The following are the results: Lib Mesa: WebGL V1 supported
SwiftShader: WebGL V2 supported
SwiftShader is 131 times faster! Also, the resulting render with swiftshader is higher quality, pay attention to details: LibMesa Render So yea guys, swiftshader is pretty performant. So why there is so slow renders some times? Well, doing the benchmark, I think i found the real issue here... The 3D model for the Babylon Scene is about 30MB, but thats not problem, after all I do downloads of more than 100MB in seconds before launching chromium... But lets look at this logs of the download progress inside the Chromium....
2min 56s total download time! 3 minutes to download 30MB?? Something is off... In my local machine with a slower connection it does not take even 5 seconds... So after researching a bit, it seems that the flag that is killing performance is:
Which it seems there are issues around. My theory is that when a download starts as a single process, it hugs all operations in the browser, therefore is extremely slow. If I take this flag out, the browser fails to launch... |
@vsantosu that's awesome indeed! Could you share the code to get it working? somehow I get this error when trying to run the sample provided by @apalchys:
Also, do you think it could be suitable to run with THREE.js + animations? |
Hello @dukuo , Are you running the binaries in AWS lambda? Otherwise it won't launch in other environment which is not AWS lambda, their EC2 redhat instance, and probably a CentOS 7 OS. It was compiled to run in that distro. "do you think it could be suitable to run with THREE.js + animations?" Absolutely! You could definitively render a scene, and create a 360 degree rotation gif or video from the canvas. |
@dukuo Usually ENOENT code means that file or directory is not found. Please check your files/directory structure and make sure you unzipped the archive with the binaries (see README https://github.com/apalchys/lambda-puppeteer-webgl-swiftshader) |
The solution by @vsantosu is great for screenshots with Page.captureScreenshot() but when I tried to create a pdf with Page.printToPdf() the WebGL disappears. I worked around this by reverting to the earlier version with osmesa instead of swiftshader but unfortunately it's much older and other things break as a result. Refs: https://bugs.chromium.org/p/chromium/issues/detail?id=809065 & puppeteer/puppeteer#1731 |
WebGL should work with the precompiled Chromium binaries available here. |
Would you please be able to share the config for your AWS lambda deployment for your example? Have been trying everything with no success. Simply trying to duplicate your demo on my own lambda function. Here's my latest error:
I understand there's an issue location libnss3.so but it's no where to be found in your repo either. Many thanks. |
Hello,
I spent all day experimenting and got WebGL working with headless shell. See the thumbnails here: https://www.reddit.com/r/pplay/ - they are rendered by lambda function from webgl scene.
To enable WebGL:
disable_shared
toenable_shared
(line 534) to create libOSMesa32.so file). On EC2 instance, then final file was called libMangledOSMesa32 - just copy it next to the headless chrome binary aslibosmesa.so
.disable-gpu
flag, and tweak serverless-plugin-chrome, so thatlibosmesa.so
is included into distribution.PS: I don't remember whether I used
headless_shell
from this repository.It might be from https://github.com/universalbasket/aws-lambda-chrome But still - the WebGL in AWS lambda is possible, and I'm very happy to share it :).The text was updated successfully, but these errors were encountered: