Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple instances collide in the worker #29

Open
Uplink03 opened this issue Aug 3, 2015 · 0 comments
Open

Multiple instances collide in the worker #29

Uplink03 opened this issue Aug 3, 2015 · 0 comments

Comments

@Uplink03
Copy link

Uplink03 commented Aug 3, 2015

The Pixastic instances share the worker, so if you have two instances that you operate simultaneously the result is not what you want.

The easiest fix is to move var worker; from the shared Pixastic variable space to the constructor so each instance has its own worker:

diff --git a/pixastic.js b/pixastic.js
index c9fb188..e0a7f3f 100644
--- a/pixastic.js
+++ b/pixastic.js
@@ -11,8 +11,6 @@

  var Pixastic = (function() {

-    var worker;
-
     function createImageData(ctx, width, height) {
         if (ctx.createImageData) {
             return ctx.createImageData(width, height);
@@ -22,6 +20,8 @@
     }

     function Pixastic(ctx, workerControlPath) {
+        var worker;
+

         var P = {},
             width = ctx.canvas.width, 

There is probably a better way to do this, but I didn't spend time figuring it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant