Search code examples
webassemblyblazor

Is there a way in Blazor to reverse map wasm-function(#) back to the c# method?


I am running a Blazor page on Chrome and I see from the Chrome profiler that it is spending a lot of time in the code wasm-function(633). Is there any way for me to tell what c# code this corresponds to?

I want to improve the performance of the page and it would help to know what is causing the slow performance before changing any code.

I know that Blazor performance is not good compared to javascript etc., but I also have seen with limited experiments that some C# techniques perform better than others. I was just looking for a data-driven way to find where my slow points are.


Solution

  • You can use WasmEmitSymbolMap property which allows to generates a dotnet.js.symbols file during compilation where you will find C# method to which wasm-function(633) corresponds to.

    Another way is to use WasmNativeStrip property. By setting it false you will have C# method names not stripped. Please note that it can be only used in AOT compiled mode and it will increase dotnet.wasm size significantly.

    enter image description here

    <PropertyGroup>
      ...
      <WasmEmitSymbolMap>true</WasmEmitSymbolMap>
      <WasmNativeStrip>false</WasmNativeStrip>
      ...
    </PropertyGroup>
    

    You can find full list of properties here - https://github.com/dotnet/runtime/blob/main/src/mono/wasm/build/WasmApp.targets