In Firefox, the following code works correctly when run in the main browser thread as normal--
var fr = new FileReader();
..but when run from a web worker, the following error is thrown:
FileReader is not defined
The same code works fine in Chrome and Safari.
Any suggestions for supporting FileReader in a web worker in Firefox?
In Firefox, the following code works correctly when run in the main browser thread as normal--
var fr = new FileReader();
..but when run from a web worker, the following error is thrown:
FileReader is not defined
The same code works fine in Chrome and Safari.
Any suggestions for supporting FileReader in a web worker in Firefox?
Share Improve this question asked Mar 30, 2014 at 7:35 Stu BlairStu Blair 1,3431 gold badge16 silver badges24 bronze badges 3-
1
Did you try using
FileReaderSync
instead ofFileReader
? – adeneo Commented Mar 30, 2014 at 8:08 - @adeneo, yes, that does appear to be supported. Does FF not support asynchronous file reading? Are chrome/safari actually operating synchronously when I use FileReader? – Stu Blair Commented Mar 30, 2014 at 9:14
-
1
Well,
FileReaderSync
is only supported in workers, as you generally don't need asynchronous file reading in a worker, but I'm not sure why Firefox doesn't support the regular asyncFileReader
in worker, I thought they did, but at least they support the synchronous version, so you can just use that as you don't need async behaviour in a worker anyway. – adeneo Commented Mar 30, 2014 at 9:17
1 Answer
Reset to default 7As adeneo pointed out, it seems that FileReader
is simply not supported by Firefox in Web Workers. I was able to use FileReaderSync
instead to acplish what I needed.