antimatter15 / whammy

A real time javascript webm encoder based on a canvas hack
http://antimatter15.github.com/whammy/clock.html
MIT License
1.02k stars 182 forks source link

iOS, Phonegap: Cannot find function atob. Works on Android #41

Open AaronLlanos opened 8 years ago

AaronLlanos commented 8 years ago

Hello,

I am building a project using this tool which records a canvas. I import the Whammy script along with the CanvasRecorder script as specified here. The problem I am having is that whenever I call the function recorder.stop((blob) => {}), it uses the whammy library to convert each webP to base 64 and combine it to webM.

It is in this function where the problem occurs:

var webm = new ArrayToWebM(frames.map(function(frame) {
    var webp = parseWebP(parseRIFF(atob(frame.image.slice(23))));
    webp.duration = frame.duration;
    return webp;
}));

WhammyVideo.compile -> processInWebWorker -> whammyInWebWorker -> ArrayToWebM -> parseWebP -> parseRIFF -> atob

As stated above, on android web view through phonegap this works but on iOS it does not. I tried logging window and even tried polyfilling the function with a shim but nothing has worked so far. It seems as though the window variable is lost in the function:

function whammyInWebWorker(frames) {}

Maybe I am just thinking about this incorrectly but I think this library should be working across all devices especially iOS through Phonegap since it is a growing development community.

Best, Aaron

AaronLlanos commented 8 years ago

After further researching this topic, it appears as though the answer above is coming from WebWorker operating on a seperate global scope.

iOS webworkers do not ship with atob defined on them. It may help to perform a check on the atob function within the webworker setup and assign it there if it does not exist. Furthermore, iOS does not setup Canvas Recorder properly to include RIFF or LIST from the decoded value.

AramVave commented 6 years ago

@AaronLlanos could you please provide your solution?