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

Uncaught ReferenceError: remaining is not defined #10

Open
CreativeTransmissions opened this issue Jun 21, 2022 · 9 comments
Open

Uncaught ReferenceError: remaining is not defined #10

CreativeTransmissions opened this issue Jun 21, 2022 · 9 comments

Comments

@CreativeTransmissions
Copy link

CreativeTransmissions commented Jun 21, 2022

Hi there, this error occurs on load.

Installed using npm, using with a svelte project.

Fix should be just a case of defining the variable "remaining" before use.

Uncaught ReferenceError: remaining is not defined
at LZWEncoder.encode (canvas-capture.js:3402:14556)
at GIFEncoder.writePixels (canvas-capture.js:3402:12864)
at GIFEncoder.addFrame (canvas-capture.js:3402:7599)
at renderFrame (canvas-capture.js:3402:28769)
at self.onmessage (canvas-capture.js:3402:29314)

@amandaghassaei
Copy link
Owner

oof, this error is coming from a pre-compiled dependency. I've added a fix to the dev branch, can you test this by running:

npm install https://github.com/amandaghassaei/canvas-capture#dev

If that works, I'll merge it into main.

thanks!

@symetryn
Copy link

symetryn commented Jul 5, 2022

@amandaghassaei Hello there, thank you for the amazing library. I encountered the same error and after running
npm install https://github.com/amandaghassaei/canvas-capture#dev
I seem to have another similar error on the dev branch:

    gif.js:2 Uncaught ReferenceError: curPixel is not defined
    at LZWEncoder.encode (gif.js:2:14878)
    at GIFEncoder.writePixels (gif.js:2:13164)
    at GIFEncoder.addFrame (gif.js:2:7898)
    at renderFrame (gif.js:2:29069)
    at self.onmessage (gif.js:2:29615)```

@amandaghassaei
Copy link
Owner

@symetryn ok I fixed curPixel in the dev branch, but I'd imagine there are other issues.

  • Do you have a test project that I can attempt to build to reproduce this?
  • Or if you wouldn't mind submitting a PR with the fixed issues? All I did was search for curPixel in gif.js and add a "var" in front of the first place it was called. It seems like a lot of variables in gif.js that are not properly defined.

This is not a great solution overall, I know, but until I can find time to rip out and redo some of the CCapture internals, it will have to do.

thanks!

amandaghassaei added a commit that referenced this issue Jul 6, 2022
@amandaghassaei
Copy link
Owner

ok I took a look at https://github.com/jnordberg/gif.js/blob/92d27a02841339e202c75150dcf6fe5f4fa42ec5/src/LZWEncoder.js

and realized that remaining and curPixel should be defined in the root of LZWEncoder, rather than inside a function. I also found another variable n_bits that needed to be defined. I've just commited the latest to the dev branch, let me know if that's working!

@symetryn
Copy link

symetryn commented Jul 6, 2022

@amandaghassaei Thank you for your work.
After looking further I found that this issue didn't occur in incognito mode. I tried disabling extensions one by one and it seems some how this issue only occurs when the official react dev tools extension is enabled. It probably declares the variables in same scope as gif.js. So, this seems to be a non issue altogether.

@amandaghassaei
Copy link
Owner

@symetryn sounds good, thanks for looking into that.

@CreativeTransmissions does the current dev branch fix the svelte issue? or do you have a project that I can take a look at to resolve this? thanks!

@Paolino95
Copy link

Sorry, @amandaghassaei , do you have merge this last 4 commits into main branch?

image

Because in the main branch I have the same issue;

@amandaghassaei
Copy link
Owner

@Paolino95 I don't think I ever did because I was waiting to hear back if the changes I made had any effect. Can you import the dev branch and test it?

npm install git+https://github.com/amandaghassaei/canvas-capture.git#dev

thanks

@junekuhn
Copy link

I had the same problem and the dev branch fixed it for me

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

5 participants