-
Notifications
You must be signed in to change notification settings - Fork 258
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
IndexedDB support for wasm/browser environments #414
Conversation
Yeah the browser might be a special place where everybody just wants to use the indexeddb store, I don't think anyone will want to run bots/bridges in the browser.
Would use
I don't think so, no. The memory store is there for two reasons:
Number 1 is largely going away and people won't use number 2. in a browser.
We could put the It was always the intention to have only the memory store be part of the SDK crates but due to time constraints shortcuts were taken.
This is a bit of a tricky one and we'll likely need to measure the performance impact. It was also skipped due to time constraints and some things are deliberately left unencrypted. For example, the user ids that are part of a room, those need to be fetched every time a message is sent. We likely could keep the performance good enough using some smarter caching. A scheme that avoid leaking the keys I had in mind is this:
The salt, of course, will be used for the key hashing. That all being said, thanks for working on this. |
Re. feature flag, I think the question isn't "does somebody want to run a bridge / bot in a browser", it's "does somebody want to use the SDK with state storage in non-browser wasm environment". I think it's definitely realistic somebody would want that so keeping this behind a feature flag seems like a good idea. |
That's a fair point, I'm a bit biased since I would just use it natively in that case, but someone is bound to be interested in the sandboxing features a WASM environment provides. |
Re feature-flag: yeah, @jplatte, that was my thinking. Especially since more and more non-browser platforms offer some form of WASM support, I don't think we can assume one by the other. Like node has wasm support and that won't have indexeddb support... Keeping it as a feature-flag than. Thanks for the input! In light of this way of thinking of it, I'd leave the memory store as an option for wasm32 non-indexeddb environments (like nodejs), too...
while I agree that
This, as a well as
I'll leave for another PR another time. For simplicity I'll try to get the indexeddb to feature parity with sled store first and then we can investigate these further. |
👍🏼 from me for |
nodejs would probably use neon to create bindings, this way they get access to native threads. I was thinking more of something like wasmer, which provides an embedable WASM runtime.
The difference is that those methods send out requests. I prefer the non-async constructor because a client might want to create the object in the UI thread which might not be a Tokio thread. Then again a more feature-full client will certainly use |
@ara4n yes, I was messing with that in the CI as well. It appears this only works with Node 14 and webpack5 reliably because of various factors (the long-name-stack-size-problem as well as the |
turns out that the magic to make this work for me is:
ignoreWarnings: [
(warning) =>
warning.message ===
"Critical dependency: the request of a dependency is an expression",
], Alternatively, one can manually snip out the unneeded code with: for i in _ZN3olm7Session8describeEPcm olm_session_describe aes_encrypt_ccm aes_decrypt_ccm
do
wasm-snip index_bg.wasm -o index_bg_fixed.wasm $i
mv index_bg_fixed.wasm index_bg.wasm
done |
note: you can get wasm-snip here. |
Updated to latest main, including the remove-room-feature added. The only test failing is marked as continue-on-error to remind us that default wasm-crypto doesn't work (though this isn't blocking merges), while there's a test within an environment (node14, emcc2.0) that is working. should be good to merge now. |
# hence the tests | ||
name: ${{ matrix.name }} WASM test | ||
runs-on: ubuntu-latest | ||
continue-on-error: ${{ matrix.experimental }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will still turn our CI state into a ❌, oh well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, github actions don't have a proper ignore-failure switch ... what I could offer is to comment the specific test (which would also mean we don't waste these resources every time) until we have it fixed up ...?!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sounds good.
Hi,
this PR attempts to implement permanent storage solutions on webbrowser environments using the browser own
IndexedDB
.Current progress:
implement backup_v1MilliSecondsSinceUnixEpoch
-support for webimprove security (currently keys leak information)Things I'd very much like an opinion/input on:
new
to instantiate, but for indexeddb it must beasync
. Right now, this goes for a feature-specific-approach, meaning the API is async for the browser but sync otherwise. Do we want to streamline the API and make it async both cases?