Browser Timings
This page details the technical constraints of the WebGL architecture related to the Application.targetFrameRate parameter.
When compiling a Unity project for WebGL, the Application.targetFrameRate parameter modifies not just the engine's internal frame limit, but the baseline browser API through which the Main Loop operates.
Uncapped (requestAnimationFrame)
If you uncap the frame rate (by setting Application.targetFrameRate to -1 or 0, depending on the Unity version), the Emscripten compiler binds the Unity main loop directly to the browser API window.requestAnimationFrame.
- Pros: This is the native, smoothest, and most accurate rendering method on the web. The browser automatically synchronizes calls with the player's monitor refresh rate (VSync).
- Profiling: The
cpuMainThreadFrameTimemetric (read by WebAP) reflects the real time the CPU spends calculating physics and scripts.
Artificial Limit (setTimeout)
If you strictly enforce a frame rate (e.g., Application.targetFrameRate = 30), Emscripten is forced to abandon requestAnimationFrame. Instead, it utilizes the setTimeout() API or a complex combination of internal timers to artificially delay the loop.
CPU Metric Distortion (The Emscripten Trap)
An artificial timer introduces a severe discrepancy when measuring CPU time. The processor may complete all game logic calculations in 5 ms and enter an idle state, but the WaitForEndOfFrame coroutine will not resume until the setTimeout timer expires.
Consequently: The FrameTimingManager records this wait time into the CPU timing. The profiler (and WebAP Tracker) will deduce that you have a CPU Bottleneck, even though the processor is functionally idle and the frame is merely awaiting the browser timer.
Correct Configuration Strategy
For optimal Web Adaptive Performance operation in the browser:
- Do not utilize
Application.targetFrameRate. Leave it at-1(uncapped). - Specify the desired FPS within the plugin settings (
Target Min FPS = 60). WebAP will use this value not as a hard limit, but as an anchor for rendering quality decisions.
