Skip to content

Instantly share code, notes, and snippets.

@zerkz
Last active July 8, 2026 03:16
Show Gist options
  • Select an option

  • Save zerkz/de5183f48f3903e4fbc7e2a166044e1a to your computer and use it in GitHub Desktop.

Select an option

Save zerkz/de5183f48f3903e4fbc7e2a166044e1a to your computer and use it in GitHub Desktop.
Fix macOS AWDL-induced UDP loss (Moonlight frame drops)

awdl-down

macOS's AWDL interface (awdl0, used by AirDrop/AirPlay/Handoff) periodically pulls the WiFi radio off-channel. In my personal case, this causes ~12% time-based UDP downlink loss and latency spikes, regardless of bitrate or signal quality — seen as ~15% "network" frame drops in Moonlight. TCP mostly masks it, which makes it hard to diagnose.

Fix: disable the features that wake AWDL, and down awdl0 at boot via a one-shot LaunchDaemon (no resident process; it watches the first 3 minutes after boot, then exits).

Install

./install.sh

Prompts for sudo where needed.

Undo

sudo launchctl unload /Library/LaunchDaemons/com.zdware.awdl-down.plist
sudo rm /Library/LaunchDaemons/com.zdware.awdl-down.plist /usr/local/bin/awdl-down.sh

Re-enable AirDrop/AirPlay/Handoff in System Settings > General > AirDrop & Handoff.

Caveats

AirDrop, AirPlay, Sidecar, Universal Control, and Handoff will not work while awdl0 is down. If macOS revives the interface mid-session (rare with the triggers disabled), run sudo ifconfig awdl0 down.

#!/bin/sh
# Down awdl0 at boot, then exit. The WiFi stack brings awdl0 up at some
# point during boot/login, so watch for 3 minutes to catch it whenever
# it appears, then get out of the way.
i=0
while [ $i -lt 36 ]; do
if /sbin/ifconfig awdl0 2>/dev/null | grep -q RUNNING; then
/sbin/ifconfig awdl0 down
fi
sleep 5
i=$((i + 1))
done
exit 0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.zdware.awdl-down</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/awdl-down.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
</dict>
</plist>
#!/bin/sh
# Installs the awdl-down boot daemon and disables the macOS features
# that wake AWDL. Run as your normal user: ./install.sh
# Prompts for sudo where needed.
set -e
if [ "$(id -u)" -eq 0 ]; then
echo "run as your normal user, not root: ./install.sh" >&2
exit 1
fi
if [ -f /Library/LaunchDaemons/com.zdware.awdl-down.plist ] && [ "$1" != "--force" ]; then
echo "already installed; use --force to reinstall" >&2
exit 1
fi
cd "$(dirname "$0")"
sudo cp awdl-down.sh /usr/local/bin/awdl-down.sh
sudo chmod 755 /usr/local/bin/awdl-down.sh
sudo cp com.zdware.awdl-down.plist /Library/LaunchDaemons/
sudo launchctl unload /Library/LaunchDaemons/com.zdware.awdl-down.plist 2>/dev/null || true
sudo launchctl load /Library/LaunchDaemons/com.zdware.awdl-down.plist
# Disable AWDL wake triggers
defaults write com.apple.sharingd DiscoverableMode -string Off
defaults -currentHost write com.apple.controlcenter AirplayRecieverEnabled -bool false
defaults -currentHost write com.apple.coreservices.useractivityd ActivityAdvertisingAllowed -bool false
defaults -currentHost write com.apple.coreservices.useractivityd ActivityReceivingAllowed -bool false
killall sharingd useractivityd ControlCenter 2>/dev/null || true
sudo ifconfig awdl0 down
echo "done: awdl0 is down and will be downed at each boot"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment