jvilk / BrowserFS

BrowserFS is an in-browser filesystem that emulates the Node JS filesystem API and supports storing and retrieving files from various backends.
Other
3.07k stars 217 forks source link

Question: HTML5FS via WorkerFS mounted in EMScripten via AsyncMirror #199

Closed tuzcsaba closed 7 years ago

tuzcsaba commented 7 years ago

Hi.

First of all, Thank you for this marvelous FS library. It already feels that it'll be invaluable in our efforts.

I'd like to ask if the scenario shown above, is supposed to work at this point, or is it something out of the scope of the above backends? When reading https://jvilk.com/browserfs/1.4.1/classes/_backend_workerfs_.workerfs.html I encountered the sentence: "Note that synchronous operations are not permitted on the WorkerFS, regardless of the configuration option of the remote FS."

I was thinking, that if I configure up a BrowserFS instance in the WebWorker, which uses AsyncMirror and WorkerFS as the 'async' backend, and configure a BrowserFS instance on the main thread with HTML5FS, then link them up, it'll work, but I'm having issues, and I'd like to rule out the possibility that I'm trying to achieve something which is not yet supposed to work.

Much appreciated.

jvilk commented 7 years ago

Sorry for the delay! I almost missed this question.

It should work with AsyncMirror, but note that AsyncMirror assumes that the backend does not change independent of the mirror. So if you write to HTML5FS from the main window, the worker will not see it. The worker will only see the state of HTML5FS at the time at which AsyncMirror mirrored it.

The main window should be able to read the worker's changes to HTML5FS via HTML5FS, though. If the main window itself is using AsyncMirror on HTML5FS, it will not see any worker changes after the point at which its AsyncMirror mirrored HTML5FS.

Does that make sense?

csabatuz commented 7 years ago

Thank you for your reply, much appreciated.

Yes, it makes sense, and consistent with my own findings since I've asked the question. The HTML5FS backend is only accessed via the Mirror, so we didn't run into the limitation you mentioned, but good to know.

It turned out that our problem indeed was not related to the AsyncMirror itself, but other aspects of our code.

Thank you again, and as far as I'm concerned this question is ANSWERED.