Open calvinmetcalf opened 11 years ago
Thanks, that's some great info! gonna do some experiments with transferable objects now :)
Regarding the worker script path, wouldn't you have the same problem figuring out the path for the worker to call itself? Looking around I also found this but it's not a great solution imo http://stackoverflow.com/questions/2161159/get-script-path
this should do the trick
function getPath(){
var scripts = document.getElementsByTagName("script");
var len = scripts.length;
var i = 0;
while(i<len){
if(/gif(\.min)?\.js/.test(scripts[i].src)){
return scripts[i].src;
}
i++;
}
}
though this is in coffeescript so
getPath = () ->
scripts = document.getElementsByTagName("script")
return script.src for script in scripts when /gif(\.min)?\.js/.test(script.src)
Now the worker is transferring data instead of copying, i'm still copying to the worker since i can not guarantee i wont need it again
you may want to test if it's internet explorer 10 before doing the transferable object, self.UintClampedArray8 might be a good proxy to check for as IE10 doesn't have that either
I actually had some issues in every browser but chrome so now it's only enabled there. Firefox ran without error but the data was corrupted
I'm running in Angular.js and it's unable to load the worker script, since my index.html is in the root so it's looking for /gif.worker.js (while actual .js is in /assets/gif.js/...
Any solution for this? I'm not clear on the typeof document === "undefined" solution above, if you can shed more insight.
The issue is if you have script.js and worker.js if they are both in the root everything is fine but if you move them both into assets then you have to modify the path in script to tell it to lead it from assets.
The typeof document idea is that is you combine the script and worker into one file with checking for document being the switch.
The key here is that the script goes through the script tags in the page to figure out what the path of itself is in order to load itself, likely you either renamed the script, or didn't import it through a script tag (this is based on having zero memory of what gif.js ended up doing I may be way off) On Jun 27, 2014 4:48 PM, "Ben Dean" notifications@github.com wrote:
I'm running in Angular.js and it's unable to load the worker script, since my index.html is in the root so it's looking for /gif.worker.js (while actual .js is in /assets/gif.js/...
Any solution for this? I'm not clear on the typeof document === "undefined" solution above, if you can shed more insight.
— Reply to this email directly or view it on GitHub https://github.com/jnordberg/gif.js/issues/6#issuecomment-47398469.
I've had some experience with workers doing communistjs here are some things I learned:
typeof document === "undefined"
and the script calls itself as the worker script, this also ends up being more portable.