DEV Community

Cover image for Fast GIF parsing on the web with WASM + Wuffs

Fast GIF parsing on the web with WASM + Wuffs

Sam Thorogood on June 28, 2018

GIFs, or JIFs, are one of those strange oddities of the internet. The format is slow, inefficient, and from the 80s (!)- did we even have color scr...
Collapse
 
adambankin profile image
Adam Bankin

Great read Sam. I do find that gifuct is faster on Safari Mobile (iOS 11.4.1, iPhone 7 plus) but I expect this is due to lack of WASM support…?

Collapse
 
samthor profile image
Sam Thorogood

So WASM actually is supported there. Safari is sometimes slower (my friend commented this too), but we're not really sure why—my hunch is that Safari's JS implementation is very good for this sort of stuff, making gifuct quite fast.

Chrome and Firefox have the more expected pattern.

Collapse
 
weswedding profile image
Weston Wedding

Wow, nice!

I was working on a gifuct-based meme assembler as a side project but maybe I ought to switch to WASM.

Collapse
 
samthor profile image
Sam Thorogood

Thanks, Weston! WASM isn't supported everywhere, but it's pretty amazing how quickly it came to all four modern evergreen browsers.

Collapse
 
alexbender profile image
Alex Bender

Hi Sam!
Thank you for such a good explanation of wasm: now I feel that I can start doing something with it, really intriguing.
One note:
seems that you have two Three steps.
Thanks!

Collapse
 
samthor profile image
Sam Thorogood

Whoops, fixed! 🤣

Collapse
 
alexbender profile image
Alex Bender

so fast, haha. Thanks!

Collapse
 
kristobaljunta profile image
Kristobal Junta • Edited

Somehow, I observe an 8x speed increase on the latest Chrome on Android

Collapse
 
samthor profile image
Sam Thorogood

That's great! We see a huge spread—some of it, I suspect, is that we are hitting initial startup work in either case. Running the code 100 times on user's browsers is not considered friendly, since I'd size their devices up for minutes, but that would be the way to really determine what the time is.

Collapse
 
ben profile image
Ben Halpern

Wow, so cool!

Collapse
 
nektro profile image
Meghan (she/her)

Great article! I'm very excited about the future of WASM :D

Collapse
 
onefabis profile image
Alexander Smirnov • Edited

Hello, at step 3 I was faced with the next error:
EM_ASM should not receive i64s as inputs, they are not valid in JS