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

Open
psykokwak-com wants to merge 1 commit from psykokwak-com/disable-wlan-autoconfig-during-streaming into master
psykokwak-com commented 2026-03-08 14:59:48 -05:00 (Migrated from github.com)

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
## 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
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'psykokwak-com/disable-wlan-autoconfig-during-streaming:psykokwak-com/disable-wlan-autoconfig-during-streaming'
git switch 'psykokwak-com/disable-wlan-autoconfig-during-streaming'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'master'
git merge --no-ff 'psykokwak-com/disable-wlan-autoconfig-during-streaming'
git switch 'psykokwak-com/disable-wlan-autoconfig-during-streaming'
git rebase 'master'
git switch 'master'
git merge --ff-only 'psykokwak-com/disable-wlan-autoconfig-during-streaming'
git switch 'psykokwak-com/disable-wlan-autoconfig-during-streaming'
git rebase 'master'
git switch 'master'
git merge --no-ff 'psykokwak-com/disable-wlan-autoconfig-during-streaming'
git switch 'master'
git merge --squash 'psykokwak-com/disable-wlan-autoconfig-during-streaming'
git switch 'master'
git merge --ff-only 'psykokwak-com/disable-wlan-autoconfig-during-streaming'
git switch 'master'
git merge 'psykokwak-com/disable-wlan-autoconfig-during-streaming'
git push origin 'master'
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-moonlight-stream/moonlight-common-c!132
No description provided.