ActionManager.onPointerOutTrigger and "Uncaught RangeError: Maximum call stack size exceeded" error

Hello,

When dynamically creating interactable meshes and adding a ActionManager.onPointerOutTrigger without a matching ActionManager.OnPointerOverTrigger, results in an “Uncaught RangeError: Maximum call stack size exceeded” error.

In most cases you would want to register both triggers for interaction feedback, but the behavior seems like a bug because it only happens in certain situations.

To reproduce, delay for a random time or wait for user interaction. Then add a mesh to the scene and register an ActionManager.onPointerOutTrigger. Do not register an ActionManager.onPointerOverTrigger. Some time must pass after the scene is created and the cursor must be over the canvas when the trigger is registered.

When the mouse moves off the mesh, you will get a bunch of “Uncaught RangeError: Maximum call stack size exceeded” errors.

If both an ActionManager.onPointerOutTrigger and ActionManager.onPointerOverTrigger are registered, no errors.

If the ActionManager.onPointerOutTrigger is registered without the ActionManager.onPointerOverTrigger when the scene is created, no errors.

If the mouse is not over the canvas when the ActionManager.onPointerOutTrigger is registered, no errors.

Here’s a playgound.
Simple GUI in fullscreen mode | Babylon.js Playground

Loading the playground and keeping the mouse out of the canvas, no errors.
Loading the playground with the mouse over the canvas when the trigger is registered, open the dev console and behold the errors.

On lines 38 and 39 you can see:

const addOverTrigger = false;
var createInstantly = false;

Set any of the addOverTigger or createInstantly variables to true, no errors.

1 Like

I’m having difficulties to repro the error.
Mouse pointer in the page, I refresh the PG using F5 but got no error.
cc @amoebachant

I was able to reproduce the error. I tried to find a solution but gave up after several attempts. The mouse pointer must be over the canvas area (and should be moving) when the scene starts. I’ll give it another try soon.

The call stack seems like this:

@amoebachant Maybe this will help you to track down the bug.

Set scene.skipPointerMovePicking = true on script load.
Set scene.skipPointerMovePicking = false after the actions were registered.

In this case the PG works correctly.

Thanks, I’m able to repro the issue and I’m investigating

2 Likes

This will fix it Fix recursive loop in onPointerOutAction by sebavan · Pull Request #16057 · BabylonJS/Babylon.js · GitHub Thanks everyone for the analysis

4 Likes