-
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
WASM support #31
WASM support #31
Conversation
Codecov Report
@@ Coverage Diff @@
## master #31 +/- ##
==========================================
- Coverage 75.13% 74.67% -0.46%
==========================================
Files 21 23 +2
Lines 3998 4040 +42
==========================================
+ Hits 3004 3017 +13
- Misses 994 1023 +29
Continue to review full report at Codecov.
|
I renamed the types subproject now to matrix-sdk-common. The locks should go in there, and anything that's shared between the different crates to make wasm work. |
While trying to get encryption to work I hit the roadblock that libolm requires the I've tried to work around that by compiling just Another alternative would be to try to compile against the |
That's a shame, perhaps asking at the wasm-bindgen repo or wasm-pack repo would give us some answers if this will ever be possible. |
Turns out I was wrong. It is possible to compile an archive with emscripten and use it with the |
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.
So I played around with this for a bit and a couple of issues came up:
- While futures-timer does compile under wasm, calling sleep panics.
Instant::now()
from std panics when called.- The example never syncs so it won't send encrypted messages correctly.
- It doesn't seem to be possible to use an event emitter implementation.
I fixed all of those in the wasm-upstream branch. Sleeping has been disabled for now, but we might want to use wasm-timer which uses the tokio timers on non-wasm targets.
The Instant
usage has been replaced with the instant crate which is a drop in replacement. We might consider using wasm-timer
instead of this since it also provides an Instant
replacement.
The example has been modified to be similar to the command bot example. It now receives messages and responds if a message starts with !party
.
I did not investigate what's up with the event emitter but I think that the huge compile time error meant that it's not possible to implement one because of the Send
+ Sync
requirement this trait has. We'll possibly need a non Send
+ Sync
version of it under wasm, as well as for the CryptoStore
trait.
The only remaining issue is that we're depending on git repos again, but that's only required for encryption to work. I think we can remove the git dependencies and not support encryption for now.
If you're fine with this please merge my changes into your branch and remove the git deps.
Thanks for the quick and thorough review. I've made the requested changes and a small fix regarding a missing I've opened an tracking ticket for the remaining issues here: #35 |
Ah ok, since futures-locks is only used for wasm I think I'm going to merge this as is. Btw that one commit message is a bit misleading, encryption does work under wasm if the deps are set to the git repos. |
Removed the misleading comment in the commit message.
Sounds good to me, thanks! |
Allows building an WASM-ready archive with emscripten. This allows e.g. to compile to the `wasm32-unknown-unknown` target with Rust. Related matrix-rust-sdk PR: matrix-org/matrix-rust-sdk#31 Signed-off-by: stoically <stoically@protonmail.com>
This starts support for compiling to the wasm32-unknown-unknown webassembly target.
Try to get tests working as is: Doesn't work because of reliance on either mockito (tcplistener) or filesystemcjson
changeslibolm
changesolm-sys
changesTo run the example in
matrix_sdk/examples/wasm_send_message
src/lib.js