Conversation
|
I am assuming that the CI test I added is not executed because of some security settings on the repo. |
|
Now that we decided that #76 should not be merged until To address any potential concerns (considering @madsmtm didn't want to use custom imports but wait for |
|
CI fails because the new version of |
notgull
left a comment
There was a problem hiding this comment.
If that's the blessed way of doing it, then I suppose everything else looks good enough.
|
Try rebasing on top of the new |
|
Done! |
3a21c8f to
f3e1435
Compare
|
Rebased after #65. |
|
This works on my machine under |
* On MacOS, the contents scale is updated when set_buffer() is called, to adapt when the window is on a new screen (#68). * **Breaking:** Split the `GraphicsContext` type into `Context` and `Surface` (#64). * On Web, cache the document in the `Context` type (#66). * **Breaking:** Introduce a new "owned buffer" for no-copy presentation (#65). * Enable support for multi-threaded WASM (#77). * Fix buffer resizing on X11 (#69). * Add a set of functions for handling buffer damage (#99). * Add a `fetch()` function for getting the window contents (#104). * Bump MSRV to 1.64 (#81).
When I tried actually using Softbuffer with #76 in a multi-threaded Wasm environment using
transferControlToOffscreen()I found that Softbuffer actually fails onImageData::new_with_u8_clamped_array(wasm_bindgen::Clamped(&bitmap), width.into()).Apparently it is not allowed to create a
ImageDatafrom aSharedArrayBuffer. I only found a couple of Stackoverflow issues facing this (#1, #2) but no actual documentation on MDN or WHATWG.This fixes it by copying the data to a
Uint8Arrayfirst and then creating theImageDatafrom that. Which is an extra copy that can't be avoided when using multi-threaded Wasm. I hid it all behind#[cfg(target_feature = "atomics")]to make sure not to affect people not needing this.This can be further optimized by keeping theUint8Arrayand not having to recreate it from scratch again every time. I thought maybe we should wait for #65 before that, happy to add it now if desired.This could be further optimized if we add an additional function for Web that uses a copy API instead of the currently owned buffer one.
To make this happen I had to do an import by hand because
web-sysdoesn't actually provide the constructors we need forImageData.I also added
-Ctarget-feature=+atomicsto the CI separately to the regular Wasm build.See the
wasm-bindgendocumentation for more information on multi-threaded Wasm.This can be run locally with
RUSTFLAGS=-Ctarget-feature=+atomics,+bulk-memory cargo +nightly run-wasm --example winit -Zbuild-std=panic_abort,std.