[RuntimeError: unreachable] Retrieving from async function in C++

75 views
Skip to first unread message

fidel espanto

unread,
Jul 3, 2024, 1:46:42 AM7/3/24
to emscripten-discuss
I'm trying to call an async function, 'isConfigSupported' from WebCodecs API.

Here is what I did in C++,
val VideoDecoder = val::global("VideoDecoder");
   ConfigCodec* config = new ConfigCodec(); // some struct
   config->codec = "vp8";
   config->codedWidth = 640;
   config->codedHeight = 480;

   val result = VideoDecoder.call<val>("isConfigSupported", config).await();
   
   if (result["supported"].as<bool>()) {
      EM_ASM(
         console.log("Codec is supported");
      );
   } else {
      EM_ASM(
         console.error("Codec is not supported");
      );
   }

I have compiled emcc with this additional option, '-O3 -sASYNCIFY' as stated in the documentation.

The result is 'Codec is supported', however, I get an error in the console logs,
wasmapi.wasm:0x1e79f Uncaught (in promise) RuntimeError: unreachable
    at wasmapi.wasm:0x1e79f
    at wasmapi.wasm:0x1ca34
    at wasmapi.wasm:0x118be
    at ret.<computed> (wasmapi.js:1:87071)
    at Object.doRewind (wasmapi.js:1:88672)
    at wasmapi.js:1:89246


Did I miss something? What does this error mean?

Sam Clegg

unread,
Jul 3, 2024, 12:00:34 PM7/3/24
to emscripte...@googlegroups.com
If you build with `-g` (or just `--profiling-funcs`) when you should see symbol names in your backtrace which might help you figure out what is going on.  You might also want to drop the `-O3` when debugging too.

BTW, we have `emscripten_console_log` and `emscripten_console_error` functions so you shouldn't need to write EM_ASM blocks just to write to the console.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/667e2e81-38ff-4c2e-a930-8cb76e1cffebn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages