Massive flickering when limiting framerate on multiple canvas views

Hi, I need help fixing this critical bug.

Intent

want to limit framerate to improve performance on multiple canvases.
preferably different framerate to each canvas

Symptom

flickers unusably

Reproducable

Uncomment line 71 to see frame rate limiting working properly when using single canvas

Limiting framerate on multi view canvases | Babylon.js Playground (babylonjs.com)

Thank you in advance :heart:
Any alternative is also welcome! :pray:

I’m no specialist of performance here. Clearly not. Yet, you are limiting at 12fps a movement that goes from 0 to 1 (bjs units). I don’t see how this could run smoothly at anything less than 24fps (human eye average speed to interpolate images - using motion blur). If you run your PG at 25/30fps the result is not bad (in my opinion).

1 Like

Oops, sorry, my post and reproduction wasn’t clear enough.

I’ve changed the original post’s PG and description for clarity.

The main issue is that you cannot really do that with multi views. On each RAF, the system will render the view and if the view was not updated it will simply clear it and copy a cleared screen:

Babylon.js/packages/dev/core/src/Engines/AbstractEngine/abstractEngine.views.ts at master · BabylonJS/Babylon.js (github.com)

1 Like

To be more precise, this code is always executed and thus the copy always happen:
Babylon.js/packages/dev/core/src/Engines/abstractEngine.ts at master · BabylonJS/Babylon.js (github.com)

Thank you for pointing me where to look.
It seems hacking with view.enabled could skip the entire code path.

https://github.dev/BabylonJS/Babylon.js/blob/6c11382529121139e9cf99b8ea1ed393b8ff7247/packages/dev/core/src/Engines/AbstractEngine/abstractEngine.views.ts#L247-L249

Let me try this :crossed_fingers:

In the meantime, don’t you think framerate limiting with or without multi canvas is a demanded feature? It would be great to see this._renderViews() be refactored in a more controllable way.

I found a workaround using view.enable!

thanks to @Deltakosh and @mawa :bowing_man:

2 Likes

I’ll answer this from a user experience/gamer experience perspective. Usually, it would be part of user options/settings. As a user/gamer, I like it this way. Of course, personal opinion only. :smiley:

1 Like

Excellent!

1 Like

Thanks for your suggestion!
I will take that as a positive for the feature, but allowing users to config is a great idea.

1 Like