soulwire/sketch.js

Issue with Running Multiple Instances

Opened this issue · 0 comments

Hey, I am trying to run two instances of Sketch.js on two different canvases. However, my demo will only run the latest Sketch.js instance that was created. I've created a reduced test below that shows the issue.

https://codepen.io/jackrugile/pen/1cd4ff94228f26fbd3775d5e9bc04dd9

You can confirm this by commenting out the second instance of the creation starting at line 15.

I am suspecting there is something going wrong with either the start(), running, dt, or millis properties when using multiple instances. You can see how they output different values in my console log interval at line 31:

setInterval(function() {
  console.log('---');
  console.log('a.dt:', a.dt, 'b.dt:', b.dt);
  console.log('a.millis:', a.millis, 'b.millis:', b.millis);
  console.log('a.running:', a.running, 'b.running:', b.running);
}, 1000);

I even tried adding a manual a.start() call, but a always reports running to be false.

I am not sure how the inner working of Sketch.js handle multiple instances, but there could be an issue there. If there's a solution for this, let me know. Thanks!