Compiling with Emscripten to Web Assembly

573 views
Skip to first unread message

andro...@gmail.com

unread,
Jan 19, 2018, 6:03:04 AM1/19/18
to grpc.io
Hi,
I'm trying to compile grpc with Emscripten to WebAssembly - trying to get a C++-based grpc client working in the browser.

Does anyone know if getting this working is even feasible and has anyone else tried it? I'm having issues compiling (mostly Protobuf) which I think I'll be able to solve, but I'd like to know if the effort is worth it.

mav...@advancedpwr.com

unread,
Mar 9, 2018, 11:16:28 AM3/9/18
to grpc.io
I just started looking at this today.  Any progress on your end?

Matthew Avery

unread,
Mar 13, 2018, 9:25:53 AM3/13/18
to grpc.io
I did get grpc and protobuf  compiles to WASM but it is not working yet, even after enabling SharedArrayBuffer on my browser.  I'm getting a type exception on the first call to Atomics.store() that is trying to allocate memory for pthread support.

Wenbo Zhu

unread,
Mar 14, 2018, 3:45:47 PM3/14/18
to grpc.io
I worked on grpc/grpc-web, and I don't believe you are able to do any native networking I/O from the browser, but if you have any pointer to suggest otherwise, happy to have a look and assess the feasibility.

Matthew Avery

unread,
Mar 14, 2018, 3:56:51 PM3/14/18
to grpc.io
I was able to compile grpc to asm.js using emscripten and run without errors, but I think you are correct, the client was not able to make a connection from the browser to the grpc server.  I'm not sure what the path forward is yet.  I am going to experiment with a c++ socket and see if webassembly will use websockets.  I saw a post on stackoverflow that suggested this is the case

Wenbo Zhu

unread,
Mar 14, 2018, 4:43:12 PM3/14/18
to Matthew Avery, grpc.io
On Wed, Mar 14, 2018 at 12:56 PM, Matthew Avery <mav...@advancedpwr.com> wrote:
I was able to compile grpc to asm.js using emscripten and run without errors, but I think you are correct, the client was not able to make a connection from the browser to the grpc server.  I'm not sure what the path forward is yet.  I am going to experiment with a c++ socket and see if webassembly will use websockets.  I saw a post on stackoverflow that suggested this is the case
I would guess websocket calls are bridged over JS calls ..(for all the security reasons)
 


On Wednesday, March 14, 2018 at 3:45:47 PM UTC-4, Wenbo Zhu wrote:
I worked on grpc/grpc-web, and I don't believe you are able to do any native networking I/O from the browser, but if you have any pointer to suggest otherwise, happy to have a look and assess the feasibility.


On Tuesday, March 13, 2018 at 6:25:53 AM UTC-7, Matthew Avery wrote:
I did get grpc and protobuf  compiles to WASM but it is not working yet, even after enabling SharedArrayBuffer on my browser.  I'm getting a type exception on the first call to Atomics.store() that is trying to allocate memory for pthread support.

On Friday, March 9, 2018 at 11:16:28 AM UTC-5, Matthew Avery wrote:
I just started looking at this today.  Any progress on your end?

On Friday, January 19, 2018 at 6:03:04 AM UTC-5, andro...@gmail.com wrote:
Hi,
I'm trying to compile grpc with Emscripten to WebAssembly - trying to get a C++-based grpc client working in the browser.

Does anyone know if getting this working is even feasible and has anyone else tried it? I'm having issues compiling (mostly Protobuf) which I think I'll be able to solve, but I'd like to know if the effort is worth it.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/b2a50b3a-fd71-4d75-b77c-8e9a75858fe1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

russell...@bynd.com

unread,
Feb 7, 2019, 9:57:36 AM2/7/19
to grpc.io
Hi, 
I was wondering if anyone managed to get anywhere with this?
I'm looking into utilising gRPC from within a Webassembly C++ module.

Cheers
Russell


On Wednesday, March 14, 2018 at 8:43:12 PM UTC, Wenbo Zhu wrote:
On Wed, Mar 14, 2018 at 12:56 PM, Matthew Avery <mav...@advancedpwr.com> wrote:
I was able to compile grpc to asm.js using emscripten and run without errors, but I think you are correct, the client was not able to make a connection from the browser to the grpc server.  I'm not sure what the path forward is yet.  I am going to experiment with a c++ socket and see if webassembly will use websockets.  I saw a post on stackoverflow that suggested this is the case
I would guess websocket calls are bridged over JS calls ..(for all the security reasons)
 


On Wednesday, March 14, 2018 at 3:45:47 PM UTC-4, Wenbo Zhu wrote:
I worked on grpc/grpc-web, and I don't believe you are able to do any native networking I/O from the browser, but if you have any pointer to suggest otherwise, happy to have a look and assess the feasibility.


On Tuesday, March 13, 2018 at 6:25:53 AM UTC-7, Matthew Avery wrote:
I did get grpc and protobuf  compiles to WASM but it is not working yet, even after enabling SharedArrayBuffer on my browser.  I'm getting a type exception on the first call to Atomics.store() that is trying to allocate memory for pthread support.

On Friday, March 9, 2018 at 11:16:28 AM UTC-5, Matthew Avery wrote:
I just started looking at this today.  Any progress on your end?

On Friday, January 19, 2018 at 6:03:04 AM UTC-5, andro...@gmail.com wrote:
Hi,
I'm trying to compile grpc with Emscripten to WebAssembly - trying to get a C++-based grpc client working in the browser.

Does anyone know if getting this working is even feasible and has anyone else tried it? I'm having issues compiling (mostly Protobuf) which I think I'll be able to solve, but I'd like to know if the effort is worth it.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.

Matthew Avery

unread,
Feb 7, 2019, 10:45:35 AM2/7/19
to grp...@googlegroups.com

I did not get the chance to finish the investigation.  I did however configure a grpc server to change its serialization to json at one point and had some js on web page (not a webassembly module) talking to it.

You received this message because you are subscribed to a topic in the Google Groups "grpc.io" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/grpc-io/rKfPSr2YLqg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to grpc-io+u...@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
Reply all
Reply to author
Forward
0 new messages