uberroot4
uberroot4

Reputation: 53

Blocking JsFuture in Web Worker

I am currently working on bringing a rust crate with I/O into the browser, where I am using the relatively new "File System API" and WebAssembly. I am struggling currently on the part of either duplicating existing sync code with an async version, as I cannot tell rust dynamically it should only be async with the wasm32-unknown-unknown target.

Beeing at this point, the idea of moving all the blocking parts into a Web Worker was my idea so far. While I am using the wasm_thread library, I can use the futures::executor::block_on(...) method for blocking stuff (e.g. sleep). Where I am pretty much stuck right now is how to block a JsFuture from the web-sys crate.

I can access the storage of the page via

web_sys::js_sys::global()
    .dyn_into::<web_sys::DedicatedWorkerGlobalScope>()
    .expect("worker global scope is not available")
    .navigator()
    .storage()

where I get the storage StorageManager object, however when I later call JsFuture::from(storage.estimate().unwrap()).await then it blocks forever. Is there any way how I can get around this problem in any way?

Thanks in advance.

Upvotes: 0

Views: 26

Answers (0)

Related Questions