Skip to content

Disable WLAN AutoConfig during streaming to eliminate Wi-Fi jitter - #132

Open
psykokwak-com wants to merge 1 commit into
moonlight-stream:masterfrom
psykokwak-com:disable-wlan-autoconfig-during-streaming
Open

Disable WLAN AutoConfig during streaming to eliminate Wi-Fi jitter#132
psykokwak-com wants to merge 1 commit into
moonlight-stream:masterfrom
psykokwak-com:disable-wlan-autoconfig-during-streaming

Conversation

@psykokwak-com

Copy link
Copy Markdown

Summary

  • Disables WLAN AutoConfig (wlan_intf_opcode_autoconf_enabled) during streaming to prevent Windows from performing periodic background Wi-Fi scans that cause 50-400ms latency spikes every ~30 seconds
  • Re-enables AutoConfig explicitly in exitLowLatencyMode() before closing the WLAN handle, ensuring network discovery is fully restored after streaming
  • Adds error logging for the existing media streaming mode WlanSetInterface call

Problem

On Windows, the WLAN AutoConfig service performs cyclic background scans at ~30-second intervals, even when already connected to a network. These scans cause periodic latency spikes of 50-400ms that are
clearly visible as jitter during game streaming over Wi-Fi.

The existing wlan_intf_opcode_media_streaming_mode optimization does not prevent these scans on all drivers (e.g., Intel AX211 returns ERROR_NOT_SUPPORTED (50) for media streaming mode).

Running netsh wlan set autoconfig enabled=no interface="Wi-Fi" before streaming completely eliminates the jitter. This PR implements the programmatic equivalent using WlanSetInterface with
wlan_intf_opcode_autoconf_enabled.

Testing

Tested on a laptop with Intel AX211 Wi-Fi adapter streaming at 2560x1600@165Hz over Wi-Fi 6:

  • Before: periodic latency spikes of 50-400ms every ~30s visible in network statistics
  • After: Frames dropped due to network jitter: 0.00%, average network latency 2ms

Log output confirms the fix is active:
WLAN interface 0 failed to enter low latency mode (error 50)
WLAN interface 0 cyclic background scan disabled
[...]
WLAN interface 0 cyclic background scan re-enabled

Notes

  • Uses the same WlanSetInterface API and dynamic loading pattern already in place for media streaming mode
  • No new DLL dependencies — wlan_intf_opcode_autoconf_enabled is part of the same wlanapi.dll API
  • AutoConfig is restored both explicitly (before handle close) and implicitly (when the WLAN handle is closed by the OS)
  • Requires the application to run with elevated privileges (administrator) for the autoconfig disable to succeed

Windows WLAN AutoConfig performs periodic background scans (~30s intervals)
that cause 50-400ms latency spikes during game streaming over Wi-Fi. The
existing media streaming mode (wlan_intf_opcode_media_streaming_mode) does
not prevent these scans on all drivers.

This disables WLAN AutoConfig (wlan_intf_opcode_autoconf_enabled) when
entering low latency mode, which is the programmatic equivalent of:
  netsh wlan set autoconfig enabled=no interface="Wi-Fi"

AutoConfig is explicitly re-enabled in exitLowLatencyMode() before closing
the WLAN handle to ensure network discovery is restored.

Also adds error logging for the existing media streaming mode call.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant