em_asm blocks interacting with json.parse somehow?

19 views
Skip to first unread message

r0l...@freemail.hu

unread,
Oct 5, 2020, 1:29:07 PM10/5/20
to emscripten-discuss

Hi All,

I'm experimenting with a relatively tricky scenario:


or its github source:


It works fine with normal html+js pages but I decided to do the same with a qt/qml app compiled as webassembly. Seems to work till the point when the EM_ASM block gets called where the global (window) onmessage function gets registered:

EM_ASM(
  var port;
  onmessage=function(e){
    port=e.port[0]
  }
);

That onmessage gets called from java via webview postWebMessage(...) fine but it seems that the parameter that is passed into postWebMessage(...) goes through a JSON.parse and what I get in the incoming 'e' event is just an:

{isTrusted: true}

So the function fails with not being able to access property 0 of undefined.

Does anyone know why the event object does not arrive as expected?

Thanks&regards,
r0ller

r0l...@freemail.hu

unread,
Oct 5, 2020, 5:40:20 PM10/5/20
to emscripten-discuss
Headbang: I had a typo in all the magic as e.ports[0] is the right way to access the port.

Sorry for the noise...
Reply all
Reply to author
Forward
0 new messages