IE support added; Basic error reporting for workers

This commit is contained in:
Christoph Oberhofer
2015-08-29 21:42:52 +02:00
parent edf813a20d
commit adaa2b3e42
3 changed files with 25 additions and 7 deletions
+6 -1
View File
@@ -332,10 +332,10 @@ function(InputStream,
blobURL = generateWorkerBlob();
workerThread.worker = new Worker(blobURL);
URL.revokeObjectURL(blobURL);
workerThread.worker.onmessage = function(e) {
if (e.data.event === 'initialized') {
URL.revokeObjectURL(blobURL);
workerThread.busy = false;
workerThread.imageData = new Uint8Array(e.data.imageData);
console.log("Worker initialized");
@@ -344,6 +344,8 @@ function(InputStream,
workerThread.imageData = new Uint8Array(e.data.imageData);
workerThread.busy = false;
publishResult(e.data.result, workerThread.imageData);
} else if (e.data.event === 'error') {
console.log("Worker error: " + e.data.message);
}
};
@@ -358,10 +360,13 @@ function(InputStream,
function workerInterface(factory) {
if (factory) {
/* jshint ignore:start */
var Quagga = factory();
if (!Quagga) {
self.postMessage({'event': 'error', message: 'Quagga could not be created'});
return;
}
/* jshint ignore:end */
}
/* jshint ignore:start */
var imageWrapper;