-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] : file-system-access - get file handle in a pthread #14094
Comments
Sounds good to me. Starting with and API that run on the main thread sounds like the way to go. It could come in sync and async flavors (the sync flavor would require ASYNCIFY on the main thread of course). When calling this APIs from a pthread we could then (just as we do for most other web APIs) proxy the calls back to the main thread). In terms of API naming I would suggest a common prefix (e.g. |
What API would be used to post the object? (All I can think of is the initial postMessage during the worker creation, but I assume you don't mean that?) |
I did mean that, but I am noticing it is not Transferable (I was serializing it), so it's a bad idea to postMessage() it, sorry. The API would be provided by emscripten :
|
If no one planned to work on this feature, I would like to submit a PR (after adjustments and in accordance with the feedbacks in this ticket ofc).
In some projects, users may need to interact with the file-system picker to select a file, and make it available for processing in webassembly.
In a multithreaded application, (and if we want to do synchronous reads), we need to have the file handle available in the pthread worker.
There is a POC in the vlc.js application that uses this patch.
I think it would be nice to have a shared handle holding the JS File instance, that is also available on pthread workers.
It could be done with a function in emscripten (triggered by user interaction), that opens a file picker, depending on if we are on chrome or not and sets the fileHandle (Module["fileHandle"]).
The click on ElementSetByUser will in both cases open the file picker. The user will need to add an indication in the UI, we don't need the
<input type="file">
element in chrome.Now we can add Module.fileHandle to the shared objects that can be posted to a pthread worker, and receive it in src/worker.js :
It would be exposed like emscripten_webgl_*()
The user interaction part can be removed when the file system access API will be supported in other browsers.
The next step could be to add functions that synchronously read/seek the file. (instead of this) And also handle directories, and file writes (and when it will be supported by other browsers).
issue to track
The text was updated successfully, but these errors were encountered: