On Wayland, frame latency can be reduced by making the compositor render as late as possible before a vblank. This allows the compositor to show the latest frame available, just in time for the screen refresh. This guide describes how to configure this for certain compositors. This will improve your experience for all applications, not just Looking Glass.
Looking Glass can also be made to render right before the compositor renders, further reducing latency. This is what the <code>win:jitRender</code> setting does on Wayland. The timing of this is also controlled by the compositor, and thus the configuration is compositor-specific.
On Sway, this is controlled by the <code>max_render_time</code> setting. The <code>max_render_time</code> setting on the output controls how many millisecond the compositor renders before the vblank. Setting <code>max_render_time</code> on the window controls how many milliseconds the compositor tells windows to render.
=== Screen latency tuning ===
The goal is to set the smallest value for <code>max_render_time</code> that does not result in frame dropping. For this test, you must be able to tell if a frame is dropping. If you cannot tell this visually, you can open [https://testufo.com/ UFO test] in a browser running on native Wayland. The frame rate reported by this test will be lower than the screen refresh rate if there is frame dropping.
We will assume your display is called <code>DP-1</code>. You should change the name if it is different. If you have multiple monitors, this process must be repeated for every monitor.
We start by running <code>swaymsg output DP-1 max_render_time 1</code>. If there is frame dropping, increase the value of <code>max_render_time</code> by 1 and try again until frame dropping stops. This is the optimal setting for <code>max_render_time</code>. Once you find this value, open up your sway config file (usually <code>~/.config/sway/config</code>), and add the line <code>output DP-1 max_render_time t</code>, with <code>t</code> replaced by the optimal value obtained previously.