canvas-capture icon indicating copy to clipboard operation
canvas-capture copied to clipboard

Uncaught ReferenceError: remaining is not defined

Open CreativeTransmissions opened this issue 2 years ago • 9 comments

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)

CreativeTransmissions avatar Jun 21 '22 11:06 CreativeTransmissions

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!

amandaghassaei avatar Jul 01 '22 23:07 amandaghassaei

@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)```

symetryn avatar Jul 05 '22 13:07 symetryn

@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 avatar Jul 05 '22 17:07 amandaghassaei

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!

amandaghassaei avatar Jul 06 '22 00:07 amandaghassaei

@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.

symetryn avatar Jul 06 '22 01:07 symetryn

@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!

amandaghassaei avatar Jul 06 '22 04:07 amandaghassaei

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

image

Because in the main branch I have the same issue;

Paolino95 avatar Oct 06 '23 13:10 Paolino95

@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

amandaghassaei avatar Oct 11 '23 01:10 amandaghassaei

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

junekuhn avatar Dec 30 '23 20:12 junekuhn