-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stutters every so often on macOS #159
Comments
I've also seen this periodically on my MacBook, but it doesn't happen on either of my other two non-Mac computers streaming over the same WiFi network. Mine is the Early 2016 MacBook. What model is yours? My guess is that it's something macOS is doing in the background that's eating up either CPU or network resources. Moonlight doesn't do any periodic work while streaming like that, so I can't imagine what it could be inside Moonlight. I'm going to try to catch the stutter in the Instruments profiler and see what's going on with the system at the time. |
Thanks, I did some testing before your post. I had run the stream and concurrently ping against the host computer and surprisingly the ping did not loose packet at all during the stutter.
This just reconfirms that it might be a macOS thing and not network inefficiency. Thanks! |
My model is |
I wouldn't totally trust the ping results. Ping is sending/receiving about 1 packet per second, while Moonlight (depending on how much is happening on screen) can be receiving 1,000 packets per second or more. If the network was only dropping a fraction of the total packets, the odds that one of the dropped packets would be your ping packet in all of that traffic is very low. |
Ah, good insight. 👍 |
I captured a trace of it in Instruments System Profiler and found some interesting stuff:
So it really appears that This confirms the issue is not our fault and lies with the network or OS network stack. |
Wow interesting. I wonder if other real-time streaming platforms (PS4 remote play) would have the same problem or if there is a workaround. |
Just want to report some of the things I've tried to resolve the issue that didn't work:
|
This whole thread is very insightful. And I've had the same issue for what it's worth. But, it's also worth noting that I get this issue on iOS as well. Both on my 2016 iPad Pro and iPhone 6s Plus. |
During the stutter, there is still interim packets of video/audio that was received. So it seems like If @euroclydon37 has problems on iOS too, does it mean the mac version and ios version utilize the same framework? |
In the trace I recorded, I saw recvfrom() take over 150 ms to return a single packet at one point. This is consistent with the stutter observed, because we are getting a bunch of data dropped and the rest delayed significantly. I'm highly suspicious of jumping to conclusions that iOS may be affected. Moonlight iOS and PC have totally different codebases and I haven't personally seen iOS affected myself. We need to remember that 99.9% of the time these issues really are transient network problems that have nothing to do with Moonlight. It takes pretty extraordinary evidence to prove that it's not the network's fault when we can prove that packets are being delayed or dropped before reaching the client. I'm not even totally convinced this isn't what I'm seeing on my own network. Very short network congestion conditions arise all the time, especially on WiFi with multiple clients and shared airspace, and real-time remote gameplay is about as intolerant of application to an imperfect network as you can find. In many ways, you are really seeing and hearing your network's performance. When packets are delayed, you see the video run in slow motion. When packets get dropped, you hear the audio crackle as it runs out of audio to play and see the video freeze until the congestion passes. |
So it looks like the packet drop from the However, I am going to test it out further on the same machine:
I'll report back the findings later this week. |
Did some snooping around with packet capture on the server and client, found that during the hiccup, the packets were unable to reach port:
And server tries to initiate a new TLS handshake:
|
@kujohn do you have the full packet capture of those packets (including port numbers and the original packet that the ICMP message was referring to)? There should be no HTTP/HTTPS activity from Moonlight after the stream is established until the session ends. |
Is this what you're looking for?
|
Without the full context of the packet capture, I can't tell whether that packet is expected or not. When Moonlight is disconnecting, we can expect to sometimes see a port unreachable message from the client to the server since the client has closed its socket but the server doesn't know yet. I'm also curious about those TLS packets you mentioned and what ports those were on? Can you send me a link to the full pcap file at cameron@moonlight-stream.org? |
Please try disabling location services. It might interrupt your stream when it scans for nearby wifi networks. System Preferences -> Security & Privacy -> Location Services |
@starchaser01 🏆 🎖 👏 👏 That was it. I haven't had any issue since turning off. I will test further! |
No issues at all. The location services caused the hiccups for me. Thanks all! |
This had been driving me crazy for a couple of months since using a Mac until I found this issue. It only affects WiFi. @cgutman it would be awesome if there was a small message that appears on macOS that notified you about this problem (like first time you start Moonlight), I can open another issue if you'd like. |
I think there is now a new variant of this issue... I know it sounds insane, but is it possible for the iPhone 11 to interfere with the connection when using Moonlight on MacOS? Every time I wake up an iPhone 11 in proximity to my laptop, regardless on if it is on the WiFi network/bluetooth, Moonlight stutters for 10+ seconds afterwards. This time, disabling location services results in no improvement. Can somebody else replicate this setup? Host Computer: Windows 10 custom built w/ ethernet Is it possible the new U1 / wideband chip triggers some weird signal interferes with moonlight? This issue did not exist with the iPhone XS. Likewise, this issue does not affect Steam In Home Streaming. How does this make any sense? |
I have the same issue as @eaferrari24 This also occurs, when my Apple Watch screen turns on. |
I think I used to have this, and I suspect it was due to Continuity/Handoff/etc. Maybe try disabling Handoff? I'm not sure if this is just in System Preferences or elsewhere. Maybe also check that you have AirDrop turned off. Also, I'm guessing this doesn't happen if you use wired ethernet and turn off the wifi? My vague recollection is that Continuity/Handoff works via Apple Wireless Direct Link (AWDL), which technically involves the wifi radio switching between channels rapidly. Perhaps see also https://stackoverflow.com/a/51786787 for further details. |
@dsedivec The other reason I don’t think it is handoff related is because other iPhone 11’s not affiliated with my Apple ID trigger this jitter/packet loss on my moonlight game stream when in proximity to my laptop. Honestly, I haven’t really followed up on this in a while. I mostly just keep my iPhone on the other side of the house or off when playing games and rely on MacOS to notify me of iMessage/FaceTime/Calls. The post above you by @Cludch suggests it also happens when connected via Ethernet. The iPhone X doesn’t have the U1 chip, so I’m stumped. Perhaps it is yet another variant of this problem. I’ve personally never had the iPhone X/XS trigger this jitter/packet loss just from waking the screen. My memory is vague but I recall replicating this issue in airplane mode... which makes me think the U1 chip doesn’t obeys the iOS airplane mode setting. Apple did recently confirm that the currently released versions of iOS continue to broadcast the U1 even if location services are disabled. Considering this doesn’t affect moonlight streaming onto the Apple TV or iPhone 11 and Steam in-home streaming works fine in all settings, I don’t think it’s the shield protocol or a macOS networking driver/interface issue. It has to be something with the macOS implementation of moonlight. Isn’t Steam’s in-home streaming open source? Maybe they communicate with the networking hardware in a different way? I’m out of ideas. |
If that's the case, I would like to shift my suspicion to Qt. Quick story: I used to use a VoIP client written in Qt, and I would experience a huge ping spikes during calls on a regular basis. It turns out, Qt makes macOS rescan wireless networks periodically, which has the same effect as having location services on. I don't think this is related to your problem, since yours happens only when you wake up your phone, but I think it demonstrates that Qt can do some surprising things to the system. Still, I doubt Qt on macOS has anything to do specifically with iPhones, so it would have to be something like "Qt causes a delay when a new BT/wifi device appears, which only happens when the iPhone wakes up". Something like that. I assume you're on wifi and not wired ethernet. If so, maybe you could enable wifi logging (https://apple.stackexchange.com/a/348574) and see if you can spot any hints as to what happens when you wake your iPhone?
That is weird. iPhone is not connected via USB? Is the phone paired to your computer with Bluetooth at all?
Understood. I just happened upon this issue after finding that I, too, needed to disable location services for a smooth experience (and sometimes quit/restart Firefox afterwards). Feel free to ignore my comments, thought I'd throw some ideas out. I just found it terribly disappointing (and, if you'll permit me, kind of funny) that you have to put your phone in another room to play games.
Since AFAIK no MacBooks have U1 chips, the only way I can think of the U1 chip playing a role here is if you're getting your network through wifi and the UWB signals are interfering with wifi. If that's the case, and it's not just a defect in your particular phone, I suspect the FCC (or your national equivalent) and Apple would very much like to hear about this! Does your iPhone leave Bluetooth on in airplane mode? I noticed mine does, presumably since newer iPhones need BT for the headphone jack. At some point in troubleshooting this I would have to start wondering if there is a defect with your specific iPhone and it's giving off RF interference.
I don't know if it's open source, but I wouldn't be surprised if moonlight-qt is using Qt's networking facilities, whereas Steam in-home streaming is not using Qt for networking (if it's using Qt at all). |
I think you and I are in sync on our suspicions with QT. At this point, I've seen this happen from multiple iPhone 11's so I really don't think its a defective phone. Likewise, since it doesn't affect Steam In Home Streaming I don't think it is appropriate yet to get Apple or the FCC involved. Yes, one iPhone has never been connected to my MacBook in any way, wired or wireless, and causes the issue. My airplane mode does leave bluetooth on, but I also manually toggled everything off. This variant of the issue REALLY messes up the connection compared to the original location services packet loss this issue was opened for. I'll try to get some wifi logging info in the next few weeks. Valves Open Source GitHub with a fair amount of their projects: https://github.com/ValveSoftware Since the issue was re-opened, maybe someone will have a similar configuration that they can replicate! Thank you @dsedivec & @cgutman Below is all speculation, but has anybody done any investigation into the UWB frequency range? Maybe it isn't too far off from 5ghz and is an independent chip purely for efficiency reasons. This may be why the newest 16 inch MacBook released a month ago doesn't have a dedicated chip. EDIT: https://www.techinsights.com/blog/apple-u1-delayering-chip-and-its-possibilities |
I have an M1 Max MBP. In my case, moonlight sometimes performs ok but most times not, Steam streaming and Geforce Now the same: sometimes OK sometimes not. Interestingly, every time I restart the Mac, they performs OK. And it's also the same situation when streaming from PS5. My other devices in the same wireless environment: android phone, steam deck, PC, they works perfectly streaming from sunshine, PS5 and Steam. |
I ended up buying a cheap WifI 6 Asus router. Put the router into AP mode and changed the 5ghz channel to 149. I connect my apple devices to that, works great now. I still keep the Eero mesh system with this setup. |
Hi, using custom network setup here 🙋♂️. What channel should I set the my 5GHz wifi to? |
I am in the EU and I use Channel 44 which fixed the issue for me. Also make sure that your router is not near many electrical appliances as this was also an issue for me. I had to find the "right" location within my apartment to reduce Network Jitter |
Thank you for triggering some |
Honestly, I always had this issue and my fix has always been turning the interface for Now, I changed my 5Ghz channel from 40 to 44 and its perfect! |
I just did a short test with macOS Sonoma. Disabled the cron and kept I don't know if the workaround is still needed, I will keep the cron disabled and an eye out for lags. PS: my Wifi was also using 5G Channel 44 at that time. |
This would mean that the best current solution is switching to channel 44 on 5Ghz |
Yes, this is also on Sonoma 14.4.1. No cron, no |
I'm just popping in to say that turning off Location Services on my new iPad Pro M4 fixed this stuttering as well. |
On top of everything mentioned in this thread, what ended up fixing the stutters on M2 MPB for me was setting both the host's output display and the mac's display refresh rates to 60hz. For the mac side, the setting is in Settings -> Displays, and by default it was set to "ProMotion" instead of 60hz. I'm also running the latest currently available dev build from here, not sure if that matters. |
confirming that after some time of using moonlight without any cron to disable the interfaces, everything is perfect. Except for the sound stutters sometime (have tried reducing de bitrate, etc and have a perfect connection) It seems to be coming in waves which sounds a lot like a network scan from macos that would impact every now and then. but it gets a hole lot better since the channel change. Now that I think about it it seems I haven't have the problem since a while now... It feels very weird that all this stuff was caused by a channel overlap... |
What you are referring too has already been responded with the crontab solution. Which is an out of the box solution compared to installing yet another app. |
Just put Moonlight for the first time on my M3 Macbook Pro and been struggling with this, tried everything suggested, and it only went away when I turned off Bluetooth. Unacceptable given I need it for the controller (not to mention keyboard / trackpad), will have to check if other streaming solutions work better. Really disappointing because everything worked perfectly fine a year ago on my M1 Air. |
did you disable "Game Mode" the controller symbol on the taskbar (we have the feature since MacOS Sonoma)? |
But didn't Moonlight stop activations gamemode on launch? |
See it, I've confused to the previous version on Moonlight that was activated the Game Mode. |
I was using the latest version of Moonlight, so it doesn't activate. I did try an older version (5.x) just to see if Game Mode might even help, no luck though. |
|
I'm having similar issues on my M3 Macbook Air (Sonoma 14.6.1). I'm trying to stream the native resolution of my macbook. I tried the following steps:
I'd prefer not to change my network channel that's managed by UniFi if possible? However, based on what @tranbaohuu said, I do notice that even when running I just can't get rid of `awdl0 .... |
You should really try the channel switch. Let us know if you see improvements! |
Thanks! I figured it was worth trying lol, so I changed my Channel Width to 20Mhz and Channel 149 & Channel 6 for all WiFi APs. Seems slightly better, but the issue persists. I also lowered the Moonlight FPS to 30 FPS, and used the automatically chosen bitrate for 27Mbps. My WiFi speeds are around 180Mbps Up/Down, yet I still get random periods of stuttering, about once every few minutes, for about 5-10 seconds. It runs flawlessly with no stuttering even up to 90Mbps except for random periods where it tells me to lower the bitrate. It seems to happen even at a 2 Mbps bitrate or even using Steam Link |
I really don't have this anymore after (I use to have it a lot) switching to sunshine, channel, location activated, AirDrop arctivated, Bluetooth on, cron fix. I'm on an m1 no stutter and apple tv |
Damn... for quite a long while I had zero issues with moonlight/sunshine. Today, the issues is back, even with Wifi channel 44 and the cron (disabling awdl0) enabled. Disabling the cron/enabling awdl0 did not change anything, neither did disabling AirDrop in the menu. The only thing I did today was rebooting the Mac, not sure how that is related. If found an Every ~10 seconds, I get high pings to a host on the local network and stuttering in Moonlight.
PS: I get these ping results also when not using Moonlight at all, so it must be a general network/wifi issue. Update: I rebooted the Wifi AP, tried disabling things on Mac - nothing helped. I then restarted my Mac and now everything is back to normal 🤷♂️ |
The fix is to temporarily disable a couple of Airdrop/Handdrop interfaces running a simple bash script, and re-activate with ctrl + c: https://www.reddit.com/r/MoonlightStreaming/comments/1dkz628/comment/l9lepvt/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button |
Important: After completing all settings, completely shut down and restart your device. It's not enough to just change the settings, in most cases it seems that restarting the device is necessary for the relevant settings to take full effect. I can't believe it took me years to figure this out! Along with all the tips above, this almost completely solved my problem - I now have no stuttering on moonlight at all. |
Describe the bug
Stream is perfect but every so often, maybe around 5-10min, video/audio stutters for few seconds. The controls still work during this time, but stutters and skips until it's over. Then it's flawless streaming until the next stutter.
Moonlight settings (please complete the following information)
I have tested with all variant of settings, changing Video bitrates from 20 ~ 150, v-sync, frame pacing, etc.. Occasional stutter still remains.
Client PC details (please complete the following information)
Server PC details (please complete the following information)
Moonlight Logs (please attach)
Moonlight-1546797780.log
The text was updated successfully, but these errors were encountered: