I'm rendering animations with Puppeteer in AWS Lambda and I'm facing a strange behaviour: Puppeteer runs faster than real-time.
My animation takes 4 seconds on a regular desktop Chrome. When run in AWS-Lambda-Puppeteer it takes a range between 1 second to 4 seconds, depending on the viewport size.
Completely counter-intuitive, the bigger the viewport, the faster it runs. All the other variables are kept the same (CPU, mem, code, ...)
As expected, the code always generates 25 screenshots per second (whatever the viewport size), so 100 frames in 4 seconds. This makes me think that the node js code runs correctly in real time.
Using a viewport of 300x200, the animation takes 4 seconds and all 100 frames contain the animation.
When I change to a viewport of 600x400, the animation plays faster and takes less than 2 seconds, so the first 50 frames have the animation and the last 50 frames are static with the last animation frame.
As I increase the viewport size, the speed increases up to less of a second.
Does anybody know if there's an explanation and a solution for this?
Additional notes:
I don't think it's a problem with my code, as it creates the frames as expected. It seems more a Puppeteer behaviour / setting.
By the way, I'm taking screenshots using the regular:
page.screenshot({
omitBackground: true
});