The WebAssembly 2023 target contains features that can improve code performance, reduce generated code size, and reduce download times for your Web build on all supported browsers and platforms.
If you enable the WebAssembly 2023 target, it automatically enables all of the following optimization features:
Section | Description |
---|---|
WebAssembly native exceptions | Exception handling with less overhead than JavaScript-based exceptions. |
Support for WebAssembly Single Instruction Multiple Data (SIMD) | Improves the performance of applications that perform a lot of mathematical calculations or complex vertex manipulation. |
Optimized data operations | Useful for large amounts of data manipulation. |
Support for BigInt | Improves data exchange between WebAssembly and JavaScript code. |
WebAssembly.Table | Improves interoperability between WebAssembly and JavaScript. |
Speed up data type conversions | Reduces code size and slightly improves performance. |
Your browser needs to support these features for them to work properly. To check supported browsers, refer to prerequisites for WebAssembly 2023.
To learn how to enable WebAssembly 2023, refer to Enable WebAssembly 2023.
In the original WebAssembly MVP feature setA feature set is a collection of related packages that you can use to achieve specific results in the Unity Editor. You can manage feature sets directly in Unity’s Package Manager. More info
See in Glossary, exception handling relied on JavaScript exception mechanisms. This form of exception handling resulted in relatively high overhead. Since then, WebAssembly has developed its own native exception handling support that reduces the overhead issue.
If you enable WebAssembly 2023, it automatically enables the WebAssembly native exceptions language feature. These native exceptions can improve runtime performance and reduce .wasm
code size.
The WebAssembly SIMD feature enables Unity to use the SIMD instruction support the browser provides. Internally, the browser targets the SIMD instruction sets in x86 intel and ARM architectures. So, this feature works on both desktop and mobile browsers that are supported. For a list of supported browsers, refer to Prerequisites for WebAssembly 2023.
WebAssembly SIMD support includes automatic vectorization support. If you have scalar arithmetic calculations in short loops in your code, auto-vectorization automatically converts it to WebAssembly SIMD data parallel form. In this form, code can perform faster because many calculations are processed simultaneously.
The WebAssembly SIMD feature can make a significant difference if you have operations that perform heavy matrix mathematics, such as character skinningThe process of binding bone joints to the vertices of a character’s mesh or ‘skin’. Performed with an external tool, such as Blender or Autodesk Maya. More info
See in Glossary or animation keyframeA frame that marks the start or end point of a transition in an animation. Frames in between the keyframes are called inbetweens.
See in Glossary and transform calculations.
If your application performs a lot of mathematical calculations or complex vector manipulation, this feature could significantly improve runtime performance.
WebAssembly 2023 enables better code generation of memcpy
and memset
functions. This improved code generation results in better performance when your code copies or sets large amounts of data.
WebAssembly 2023 enables the WebAssembly.BigInt
language feature. You can use WebAssembly.BigInt
to access the JavaScript BigInt data type when you exchange data between JavaScript and WebAssembly code. You can then use the BigInt data type to send and receive 64-bit integers natively between JavaScript and WebAssembly code without the need to split 64-bit integers into high order and low order (HI/LO) pairs of 32-bit numbers.
This improved communication results in a better marshaling boundary between the two interfaces, which improves marshaling performance and also generates smaller code.
You can also enable WebAssembly.BigInt
support without the other WebAssembly 2023 features. For more information about the feature and how to enable it separately, refer to WebAssembly language features.
Note : If you already have marshaling code between the JS and WebAssembly language boundaries that use 64-bit integers, adjust your code to the updated 64-bit marshaling mode that uses the JS BigInt feature.
For example, if you have an integer like this:
const number = 12345678901234567;
Convert it to BigInt like this:
const bigInt = BigInt(number);
For more information, refer to Emscripten documentation.
The Unity WebAssembly 2023 feature set enables the Unity Emscripten toolchain to target the WebAssembly.Table
language feature. This feature simplifies code generation whenever you invoke functions via pointers. Also, because the Emscripten compiler requires fewer passes during compilation, compilation times are faster.
To invoke functions via pointers, use the {{{ makeDynCall }}}
macro.
For more information about the JavaScript object, refer to the Mozilla documentation on WebAssembly.Table.
You can also enable WebAssembly.Table
support without the other WebAssembly 2023 features in Player settings. For more information about the feature and how to enable it separately, refer to WebAssembly language features.
Note: The Emscripten functions dynCall_*()
and Module.dynCall()
are deprecated. If your JavaScript plugin code uses these functions, use the Emscripten {{{ makeDynCall() }}}
macro instead.
If you enable WebAssembly 2023, Unity implements the following conversions with a shorter low-level instruction sequence:
float to int
double to int
These conversions reduce code size and slightly improve runtime performance.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.