protobuf-javascript icon indicating copy to clipboard operation
protobuf-javascript copied to clipboard

WebAssembly module for protobuf encoding / decoding

Open chicoxyzzy opened this issue 8 years ago • 8 comments

Are there any plans on wasm implementation of protobufs?

chicoxyzzy avatar Oct 03 '17 21:10 chicoxyzzy

There's no such plan yet. Would simply use the C++ code work for wasm, or it is more about bridging the parsing/serialization with the native JS message types?

liujisi avatar Oct 06 '17 20:10 liujisi

Yes, I mean bridging with JS

chicoxyzzy avatar Oct 06 '17 22:10 chicoxyzzy

No plan yet. But will investigate.

TeBoring avatar Jun 30 '18 00:06 TeBoring

Ideally, we could get a WASM module generated directly out of the definitions in a .proto file, with exported functions to unmarshall a Uint8Array containing a PB message into a JS object, or pass in a JS object to be marshalled into a Uint8Array.

dchenk avatar Aug 15 '18 20:08 dchenk

@dchenk How to create JS objects in web assembly? Is that efficient or possible? I have looked a bit into web assembly recently but I don't remember seeing any C API that can be used to construct JS objects directly in web assembly. If every manipulation of a JS object requires crossing the wasm-js boundary, creating JS objects this way in web assembly can be very inefficient.

xfxyjwf avatar Aug 16 '18 06:08 xfxyjwf

WebAssembly doesn't have any structures besides number types. It has proposal for anyref though.

chicoxyzzy avatar Aug 16 '18 06:08 chicoxyzzy

This basically works with C++ protos and communicate via sending typed arrays back and forth.

We should document how to do this.

dibenede avatar Sep 30 '22 22:09 dibenede

I am also interested to know which implementation is faster. protobuf.js, this repo, or the WASM build.

aminya avatar Mar 20 '24 18:03 aminya