runtime: [browser] Enabling WasmStripILAfterAOT breaks app with 'NIY encountered' and results in larger build size

Description

I’ve tried enabling recently added <WasmStripILAfterAOT> (https://github.com/dotnet/core/issues/8439#issuecomment-1684085249), but it breaks the application and results in slightly larger build size (5.05MB vs 5.06MB).

Reproduction Steps

  1. Clone https://github.com/Elringus/DotNetJS/tree/feat/revamp/Samples/App
  2. Under App directory run npm install
  3. Run dotnet publish backend
  4. Run npm run dev
  5. Open browser with the reported dev server address
  6. Observe the app is working and check binaries size under App/public/bin (5.05MB on my end)
  7. Add <WasmStripILAfterAOT>true</WasmStripILAfterAOT> to App/backend/Backend.WASM/Backend.WASM.csproj properties
  8. Run dotnet publish backend to re-build the solution
  9. Run dev server and check the app and binaries size again

Expected behavior

App works as before and binaries size is at least not larger than before.

Actual behavior

Binaries size is slightly larger (5.06MB on my end) and app crashes with the following log:

Browser console log
MONO interpreter: NIY encountered in method .ctor backend.js:21:18473
ht@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:13344
El<@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:177768
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[14918]:0x338c58
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[12244]:0x284015
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[12168]:0x280bb2
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[12172]:0x280cd5
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[12175]:0x280d3e
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11596]:0x250ae1
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11664]:0x260823
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11669]:0x2609de
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[7663]:0x166705
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[242]:0x16789
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[241]:0x166c9
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[240]:0x1665a
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[128]:0x106a2
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11156]:0x231c55
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11706]:0x2618bd
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.Module:wasm-function[1]:0x56
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11604]:0x25e3e4
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11596]:0x251b4f
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11630]:0x25f1dd
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[14228]:0x3079a4
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13623]:0x2dee64
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13622]:0x2dedef
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13106]:0x2bc4b6
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[5387]:0xf5900
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[5386]:0xf5885
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[6898]:0x13f939
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[5395]:0xf6892
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[5392]:0xf61bc
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[5493]:0xfbbab
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[5374]:0xf48d4
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[7041]:0x1446ca
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11156]:0x231c55
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11706]:0x2618bd
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.Module:wasm-function[1]:0x56
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11604]:0x25e3e4
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11596]:0x251b4f
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11630]:0x25f1dd
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[14228]:0x3079a4
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13623]:0x2dee64
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13629]:0x2df704
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13653]:0x2e1da6
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[14908]:0x33523a
createDotnetRuntime/Module._mono_wasm_invoke_method_bound@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:21:99186
Sr@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:36377
jl/e.onRuntimeInitialized/l$1.javaScriptExports.call_entry_point@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:210505
$c@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:138300
boot@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:234:51
async*bootBackend@http://localhost:5173/src/boot.ts?t=1695055130977:7:19
async*@http://localhost:5173/src/main.tsx?t=1695055130977:8:1
backend.js:3:177762
ht@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:13344
El<@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:177768
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[14918]:0x338c58
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[12244]:0x284015
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[12168]:0x280bb2
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[12172]:0x280cd5
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[12174]:0x280d18
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[12173]:0x280ceb
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11604]:0x25e669
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11596]:0x251b4f
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11630]:0x25f1dd
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[14228]:0x3079a4
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13623]:0x2dee64
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13622]:0x2dedef
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13106]:0x2bc4b6
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[5387]:0xf5900
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[5386]:0xf5885
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[6898]:0x13f939
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[5395]:0xf6892
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[5392]:0xf61bc
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[5493]:0xfbbab
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[5374]:0xf48d4
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[7041]:0x1446ca
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11156]:0x231c55
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11706]:0x2618bd
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.Module:wasm-function[1]:0x56
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11604]:0x25e3e4
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11596]:0x251b4f
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11630]:0x25f1dd
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[14228]:0x3079a4
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13623]:0x2dee64
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13629]:0x2df704
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13653]:0x2e1da6
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[14908]:0x33523a
createDotnetRuntime/Module._mono_wasm_invoke_method_bound@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:21:99186
Sr@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:36377
jl/e.onRuntimeInitialized/l$1.javaScriptExports.call_entry_point@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:210505
$c@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:138300
boot@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:234:51
async*bootBackend@http://localhost:5173/src/boot.ts?t=1695055130977:7:19
async*@http://localhost:5173/src/main.tsx?t=1695055130977:8:1
backend.js:3:177762
ht@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:13344
El<@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:177768
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[14918]:0x338c58
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[12244]:0x284015
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[12168]:0x280bb2
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[12172]:0x280cd5
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[12174]:0x280d18
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[12173]:0x280ceb
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11604]:0x25e669
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11596]:0x251b4f
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[11630]:0x25f1dd
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[14228]:0x3079a4
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13623]:0x2dee64
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13629]:0x2df704
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[13653]:0x2e1da6
@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977 line 3 > WebAssembly.instantiate:wasm-function[14908]:0x33523a
createDotnetRuntime/Module._mono_wasm_invoke_method_bound@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:21:99186
Sr@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:36377
jl/e.onRuntimeInitialized/l$1.javaScriptExports.call_entry_point@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:210505
$c@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:3:138300
boot@http://localhost:5173/backend/Backend.WASM/bin/backend/backend.js?t=1695055130977:234:51
async*bootBackend@http://localhost:5173/src/boot.ts?t=1695055130977:7:19
async*@http://localhost:5173/src/main.tsx?t=1695055130977:8:1
backend.js:3:177762
Uncaught (in promise) 
Object { name: "ExitStatus", message: "Program terminated with exit(1)", status: 1 }

Regression?

No.

Known Workarounds

None.

Configuration

.NET 8 RC1 Windows 10 x64

Other information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 17 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@fanyang-mono gotcha thank you. Stripping IL isn’t critical now that I can get AOT working without it.

The fix was merged recently. Unfortunately, it didn’t make it to the .NET8 GA. It will for sure be in .NET9. It might be able to be released as part of .NET8 service1. But I can’t guarantee that right now.

Sorry about the delay. The fix has been shipped as part of .NET9 Preview1. Please download the latest .NET from https://dotnet.microsoft.com/en-us/download/dotnet/9.0 to see if you issue has been resolved.