In the Wasm 2023 feature set, exception catching is “built in” into the WebAssembly VM codegen behavior.
Before Wasm 2023, WebAssembly specification did not natively support exceptions, so it “loaned” exception support from the outside Javascript VM, implementing exceptions by calling out to throwing JS exceptions.
There were quite a few performance implications to the old behavior, but it did provide this nice feature that it was possible to disable exceptions in a build just by tweaking the JS side code. The compiled Wasm code didn’t need to change, and the same code could be shipped in exceptions enabled vs disabled builds: only a small tweak to the JS code would be needed.
However now with Wasm 2023, since exceptions are a built-in feature to WebAssembly, disabling exceptions means that all the compiled code (including Unity engine and C# runtime) will need to be compiled twice to generate a no-exceptions and an exceptions-enabled builds. This would result in doubling of the number of permutations of the Unity Web engine that would need to be shipped.
We are currently struggling quite a bit with the number of combinations: the engine distributable is at 15 variants, and the upcoming Wasm64 feature set is expected to bring that up to 23 or so; which is a large download footprint for the Web Player Module to have during Editor installation. (the number of variants multiply combinatorially) No-exceptions variants of Wasm2023 would further increase this download size by several hundred MBs.
So this is all to say that it is quite tricky to manage. Originally our hope was that with native Wasm exception handling, the “no exceptions” mode would be a thing of the past, and help to simplify the number of combinations needed here.
I’ve pinged the IL2CPP team to see if they would have a mechanism to allow the C# runtime to abort on thrown exceptions, although not completely sure if such a mechanism exists. For the time being, I recommend still using the non-Wasm2023 feature set to keep the ability to disable exception catching.
In the future we are looking to remove the non-Wasm2023 feature set. Maybe at that point it might be possible to replace that with a exceptions enabled vs disabled combinations of Wasm2023, to enable this use case. We’ll definitely keep this request on the radar.