Use Uint8Array for more efficient loading of GIF frame data#26
Use Uint8Array for more efficient loading of GIF frame data#26jbaicoianu wants to merge 1 commit intobuzzfeed:masterfrom
Conversation
|
Coincidentally I also implemented the same changes as #25 before realizing there was a pull request open for it, so +1 for that as well. |
|
Doesn't appear this will ever get merged, but for anyone else using this branch the |
|
I haven't fully evaluated it or switched over, but https://github.com/gtk2k/gtk2k.github.io/blob/master/animation_gif/gifsparser.js seems to be a much cleaner and quicker way of parsing GIF frames, and it what A-Frame uses. libgif-js seems to be a dead project, and even with all the optimizations I've made it's still quite slow. |
|
@jbaicoianu Does https://github.com/gtk2k/gtk2k.github.io/blob/master/animation_gif/gifsparser.js allow us to achieve the simple GIF pause / resume functionality? I didn't found any instructions on the repo. |
|
How to get the total number of frames |
This change results in an approximately 10x speedup when parsing large GIFs. This is accomplished by using
Uint8Arrayinstead of binary strings, and using block memory allocators to increase memory efficiency/reduce GC load.Using a basic
forloop instead ofpixels.forEach()to populate the canvas pixeldata also gave a significant performance boost.