Version: 2023.2
Cursor locking and full-screen mode in Web
Debug and troubleshoot Web builds

Web performance considerations

In general, the Web performance is close to native apps on the GPU, because the WebGL graphics API uses your GPU for hardware-accelerated rendering. The only exception is the slight overhead for translating WebGL API calls and shaders to your OS graphics API (typically DirectX on Windows, OpenGL on Mac, and Linux).

On the CPU, Emscripten translates your code into WebAssembly, the performance of which depends on the web browser you’re using. For more information, see the Unity blog post WebAssembly Load Times and Performance.

Following are the additional considerations that you must be aware of:

  • The JavaScript language doesn’t support multi-threading or SIMD.
  • Any code that benefits from these features are likely to be slower than other code.
  • You can’t write threading or SIMD code in Web scripts, but as some engine parts are multi-threaded or SIMD optimized, they offer low performance on Web. For example, Web Skinning is both multi-threaded and SIMD-optimized.

Tip: To see how Unity distributes work to different threads on non-Web platforms, see the new timeline Profiler in Unity.

Web-specific settings which affect performance

To improve performance, set Exception support to None in the Player settings for Web by expanding Other Settings > Stack Trace.

Profiling Web

Web supports the Unity profiler. See the Profiler documentation to learn how to set it up.

Web content in background tabs

If Run in background is enabled in the Player settings for the Web platform, or if you enable Application.runInBackground, your content continues to run when the canvas or the browser window loses focus.

However, some browsers can throttle content running in background tabs. If the tab with your content isn’t visible, your content only updates once per second in most browsers. Note that this causes Time.time to progress slower than usual with the default settings, as the default value of Time.maximumDeltaTime is lower than one second.

Throttling Web performance

You might want to run your Web content at a lower frame rate in some situations to reduce CPU usage. For example, on other platforms, you can use the Application.targetFrameRate API to do so.

When you don’t want to throttle performance, set this API to the default value of –1, rather than to a high value. This allows the browser to adjust the frame rate for the smoothest animation in the browser’s render loop, and might produce better results than Unity trying to do its own main loop timing to match a target frame rate.

Cursor locking and full-screen mode in Web
Debug and troubleshoot Web builds