Taking screenshot crashes with WebGL1

Repeated raw calls to CreateScreenshotUsingRenderTarget in Babylon 4.2.0 (without doing anything with the data parameter on its callback) crashes in WebGL1 devices. This was tested with different iOS versions (crashes around 100 calls) and with Safari in MacOS (crashes around 600 calls in my tests).

Also went to explore existing playgrounds using this API function, and found the following two (written by another person):

  • HJI09Z#1
  • HJI09Z#2

Although these do not seem to crash on WebGL1, they add a full screen flickering that makes the whole scene useless.
It seems that now BabylonJS PlayGrounds are using Babylon 5.0.0-alpha11, and thus I replaced the engine that I was using on my own app with 5.0.0-alpha11. The result was that it does not crash anymore, but it introduced now the same flickering as can be seen on the Playgrounds mentioned above.

So it seems that there are 2 separate issues with CreateScreenshotUsingRenderTarget :

  1. On WebGL1 devices and Babylon 4.2.0, there is a crash. I tried doing the call slower (from about 180 ms between calls to around 450 ms, which anyways is non acceptable on my use case), and still crashes. However, it works perfectly on WebGL2 devices .

  2. On either WebGL1 or WebGL2 devices, but with Babylon 5.0.0 Alpha 11, it introduced the full screen flickering. No crashes, but not usable anyways.

Adding @Evgeni_Popov

1 Like

PR is on its way:

When the fix is merged, this PG should work both in WebGL and WebGPU and not flicker:


1 Like

Thank you for the quick fix!!!