Comments (2)
I ran into likely the same bug. I get the same error message after trying to encode 201 frames of a 512 by 512 resolution animation but I think the more critical detail is how large the compressed data is getting. It crashed shortly after the "outs" variable reached roughly 50 million elements. It is a ByteArray as defined in GIFEncoder.js which is repeatedly given more bytes using writeByte and writeBytes in the LZWEncoder.js. Eventually, the browser freezes for a few seconds before showing the error message above. The exact line of crash was outs.writeBytes(accum, 0, a_count) in the flush_char function of LZWEncoder.js while GIFEncoder is calling output on a pixel indirectly from the addFrame function. Immediately before that final call to writeBytes, outs = ByteArray { bin: Array(50139333)} according to Edge's debugger tools. I tried to encode the same animation in both Microsoft Edge and Google Chrome and it crashed on the same frame. I'm testing with a laptop that has 8GB of RAM.
I want to help you reproduce the problem so I'm sharing a prototype that tries to encode and download a gif as soon as you open it. When I open it in Edge, it encodes many frames but eventually crashes within a minute or so.
My prototype references a minified version but the problem is reproduced if you download and reference using script tags in the HTML file:
jsgif/LZWEncoder.js
jsgif/NeuQuant.js
jsgif/GIFEncoder.js
gifOutputBufferTooLarge.zip
Here is what I see after the crash in Microsoft Edge Version 113.0.1774.42 (Official build) (64-bit) in Windows 10:
I understand if the encoder runs out of RAM at some point but 50MB seems a little small for a maximum sized gif. Even if ByteArray can't expand beyond 50 million elements or so, a JavaScript Error or exception would be FAR more graceful than letting the browser tab completely crash. If GIFEncoder needs to be optimized for memory, a typed Array of 8-bit elements such as Uint8Array should use a small fraction of the memory.
from jsgif.
Pull request #40 is open to tackle a large part of this problem by optimizing the data structure maintaining the encoded GIF data. I have it merged in my fork so if you want a more updated and stable jsgif, try my fork. antimatter15's repo looks like it has been dead for about 6 years.
from jsgif.
Related Issues (20)
- No license information HOT 1
- `addFrame` with `is_imageData=true` makes Chrome hang up HOT 3
- Writing canvas to GIF outputs double speed GIF HOT 1
- License HOT 1
- last frame of addFrame is not added to gif HOT 1
- Data URI generates a black gif HOT 4
- jsapng? can you make convas into animated PNG? HOT 5
- GIF almost empty HOT 4
- Animated Gif comes out black w/ Web Workers HOT 6
- Pixel width black line on left edge of GIF
- Add git tag
- My webcam snapshot is being overlay by the gif ??
- No plugin.xml file
- Color Reproduction Issue HOT 2
- Fixes report HOT 1
- Global color map HOT 2
- License? HOT 2
- The encoding of the Gif fails depending on the size of the canvas HOT 1
- Background image shown in canvas but not in image output HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsgif.