moonlight-stream / moonlight-ios

GameStream client for iOS/tvOS
GNU General Public License v3.0
1.04k stars 260 forks source link

Sound and video stutter on iPad Pro M4 #627

Open ollebro opened 3 weeks ago

ollebro commented 3 weeks ago

Describe the bug Both video and sound stutters every 3-4 seconds, similar to the kind of video stutter you would get from running 24Hz video on a 60Hz display. It doesn't matter which resolution(720,1080,4K), FPS/Hz(30,60,120) or bitrate I select in Moonlight. Also doesn't matter if I select smooth video or not on the frame pacing setting. Both host and client are on the same network and just to be sure to rule out network and host I tried Moonlight on a iPhone 15 Pro and Macbook Air M2. Neither have any issues regardless of resolution, Hz or bitrate.

I'm using a virtual display adapter which can handle any resolution and Hz, and it works fine for the other Apple devices but not the new iPad. https://github.com/itsmikethetech/Virtual-Display-Driver

Device details

Server PC details

marcosscriven commented 3 weeks ago

Hi - I wanted to report the same. I have all the latest versions of OS, drivers, Sunshine/Moonlight (as per @ollebro). In my case, I'm not using the virtual driver.

I'm using a Wifi 6e Unifi router, with the iPad on 6GHz. Stats show no dropped frames.

I was excited to try AV1 + 6GHz wifi, but unfortunately it's unplayable like this.

justing6 commented 3 weeks ago

I can confirm the exact same behavior. An entire stream stutter (video and audio) usually every 3-5 seconds, but sometimes up to 10 seconds between stutters. Between major stutters, video and audio are flawless without micro-stutter at both 60hz and 120hz settings.

Note I usually use moonlight on my steam deck oled, and I have absolutely no stutter at 60hz or 90hz, 5ghz or 6ghz streaming 2560x1600 at 100mbps.

This is with my desktop (i7-12700k/rtx 4090) running a custom resolution to match the iPad from directly connected TV (not virtual driver), 2752x2064 at 120hz and 60hz. I also have access to 6ghz wifi which consistently hits 920mbps on a speedtest from the iPad. Normally I’d blame apple’s WiFi, but the 0.00% network dropped frames with 4-6ms average network latency from the statistics window points away from it.

Nothing I’ve tested has affected this at all (didn’t make the stuttering better or worse), including:

Testing both 120hz and 60hz Vsync on/off in game nvidia control panel frame limit game to 120fps/60fps respectively instead of Vsync Gsync on/off on host monitor Using 5ghz or 6ghz wifi Streaming 60hz and limiting iPad screen to 60hz max using h264/hvec/av1 encoder lowering/raising bitrate (between 50mbps and 150mbps) changing frame pacing setting on moonlight disabling location service on iPad disabling bluetooth on iPad testing after fresh boot of iPad and PC Disabling Moonlight Statistics window multiple different games

Device details

iOS/tvOS version: iPadOS 17.5 Device model: iPad Pro 13 M4, WiFi only Moonlight Version 9.0.2

Server PC details

OS: Windows 11 Pro Version 10.0.22631 Build 22631.3593 GeForce Experience version: 3.28.0.412 (not used for streaming) Nvidia GPU driver: 552.22 Sunshine Version v0.23.1 Antivirus and firewall software: Windows Defender and Windows Firewall

marcosscriven commented 3 weeks ago

I found the following fixed the issue for me: https://github.com/moonlight-stream/moonlight-qt/issues/159#issuecomment-452675992

Please try disabling location services. It might interrupt your stream when it scans for nearby wifi networks. System Preferences -> Security & Privacy -> Location Services

justing6 commented 3 weeks ago

I found the following fixed the issue for me: moonlight-stream/moonlight-qt#159 (comment)

Please try disabling location services. It might interrupt your stream when it scans for nearby wifi networks. System Preferences -> Security & Privacy -> Location Services

Note for anyone looking at this issue, this did not fix the issue for me. Disabling location services seemed to have no effect.

heywoodlh commented 3 weeks ago

TL;DR - Resolved this issue for myself on my M4 iPad Pro by switching my 5Ghz wireless network to channel 149 on OpenWRT.


I have experienced the same issue on my 11" iPad Pro and M2 Macbook Air but no other devices on my network (Steam Deck, Apple TV, iPhone, Logitech G Cloud) seem to encounter this issue over Wifi. Today I upgraded to an M4 iPad and encountered the same issue so was happy to see this thread pop up and know that I'm not the only one experiencing the issue. As it seemed to only happen to me on low-priority (for me) Apple devices, I wasn't very concerned about this.

After a bit of Googling today, I found this Reddit comment which suggests to switch your 5Ghz wifi network to channel 149. I gave it a try thinking it would resolve nothing -- but it totally worked for me on my OpenWRT router. I was able to play Ghost of Tsushima on my iPad Pro over Moonlight without stuttering. Prior to today, I was using the default OpenWRT 5Ghz channel.

I am also happy to report that it resolved my MacOS + Moonlight stuttering issue. I've never been able to get smooth performance on my Macs before, so I was happy that this helped!

Would be curious if this helps anyone else and if any wireless/Apple wizards have any explanations. I work remotely in a tech role, so I'm pretty attentive to making sure my wireless network is solid -- and this was one of the only niche pain-points I've had that I haven't tried hard to resolve.

Ysabelle12 commented 3 weeks ago

This happens to me on every exactly 1 second interval. no packet loss was detected and stuff. I tried using ethernet to no avail. However restarting iPad 11" M4 will fix it temporarily. just it'll come back sooner or later. its a very specific interval of 1 second or sometimes even 500MS

EvenZH1102 commented 2 weeks ago

I have similar issue as well on iPad Pro M2, however such stutter won't happen when I use cable network.

justing6 commented 2 weeks ago

I got a chance to test my iPad Pro M4 using an Ethernet adapter and got no stuttering or skipping at all. I also tested having my desktop host a WiFi network in hotspot mode and connecting the iPad to that and got a much smoother connection as well. It wasn’t really usable as I got massive frame drops every 30 seconds or so due to the hotspot feature in windows just not having consistent throughput, but I didn’t get the same skipping every few seconds that I did over my normal WiFi connection.

I can’t figure out what the difference is though, as I’ve tested multiple wireless APs, switches, security settings, bands, etc and nothing has made the skipping better or worse using Moonlight on my iPad. At the same time, my android phone and Steam Deck OLED work completely fine with no skipping on the same 5ghz and 6ghz networks that the iPad is having issues on. I also have an older iPad Pro 2018 I’m testing with, and while the stream isn’t as smooth as my Steam Deck and there is some skipping still, there’s notable no audio skipping on my 2018 iPad. While the 2024 iPad has a smoother stream, it has much larger skips where the audio cuts out as well.

alotofentropy commented 1 week ago

I suspect it is a mix of Location services and other apple services like continuity. On a fresh boot of iPad OS having location services on makes lag spikes horrible, but when I turn it off it disappears. If I share my screen with my mac though, everything comes back, and no change of disabling or enabling continuity fixes it, the iPad will need a reboot to get rid of the lag again

justing6 commented 6 days ago

I gave it a try and disabled location service prior to a fresh boot, didn’t see really any change. Still got skips every few seconds. It must be that something in my setup just hate iOS, because everything works great to my steam deck.

Belthazaar commented 6 days ago

@justing6 I responded to another issue about this, but can you try this and see if this helps https://github.com/moonlight-stream/moonlight-ios/issues/607#issuecomment-2153749235

ollebro commented 6 days ago

Before switching to AWDL channels I did a test with steam link which looks like below. for iPhone the connection is very stable while you can see the result for iPad, a jump every second or so.

iphone ipad

I then tested to switch 2,4Ghz to channel 6 and 5GHz to channel 44 (I don't have access to channel 149) and now both devices looks like the iPhone result, rock solid connection and I notice it immediately starting up Moonlight on iPad that there now is 0 stutters.

So I guess this is one solution, what doesn't make sense to me is that even with this network stutter I don't notice any video or audio issue streaming with Steam Link as opposed to Moonlight, so is Steam Link doing some kind of buffer?

Secondly I don't understand how this issue never affected the iPhone which is on the same network.

Belthazaar commented 6 days ago

My guess is that the Steam Link has a bit of a buffer somewhere. Since clearly the Steam Link sees the same network behaviour when we do a network test. However, I have seen posts about people complaining about other streaming software such as Geforce Now, Xbox Cloud Streaming, and even Apple's own Virtual Mac streaming. This reddit post pointed me towards AWDL and started the whole debugging process.

I'm not sure with the iPhone, as I might have only encountered this issue maybe once over the past year, compared to how easily it is to reproduce this issue with an iPad. I have experienced this on my MacBook in the past, but I am usually connected to a dock with wired networking when I stream on that.

My current guesses for the iPhone is :

  1. that Apple keeps the AWDL knowledge and network running for longer when the screen is off, so it doesn't need to do the discovery process as often. On my iPad I noticed that the Steam Link performance is at it's worst when I've left my iPad locked for a few minutes and start the network test immediately after waking it
  2. The iPhone has the possibility to listen on multiple Wi-Fi channels at once. Unsure if this is related to the iPhone having cellular access as well.
joeybaumgartner commented 5 days ago

The switch to AWDL fixed the same issue I had, just on a slightly older iPad (M2 iPad Pro). Prior to that, the stream was pretty stuttery. On top of that, I found that running iperf3 on a server for my iPad to connect to would always cause the connection to drop to zero (or near zero). Similar results when doing a test using Steam Link as well. After switching my Wi-Fi signal over to 149 MHz, all of these issues went away. iPerf3 testing showed a lower bound of 149 Mbps compared to 0 or single digits. I highly recommend making this change if your wireless supports it.

mayankk2308 commented 4 days ago

Strangely, using the aforementioned WiFi channels does not fix this issue for me on the M4 iPad Pro (no cellular). I still get the rhythmic spike in the steam link test regardless. Streaming over WiFi on Mac and iPhone works fine. Turning off both airplay/handoff and location services also does not seem to help in my case.

chrispe-lab commented 1 day ago

I have the same issue with my new Ipad Pro M4.

Iphone Steam Link on Wifi - No issues IMG_0460

Ipad Steam Link on Wifi - Major issues IMG_0005

Ipad Steam Link on Wifi after network reset - No issues IMG_0006

Ipad Steam Link on Wifi after network reset and a while later - Major issues IMG_0007

Ipad Steam Link on Cellular with VPN - Major issues C34E4EAF-FBEC-41C0-995F-91096BA6F6BF_1_201_a

Iphone Steam Link on Cellular with VPN - No issues BBC4AE11-BE94-4299-9561-1AE92679CEF8_1_201_a

Based on the above makes me think this is not a specific Wifi issue with channels or related to specific Wifi brands. This is either an issue with Steam Link or how Apple have configured their wifi settings.

ollebro commented 1 day ago

I wonder if this will improve with the Game Mode Apple showed off at WWDC.

chrispe-lab commented 1 day ago

I really hope so, have you found some other fix to this? It keeps coming back for me...

I'm downloading iPadOS 18 Beta now to see if it works better.

ollebro commented 1 day ago

For me switching the wifi channels to 6(2.4GHz) and 44(5GHz) worked but those channels are quite congested in my building so if the Game Mode fixes this I would be very happy. I dont have access to the beta so I'm curious to see if it improves for you.

chrispe-lab commented 1 day ago

Ok, I might try that later.

First let's see if iPadOS18 solves anything.

I've also bought a new 6GHz AP, not sure i will need it as the issue seems to go beyond WiFi.

chrispe-lab commented 1 day ago

Some interesting findings here. At first iPadOS 18 seemed to fix this issue but then I opened my Macbook Pro to start working again. Did the latency test again and it's back to intermittent lag spikes...

So this has more to do with the connection to the MacOS than anything else.

Do you have a Macbook Pro in close proximity?

Belthazaar commented 1 day ago

I did some more testing over the last few days. Purposely having my network not "Apple optimised".

What you are seeing is the MacBook sending out it's AWDL discovery packets when it wakes up. This is an issue with Apple products in general, not just iPads, iPhones or the new Vision Pro.

To easily replicate this issue on your iPad, you can run a continuos ping to something else on your network (preferably a device with a wired connection to your router). For the best result reduce your ping count to something pretty low, like 0.1 or 0.05 seconds. You might start to see the rhythmic pattern already.

Now this is where the "fun" begins, if you then unlock your iPad or iPhone, you will start to see your RTTs go all over the place, and you might even see some packets drop.

Belthazaar commented 1 day ago

This is the results of some tests I ran earlier. The setup is a Macbook running pings to my moonlight pc, with a second Macbook sniffing on channel 44. The blue line is ping RTT, and the red lines that I've overlapped is every time an AWDL packet was seen on channel 44.

image

The first red cluster is me unlocking my iPad, and the second is me unlocking my iPhone.

I can't yet say for 100% certainty that it is AWDL, but it sure looks like it causes it.

chrispe-lab commented 1 day ago

It sure is: https://forums.macrumors.com/threads/wi-fi-jitter-erratic-ping-latency-due-to-awdl-airdrop-airplay.2373916/

I'm not sure how Apple is getting away with this, especially now that Apple are going for the gamers market with Sequioa and iPadOS / iOS 18.

Would prefer the option in the upcoming "Game Mode" to disable AWDL completely!

This seems to only affect iPads and MacBooks, as I'm not seeing this issue on the iPhone.

chrispe-lab commented 1 day ago

This is slowly driving me crazy. I thought I was able to isolate this problem but I've been using the iPad next to my other Apple devices now for a few hours and nothing, it works perfectly.

I did a restart (up then down) of the AWDL eth adapter though, maybe that was the solution to the problem.