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
I am developing a WASM application that allows a user to "upload" a file which must then be processed by a worker. I must pass the file to the worker via messages. yew_agent requires that messages implement Serialize/Deserialize - however, for relatively small (1 MB) files, you'll get a SerializeBufferFull error.
We don't have to serialize/deserialize anyway - it's unnecessary work. Web workers support "transferables" - variable hand-offs to workers that are done by reference, that then become inaccessible to the calling program. They are essentially Rust ownership moves - they're zero-copy. Fantastic for binary data.
This is not supported by our upstream @ gloo. Please see rustwasm/gloo#240.
A data import function for a budgeting web application. The worker converts a zip archive containing CSV data into the application's native data format, and then sends that off via protocol buffers to the server.
The cost of the initial data processing client-side is small - not so small it won't freeze the browser if we don't use a web worker, but not so large that they'll be annoyed waiting for the worker to finish.
Leveraging the user's compute drastically reduces the need for server side compute. Client/server communication can be restricted to protocol buffers - no file handling, etc. Clean!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am developing a WASM application that allows a user to "upload" a file which must then be processed by a worker. I must pass the file to the worker via messages.
yew_agent
requires that messages implement Serialize/Deserialize - however, for relatively small (1 MB) files, you'll get aSerializeBufferFull
error.We don't have to serialize/deserialize anyway - it's unnecessary work. Web workers support "transferables" - variable hand-offs to workers that are done by reference, that then become inaccessible to the calling program. They are essentially Rust ownership moves - they're zero-copy. Fantastic for binary data.
This is not supported by our upstream @
gloo
. Please see rustwasm/gloo#240.This is however supported @
web_sys
: post_message_with_transferUse Case Example
A data import function for a budgeting web application. The worker converts a zip archive containing CSV data into the application's native data format, and then sends that off via protocol buffers to the server.
The cost of the initial data processing client-side is small - not so small it won't freeze the browser if we don't use a web worker, but not so large that they'll be annoyed waiting for the worker to finish.
Leveraging the user's compute drastically reduces the need for server side compute. Client/server communication can be restricted to protocol buffers - no file handling, etc. Clean!
Beta Was this translation helpful? Give feedback.
All reactions