I have a problem with the
RenderTargetTexture class, starting at line 61 : https://github.com/BabylonJS/Babylon.js/blob/08dec3cf9c83b61c468de3f0aee0efbd2a72851b/packages/dev/core/src/Materials/Textures/renderTargetTexture.ts#L61
The setter for the
renderList field calls a method
_hookArray, which changes the behavior of the passed array
value. Specifically, the
splice methods are replaced by custom functions.
This causes a problem in our application, because we need to switch between 2 different renderList-s every frame, and since we don’t want to deep-copy the list each time, the reference of the array stays the same between 2 calls.
The problem can be seen in this Playground (starting at line 30) : https://playground.babylonjs.com/#XA2GK6#1
As you can see, the push functions are stacked upon each other, so that calling
push() causes a
Maximum call stack size exceeded error to be thrown.
We found a fix by resetting the
splice methods before setting
renderList, but others may encounter this issue in the future.
If we really need to keep this behavior (e.g., for backwards compatibility), I think it would be great to add some sort of check at the beginning of
_hookArray to avoid exceeding the call stack size.