Enable Late Latching
Updated: Dec 16, 2024
Note: In Unreal Engine 4, Late Latching should not be enabled at the same time as
Occlusion Query.
In Unreal Engine 5, Late Latching should not be enabled at the same time as
Emulated Uniform Buffer.
Late Latching is a latency-reduction technique that allows applications to remove up to one additional frame of latency in head and controller poses. The latest Meta XR plugin offers it as an option for Meta Quest, Quest 2, and Quest 3 apps.
Late Latching helps Meta Quest, Quest 2, and Quest 3 apps lower motion-to-photon latency in their camera and controller transforms by providing the GPU with camera and controller poses at the last possible moment before rendering starts.
In most game engines, including Unity and Unreal, there are up to 3-4 frames of latency between receiving an input and displaying the effect of that input on-screen:
- The current input state is sampled at the start of a main thread update. The main thread acts on the current input state and updates the game simulation. Nearly all of your C# scripts will run during this simulation phase.
- Once the main thread is complete, a render thread starts on the CPU, determining what commands to send to the GPU to produce a visual representation of the game simulation.
- Once the render thread is complete, the command list is sent to the GPU, which generates the eyebuffer frames for your screen.
With Late Latching enabled, the game engine will do two things:
- Sample your headset and controller positions at the last possible moment -- at the end of the render thread, when it’s sending its command list to the GPU.
- Calculate a new pose based on this data for every uniform buffer value derived from a head or controller pose and write it to the uniform buffer memory at the end of the render thread.
For example, let’s say you have an app with 200 objects. Ten of those objects are children (in the scene hierarchy) of your right-hand mesh, ten are children of your left-hand mesh, and the other 180 objects just exist normally in the scene.
When you perform Late Latching, we will recalculate:
- The model matrix for each of the twenty objects that are children of the left and right-hand anchors.
- A new global view-projection matrix representing camera position.
The system then patches in the new matrix values. Patching is as simple as rewriting to the same Vulkan uniform buffer memory in exactly the same way as a normal write occurred earlier in the frame. These writes happen during the regular render thread executions. The late latch writes occur at the end of the render thread with fresh pose data.
There are two considerations to note with this implementation of Late Latching:
- Late Latching allows the GPU to render frames with headset positions that the system has not yet parsed through gameplay code. This functionality could allow players to put their heads or hands through a wall for a frame, even though gameplay code stops these collisions. The key to understanding this is that the Gameplay Pose in the above image is the earliest in the scene, and the system uses it for your physics and gameplay calculations. The system calculates the Late Latching pose much later with more recent pose data.
- From the main and render threads perspective, a “frame” is not guaranteed to be 1/72 seconds in an app running at 72fps. If Phase Sync is enabled, and you have a simple app that takes 1ms on the main thread and 3ms on the render thread, Unity and Unreal will automatically schedule the render thread to start 3ms before the GPU frame needs to render and the main thread 1ms before that. As a result, late latching will only reduce latency by 4ms under these conditions.
Late-Latching and
Phase Sync typically complement each other, and we encourage developers to use both systems.
To use the Late Latching feature, you must enable
Multi-View and use the Vulkan API.
To enable Late Latching
- Download and install the Meta XR plugin.
- Enable the Meta XR plugin.
- Click Edit > Plugins > Virtual Reality.
- Check the Meta XR plugin to enable it in your project.
- Click Edit > Project Settings.
Go to Plugins > Meta XR > Mobile > Late Latching, and check the box to enable the feature.
After enabling Late Latching in your app, you can verify that it is active and see how much latency it has saved by examining the logcat logs.
The Prd value stands for Prediction Latency, and indicates the render latency as measured by the runtime. To calculate how much latency Late Latching has saved, compare the Prd values between when Late Latching is active and not active. For example, if the Prd with Late Latching is 35ms and the Prd without is 45ms, you saved 10ms of latency with Late Latching.