-
-
Notifications
You must be signed in to change notification settings - Fork 582
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
Brief drop outs from an M1 mac #1515
Comments
I'm realizing that this may be a very similar issue to the other M1 related issue I posted about previously: #1496 One big difference though is that in the previous issue, the drop outs were frequent enough that they could be called "stuttering" (i.e. every few seconds). Whereas in this issue, the drop outs are every ~10 minutes. |
I also realized there is a macOS update available. I've just upgraded my M1 mac from 12.4 to 12.5.1 (21G83). I'll see if that helps. |
I've just started noticing similar drop outs coming from an intel mac: MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports), macOS 12.4 (21F79). Playing Pandora music via a firefox tab, connected to SPS via system sound output menu (realtime stream). Logs:
I restarted my intel macbook, and after a single recurrence of the drop out, it did not recur. Logs after the restart:
Makes me wonder if airplay bugginess is present in intel as well as M1 macbooks. |
Thanks for the information. It's really hard to know where the problems may lie -- the clients, the network, general delay on the Internet, Shairport Sync itself... so I guess that the best thing is to keep monitoring it, see if there is anything definite we can pin down... |
Agreed, I'm going to see if I can find any patterns in the long run. I may post updates in this thread from time to time, but feel free to ignore me until I have something more conclusive :) FWIW, connecting to SPS via iOS (whether in streaming or buffered mode) seems more reliable than connecting via macOS devices in my experience. |
Hi again, I've been testing various configurations for the past week to attempt to isolate the issue. I've determined that this issue only occurs when the raspberry pi is connected via ethernet. When it's connected via wifi, I don't get these drop outs. I tested on a new raspberry pi, SD card, and ethernet cable as well, so I don't think it's that I got a "dud". Based on all the tests I ran, I believe the problem must lie in one of three places:
Here are two full logs with log level 2 and statistics enabled that show the dropouts occurring in case you are interested to see (cmd + F for
When these logs were recorded, I was connecting to SPS from an intel macbook client. The macbook was connected to my network via wifi. I was streaming pandora music from a firefox tab. The macbook was connected to SPS via the system-wide audio output setting. SPS was running on a raspberry pi that was connected to my network via ethernet cable. software versions:
hardware:
MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports), macOS 12.4 (21F79) |
Wow, thank you so much for all this, which I will study in the morning. |
Okay, so there is a fault in Shairport Sync. In a Realtime Stream, packets of timing information are sent roughly every two seconds. If a packet has not been received for more than three seconds, Shairport Sync works on the basis that the sender has disappeared, at least temporarily. (This happens, for example, if you shut a Mac -- putting it to sleep -- while it is playing a YouTube video and the Mac is not plugged in to a power source.) From your experience, it seems that three seconds is too short, since packets can occasionally be lost in "normal" operation. So the wait time has been changed from three to seven seconds, giving the opportunity for at least three packets to be received before concluding the sender is gone. (The idea of the code is to detect that the sender has disappeared, and when that happens, it is normally for at least tens of seconds; from that perspective, seven seconds should be fine.) I've just pushed an update on the If you got a chance to try it and report back, it would be appreciated. Super thanks for your really thorough and very helpful investigation! |
Very interesting! I am currently testing with your latest changes. So far so good, but I'll keep testing for a few days before declaring victory :). Sometimes it takes a while for the issue to occur. I am now curious why my network might be losing these timing packets. Looks like they are sent over UDP. I may try to run a packet capture on both ends (client and server) to see if anything unusual happens when these drop outs occur. Netstat does not show any UDP receive buffer errors on my pi... |
We live in hope 🤞. Yeah, they are UDP packets, so it was foolish of me to wait for only one missing packet, TBH. The other thing, of course, is that the packets might not be lost but just delayed by a little more than one second and allowing the three-second timeout to mature. |
Just for fun, I decided to rebuild SPS before your recent fix and get a packet capture of what was happening on the network during the audio drop outs. TLDR: there were two drop out occurrences while I was packet capturing. The first was caused by a misbehaving client, and the second was caused by packets being dropped somewhere in the network. Software versions:
During my packet capture, I got 2 occurrences of the drop out. Note that in my write up here, all timestamps in the logs are in UTC (logs from the pi). But all timestamps in the wireshark screenshots are in ET. So there's a 4 hour time difference. First drop out occurrenceLogs: https://gist.github.com/dasl-/5f3cc790e2dd89ec7f3c5a5a2b85b846#file-gistfile1-txt-L6 Packet capture on client (macbook): We can see at the time of the drop out in the logs, there was a gap of just over 3 seconds in the client sending timing packets. So a "misbehaving" client may have caused this drop out. Packet capture on the server (pi) also sees a gap of over 3 seconds in between timing packets, as expected: Second drop out occurrenceLogs: https://gist.github.com/dasl-/72ad4261d0de30202d035fbcae4292e6#file-gistfile1-txt-L8 This time, let's look at the packet capture on the server (pi) first. Packet capture on the server: We can see at the time of the drop out in the logs, there was a gap of just over 4 seconds in between timing packets, as recorded by the server. Next, let's look at the packet capture on the client (macbook): This time, it appears the cause of the drop out is different: the client appears to have sent a timing packet that the server never received. I guess it got lost in the network somehow. The server does not appear to have any UDP receive buffer errors:
I'm less familiar with the version of
So, the cause of the packets lost in the network remains a mystery... I'm guessing it could easily be wifi though. The client is connected via wifi, and the server is connected via ethernet cable. I'm really happy we seem to have figured out what was going on here! Thank you for investigating! I'll continue running SPS with your recent fixes for a few days and then I'll report back whether everything appears to be fixed :) |
Thanks for the writeup. If I'm not wrong, the first example shows a packet being send a second or so early and then leaving a corresponding gap of over three seconds before the subsequent one -- very interesting. I have learned a lot, thanks. |
I've been having similar issues, and recently discovered that the ethernet power saving features on the rpi4 may be causing my grief: raspberrypi/linux#3292 (comment) I'm going to try this workaround, might be worth a try in your case as well... |
Interesting, I had not heard of the ethernet powersave feature before. On my pi, I see this by default:
After running
Since it originally showed UPDATE: it seems that when my network path is In any case, I just tested by downgrading to before Mike's recent fix for this issue. In particular, I downgraded to building shairport-sync on the development branch at this commit: 3354f66 Here are the exact versions I was running after the downgrade:
I then played some music through SPS for a while, and observed occasional drop outs as expected. Logs from this period: https://gist.github.com/dasl-/194c387bf17711b208e48e9bd326f33b Next, I ran So it seems disabling ethernet powersave did not help. That said, this is not totally unexpected. In my earlier testing, I found that sometimes the drop outs were caused by a "misbehaving client", and other times they were caused by timing packets getting lost somewhere in the network. I think ethernet powersave could potentially explain the latter case, but not the former. So I wouldn't expect turning off ethernet powersave to fully solve this issue. That said, it's also a mystery to me why I didn't notice this issue more when the pi was connected via wifi. A misbehaving client should cause drop outs no matter whether the pi was connected to the network via wifi or ethernet. I believe that Mike's fix has fully solved the issue for me. In fact I was planning to close this issue soon. Did the fix not solve your drop outs? |
Alas, I think my issue is distinct, because it appears to be happening at least with buffered audio streams:
What is particularly strange is that the drop out occurs while playing a song from Apple Music, is repeatable when playing that particular song, and occurs at the same point during the playback of the song. It looks like I'll need to open a separate issue. |
I'm closing this issue as I've not had the drop outs recur in the same manner since Mike's fix: #1515 (comment) |
I've found yet another instance of what I suspect is bugginess when connecting to SPS via an M1 mac (macOS 12.4, MacBook Air M1, 2020). I suspect that this is a bug with the M1 mac, rather than a bug with SPS. As such, I doubt that there is much you can do to address the bug. I'm just posting in case others come across the same issue and my report can be helpful to them.
My setup was: playing music on the Music app of my M1 mac, connected to SPS via the system sound output controls. Because I connected via the system sound output controls, SPS used a realtime audio stream rather than a buffered audio stream. Approximately every 10 minutes, there would be a brief (1-2 second) drop out in the music. The logs would say:
More logs demonstrating this occurring roughly every 10 minutes (sometimes it would also occur outside of the regular 10 minute intervals though):
Another commonality is the sync errors often mention a duration of ~1.7 seconds (although again, this is not always the case).
One strange aspect of this bug was that when I connected my M1 mac in the same manner to a different SPS instance running on another raspberry pi, I could not reproduce the drop outs. If the bug was caused by the M1 mac, I might expect my laptop to have these drop outs no matter which SPS instance it was connected to.
A restart of my M1 mac solved the issue. This was the first time I've observed this particular issue happening, so at least it appears to be a relatively rare issue to encounter.
Software versions:
SPS running on raspberry pi 4. Config file:
The text was updated successfully, but these errors were encountered: