-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add mechanism to read / write from WebAssembly memory #13
Comments
@kettle11 I have no idea if this will be helpful to you, but I was experimenting with making wasm-bindgen work with Tangle. Here is what I have so far. It's a very basic "game" made in Rust with Bevy. I've gotten it to the point where the first client can start up and run just fine. When you open a second connection, the first client sees the connection and receives it fine, but the second client never synchronizes, and then throws a ton of
I forked tangle and added it as a submodule of that repo as well. Here is the commit with the changes I made so far, none of which are probably actually useful. In |
@ianjsikes Nice hacking! Sorry it didn't work. I skimmed your code and I've been thinking about how to potentially get it working. The problem is that Tangle attempts to isolate the Wasm from any changes that could desync the Wasm and Tangle has no ability to synchronize the JavaScript side of things. That's why Tangle prevents imports from returning a value: they could just return a random number that always causes a desync. But I'm thinking now that's a design mistake on Tangle's part. Tangle shouldn't prevent all desyncs, it should instead detect all desyncs and throw an error when one occurs. That way it's possible to try to write Javascript that stays in sync and lets Tangle be used in a more natural way. The other thing to figure out is how to make There are plenty of other ways to store state in a browser but this should handle the most basic of |
Right now a big missing feature in Tangle is the ability to pass in large data or read data from Tangle.
Libraries like
wasm-bindgen
directly write / read Wasm memory like thisnew Uint8Array(wasm.memory.buffer)
but unfortunately Tangle can't polyfill that directly without creating desyncs.Tangle should expose an alternative way of reading / writing to Wasm memory in bulk.
I wonder if Tangle could have an optional mode that replaces
WebAssembly.instantiate
completely withTangle.instantiate
andnew Uint8Array
with something that checks if the value passed in is a special Tangle object?This could make using Tangle with something like
wasm-bindgen
as easy as importing the library.The text was updated successfully, but these errors were encountered: