Wayland latency tuning

From Looking Glass
Revision as of 22:55, 5 February 2023 by Gnif (talk | contribs) (→‎Looking Glass latency tuning (B5-only))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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 win:jitRender setting does on Wayland. The timing of this is also controlled by the compositor, and thus the configuration is compositor-specific.

Sway[edit]

On Sway, this is controlled by the max_render_time setting. The max_render_time setting on the output controls how many millisecond the compositor renders before the vblank. Setting max_render_time on the window controls how many milliseconds the compositor tells windows to render. Both must be set for optimal latency.

Screen latency tuning[edit]

The goal is to set the smallest value for max_render_time 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 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 DP-1. 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 swaymsg output DP-1 max_render_time 1. If there is frame dropping, increase the value of max_render_time by 1 and try again until frame dropping stops. This is the optimal setting for max_render_time. Once you find this value, open up your sway config file (usually ~/.config/sway/config), and add the line output DP-1 max_render_time t, with t replaced by the optimal value obtained previously.

Looking Glass latency tuning (B5 and later only)[edit]

Tuning the latency for Looking Glass follows a very similar process:

  1. Close the Looking Glass client.
  2. Run swaymsg 'for_window [app_id="looking-glass-client"] max_render_time 1'.
  3. Run the Looking Glass client with the win:showFPS win:jitRender option. If you have multiple monitors, you want to move to window to the monitor with the highest resolution.
  4. If the FPS value displayed is lower than the screen refresh rate, close the client and restart from step 2, but increment the value of max_render_time by 1.
  5. Once this is done, open up your sway config file (usually ~/.config/sway/config), and add the line for_window [app_id="looking-glass-client"] max_render_time t, with t replaced by the optimal value obtained previously.