Web worker: NotFoundError when I try to read a file created in the main thread

In Chrome 32, I've got an JS app where I write raw images from a canvas to a file and I want to close the file and open it for processing in a worker. I pass the file name to the worker and I can see that it's found and opened but as soon as I try to read it I get a DOM exception (NotFoundError).

// In my worker:
fs = self.requestFileSystemSync(self.PERSISTENT, quota);
var f = fs.root.getFile(rawFileName, {create: false});  // this works, f is valid
var reader = new FileReaderSync();
// At this point, 'reader' looks ok
rawFramesArrayBuffer = reader.readAsArrayBuffer(f); // My exception is thrown here.
log("Opened " + rawFileName + " for reading.");

In my main thread, I've tried setting my File and FileWriter to undefined to ensure the file is closed (I can't see a method for doing this), but it doesn't help. In any event, the spec says that a NotReadableError should be thrown if the file is locked, but I don't see this.

If I step through the code, everything pauses for about 5 seconds when I step over the readAsArrayBuffer line and then the NotFoundError is thrown.

If I create a DirectoryReader and enumerate all the files, I can see that my file exists.

Answers


You may want to pass the images to the worker rather than saving them and having the worker open a file.

Here is a page with sample code

http://kinderas.blogspot.com/2011/06/html-5-web-workers-and-image-processing.html

But it does depend on how big your image is.

I found this interesting but haven't tried to do processing from the computer camera so it may help you out.

http://blog.aviary.com/posts/live-image-processing-with-getusermedia-and-web-workers


I needed to access the file via the FileEntry:

rawFramesArrayBuffer = reader.readAsArrayBuffer(f.file());

Need Your Help

Laravel 5.1: Guzzle 6 return response is not working

php laravel-5.1 guzzle6

I'm using Gazzle 6 with Laravel 5.1 and I'm having a strange behaviour returning my data from the APIs I'm using. This is my code:

Getting HttpHostConnection refused error while connecting to Amazon S3

java amazon-web-services amazon-s3

I am using java code to connect to amazon s3. I am getting HttpHostConnection refused error every time I try to connect to S3. On S3 I have only one bucket with all permissions to me as a owner. Wh...