How do I emulate WebGL stuff with OESMesa on AWS Lambda? How do I emulate WebGL stuff with OESMesa on AWS Lambda? selenium selenium

How do I emulate WebGL stuff with OESMesa on AWS Lambda?


Yes it is possible!

You need the right combination of:

  1. headless-chromium binary
  2. libosmesa.os binary (in same directory)
  3. launch chrome headless with the right flags, such as (see link for full details): ['--use-gl=osmesa', '--enable-webgl', '--ignore-gpu-blacklist', '--homedir=/tmp', '--single-process', '--data-path=/tmp/data-path', '--disk-cache-dir=/tmp/cache-dir']

This thread on the serverless-chrome github project discusses the issue and provides some binaries which I have used to capture screenshots of WebGL content on AWS Lambda using Page.captureScreenshot().

https://github.com/adieuadieu/serverless-chrome/issues/108#issuecomment-416494572

(See comment by @apalchys on 28th August)

This particular example uses SwiftShader which seems to be the preferred option going forward.

Note, however, that I was unable to create PDFs using Page.printToPDF() using this version - WebGL content just appears blank/white. However, I was able to also get Page.printToPDF() using an earlier version which uses osmesa, see https://github.com/adieuadieu/serverless-chrome/issues/108#issuecomment-371199530