You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Revert "Remove uses of future_to_promise in machine.rs (#193)"
This reverts commit eea167e.
Unfortunately, most of this change is unsound.
With an explicit `future_to_promise`, we are able to clone the underlying
`matrix_sdk_crypto::OlmMachine` (and its constituent `Arc`) *before* returning
a Promise to the javascript, meaning even if the
wrapping `matrix_sdk_crypto_wasm::OlmMachine` is dropped, the underlying `OlmMachine`
hangs around.
An `async` function does nothing until it is polled, meaning there is plenty of
time for the Javascript to get hold of the Promise and drop its reference to
the OlmMachine, before we try and clone it. I think it's fine if we let the
Javascript finalizer manage cleanup; but we deliberately drop OlmMachine, in an
attempt to get it to drop its indexeddb conneciton.
I'd go so far as to say that wasm-bindgen's support for `#[wasm_bindgen]` on
`async fn` (rustwasm/wasm-bindgen#1754) is
fundamentally incompatible with an explicit call to `.free()` (or, in this
case, `.close()`, which is the same thing.)
Probably, the correct fix here is to improve the way we handle indexeddb
connections (cf element-hq/element-web#25779), at
which point we can remove the `.close()`/`.free()` calls, and reintroduce
this. For now though, I'm going to back it out.
0 commit comments