|Summary:||Implement btoa and atob functions in Web Workers|
|Product:||WebKit||Reporter:||Jon Leighton <j>|
|Severity:||Enhancement||CC:||adam, ap, cdumez, dmitry, ericbidelman, mathias, popecode|
|Version:||528+ (Nightly build)|
Description Jon Leighton 2011-03-03 04:40:54 PST
Firefox supports btoa() and atob() functions within workers, which do the same thing as window.btoa() and window.atob() in the DOM. It would be great if these were available in WebKit too.
Comment 1 Alexey Proskuryakov 2011-03-03 14:38:58 PST
Could you please provide some use cases for using these functions in workers?
Comment 2 Jon Leighton 2011-03-03 15:07:18 PST
In a project I was working on I was downloading image data via XHR in a Web Worker and then encoding it into a data: URI. (I say 'was' because I have since stopped doing it in a worker, for separate reasons, but there you go...) I could imagine you might have, for example, a web-based email client which might want to encode a multipart message before sending it, all the background in a worker.
Comment 3 Eric 2012-08-17 15:33:22 PDT
My use case is similar. I'm using GIFEncoder (https://github.com/antimatter15/jsgif/blob/master/GIFEncoder.js), in a worker to produce a data URL from of the encoded gif. GIFEncoder implements it's own encode64() method: https://github.com/antimatter15/jsgif/blob/master/Demos/b64.js
Comment 4 popecode 2013-09-23 21:15:31 PDT
I wrote a frame buffer to handle image downloads from a worker thread. For my application, this is necessary as the main thread is handling a video and an animation and performance is critical. To use the downloaded images in the browser, I first have to convert them via btoa(). Using firefox, I can perform this conversion before passing the data to the main thread. Since chrome does not allow this, Firefox runs significantly faster than Chrome in my case.
Comment 5 Dmitry Chestnykh 2014-12-13 06:13:57 PST
Is there any progress on this? I use atob/btoa for base64 encoding in TweetNaCl-js instead of implementing my own routines, and I'd like them to be available from web workers. FIY, both Firefox and Chrome have them. Thanks!
Comment 6 Mathias Bynens 2014-12-13 09:23:06 PST
@Dmitry, as a workaround you can use a fully `btoa`/`atob`-compatible polyfill like https://github.com/mathiasbynens/base64.