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.
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.