debuggingwebglwebassemblyunity-webgl

How to translate unreadable WebGL unity WASM stacktrace?


I ran into a debugging issue in a prod environment with Unity Unity 2022.1.24f1 and WebGL. When an exception occurs, I get an unreadable stacktrace. Something like this:

Invoking error handler due to
RuntimeError: unreachable
at wasm://wasm/0785b666:wasm-function[985]:0x98818
    at wasm://wasm/0785b666:wasm-function[544]:0x89330
    at wasm://wasm/0785b666:wasm-function[8670]:0x24dccf
    at wasm://wasm/0785b666:wasm-function[1922]:0xbf4e5
    at wasm://wasm/0785b666:wasm-function[28368]:0x812a8b
    at wasm://wasm/0785b666:wasm-function[86902]:0x14c5d3c
    at wasm://wasm/0785b666:wasm-function[557]:0x898ed
    at wasm://wasm/0785b666:wasm-function[77488]:0x1326327
    at wasm://wasm/0785b666:wasm-function[5230]:0x171c41
    at wasm://wasm/0785b666:wasm-function[10658]:0x2feb0d
    at wasm://wasm/0785b666:wasm-function[104320]:0x178c493
    at invoke_iiii (blob:http://localhost:8080/eef1af57-52ea-407d-b414-b8a770143494:3:408461)
    at wasm://wasm/0785b666:wasm-function[2104]:0xc4fc3
    at wasm://wasm/0785b666:wasm-function[24046]:0x7aace3
    at wasm://wasm/0785b666:wasm-function[990]:0x989d5
    at wasm://wasm/0785b666:wasm-function[21506]:0x561c30
    at wasm://wasm/0785b666:wasm-function[51389]:0xd496a6
    at wasm://wasm/0785b666:wasm-function[109425]:0x18f3801
    at wasm://wasm/0785b666:wasm-function[108044]:0x1853d4c
    at wasm://wasm/0785b666:wasm-function[23913]:0x79ec70
    at wasm://wasm/0785b666:wasm-function[23913]:0x79ece1
    at wasm://wasm/0785b666:wasm-function[21361]:0x554206
    at wasm://wasm/0785b666:wasm-function[104316]:0x178c45d
    at browserIterationFunc (blob:http://localhost:8080/eef1af57-52ea-407d-b414-b8a770143494:3:229388)
    at callUserCallback (blob:http://localhost:8080/eef1af57-52ea-407d-b414-b8a770143494:3:182585)
    at Object.runIter (blob:http://localhost:8080/eef1af57-52ea-407d-b414-b8a770143494:3:183845)
    at Browser_mainLoop_runner (blob:http://localhost:8080/eef1af57-52ea-407d-b414-b8a770143494:3:182120)

I can't enable debug symbols mode for prod environment, is there any algorithm to translate this stack trace to real method names?

I found out, that Library\Bee\artifacts\WebGL\il2cppOutput\cpp\Symbols\MethodMap.tsv file has all method names from my app, but I didn't found any relations between those method names/their serial number and numbers in stacktrace.


Solution

  • MethodMap.tsv contains the relationship between c# and c++ functions. This is the first stage of compiling to WASM. The second step creates in build directory a file .symbols.json (for Unity 2021 and newer, in older versions it has a different name). It contains the links between c++ and wasm functions. But to get this file, you need to set "Debug symbols" in "Publishing settings" to "External" value.