Token cursor not moving when browser is not active

Hello Team,

I’m trying to move the token cursor programmatically within a looping (following this example =>
Token Simulation
). I found out that cursor was immediately stopped if I go away from the browser. E.g If I open new browser tab for a while and come back to the simulation screen, cursor was already stopped itself. How can I resolve it ,please ?

Below is my example code:


var lastActivityId = "";
foreach ( var activityId in activityIds){ 

var fromActivityId= activityId[0];
var toActivityId = activityId[1];


    if (lastActivityId != "") {
      simulator.waitAtElement(lastActivityId, false);
    }

    simulationSupport.triggerElement(fromActivityId);
 simulator.waitAtElement(toActivityId, true);

lastActivityId = toActivityId;

}

What’s the use case? You want to let it run in the background? The token simulation uses requestAnimationFrame.

requestAnimationFrame() calls are paused in most browsers when running in background tabs or hidden <iframe>s, in order to improve performance and battery life.

See Window: requestAnimationFrame() method - Web APIs | MDN.

You’d have to change the implementation of how the animations work to work around this.

My use case is like that…I have one signalR messaging service. What I doing now is if I receive a message , I want to move the token immediately box to box according to message. Lets say message is “A” , move the token to “A” box.

Yes…I want to let it run even user is away from the screen.

I’m sorry… not understand this very well. You meant to change at my implementation or change at the bpmn-js-token-simulation library level ,please?