Preventing canvas freeze/unresponsive tab from too many VideoTextures

I prepared a playground example here which shows 10 videotextures playing simultaneously https://playground.babylonjs.com/#DYW6PM#3

The issue is that in our BJS app, we could conceivably have more than 10, in fact, assuming our end-users computers can handle it, the more the better.

The problem here is that when I increase (totalVideoMeshes) from 10 to say 100, the canvas/tab will freeze and go unresponsive, but I don’t see any errors in the console or anywhere else, and my only recourse is to close the tab and open a new one.

Depending on the scene sometimes the lock ups will happen at 50, or 60, or 70, but at some point, things lock up, and I don’t really know where to “draw the line” so to speak.

Maybe someone can shed some light on the underlying cause(s), and ideas for how to optimize or prevent/handle this situation? (maybe monitoring GPU resource usage, or some such mechanism?)

Not sure if this is helpful at all but I thought to check chrome://gpu and this is what I see under Log Messages.

[13643:13704:1108/100648.814047:ERROR:validation_errors.cc(106)] : Invalid message: VALIDATION_ERROR_UNEXPECTED_NULL_POINTER (null field 1)
[13643:13704:1108/100648.814114:ERROR:gpu_child_thread.cc(67)] : Mojo error in GPU process: Validation failed for gpu.mojom.GpuChannel [VALIDATION_ERROR_UNEXPECTED_NULL_POINTER (null field 1)]
[13643:13704:1108/100648.841626:ERROR:interface_endpoint_client.cc(665)] : Message 208270303 rejected by interface gpu.mojom.GpuChannel
[13643:13704:1108/100648.841721:ERROR:validation_errors.cc(106)] : Invalid message: VALIDATION_ERROR_UNEXPECTED_NULL_POINTER (null field 1)
[13643:13704:1108/100648.841757:ERROR:gpu_child_thread.cc(67)] : Mojo error in GPU process: Validation failed for gpu.mojom.GpuChannel [VALIDATION_ERROR_UNEXPECTED_NULL_POINTER (null field 1)]
[13643:13704:1108/100648.841804:ERROR:interface_endpoint_client.cc(665)] : Message 208270303 rejected by interface gpu.mojom.GpuChannel

Update: At face value I don’t think it’s a resource consumption thing… when I watch CPU/GPU and RAM/VRAM utilization, I don’t see anything that really jumps out at me, but maybe I’m missing something :man_shrugging:

Also, I updated my playground example so you can progressively add more textures to the scene, in this version you can hit the “Enter” key to add 10 at a time https://playground.babylonjs.com/#DYW6PM#5 until it eventually freezes

Hello there! I tried to get it to crash on my dev machine (with a Quadro P620), but even with some 750 textures, it was still running (slightly modified your example to add to random positions once the position array runs out: Babylon.js Playground (babylonjs.com)). Through I did notice eventually that quite a few of the VideoTextures stopped playing.

Maybe @sebavan who has been working on video or @Evgeni_Popov have some idea of what could be done?

1 Like

I’m not sure much can be done…

The number of videos you can show at once will probably depend on the browser / the GPU and the memory available. I don’t see a way to know beforehand how many videos you will be able to display simultaneously.

1 Like

@carolhmj thank you for that test, that just made me think to test it in windows (since I was originally running this in linux mint) and as it turns out, I can reach my 100 videotexture target just fine in windows…

so something is happening that’s unique to the environment, and I’ve confirmed/reproduced on another laptop I have (different model different GPU)

some observations:

  1. windows chrome/brave everything works fine
  2. linux chrome/brave tab freezes/becomes unresponsive
  3. linux firefox tab never freezes but some of the video textures do

I don’t know if any of the above provides hints?

1 Like

Here’s a video of what’s happening bjs videotexture freezing - YouTube

Hmmmm it might have to do with linux GPU drivers? Unfortunately the support is not quite as good there as in windows :confused:

1 Like

Ok, I suppose I can do an OS check and throttle based on that.

Maybe one day it’ll just fix itself with new drivers or something.