Animation frames get occasionally skipped
Hi! I'm currently experiencing an issue that I assume/believe to be something caused by the nature of wifi and what I'm trying to do.
I'm looking to animate some LEDs to music, and the first thing I've been trying is using line splits for bass kicks. However, I've noticed occasionally frames of the animation will get skipped, which looks quite strange:
https://www.youtube.com/watch?v=N_tu01dyCso
I assume this happens when a packet arrives late, and due to how quick the animations are it is very noticeable.
I'm not really sure how fixable something like this is, but I figured I would create a Github issue about it just in case :)
Hi again!
Hmm yeah, that does look a bit janky 😔 There's nowhere for packet loss to hide in an animation like that, as you said.
There are a bunch of different factors at play here, it can be a pain to debug.
Router I've found that some routers play nicer than others when it comes to UDP streaming. I use a dedicated router for my xmas display, so that other traffic isn't going to cause any issues. Bit of a weird setup, but my Mac Mini is plugged into my Sparkled-specific router via cable, and to my regular home network via Wi-Fi (so I can remote in without changing networks).
ESP board I suspect different ESP boards are of differing quality, especially if you get them on the cheap from eBay like I do. All of mine seem to handle Sparkled quite well (the occasional hitch due to the nature of Wi-Fi, but generally fine), but my friend had a lot of trouble getting a workable connection out of his.
Signal Distance between the ESP32/8266 and your router can make a huge difference too, they don't have the strongest antenna and network quality can degrade if there's a wall in the way etc. Try sitting it as close to your router as you can.
If you have your PC connected to the router via Wi-Fi, then you could try running a cable to see if that improves the performance at all. Packet loss could potentially be between the PC and router, a cable should rule that out.
Errors
On the Sparkled side, check sparkled.log to make sure there aren't any errors. If an exception is being thrown for every frame sent out (hopefully not!), I could see that slowing things down quite a bit.
Framerate You could try creating a sequence with a lower framerate (e.g. 15) and see if it runs smoother. I think I exposed the framerate as an option when you create sequences, if not let me know.
Compression (future) I plan to implement data compression at some point. Currently 3 RGB bytes are sent out per pixel, but there are heuristics like "every pixel is the same colour", "there 4 or less distinct colours" etc. that can be used to send way less data. That will require work on the backend and the ESP clients, so unlikely to happen before Christmas unless I find some more time :)
Let me know if any of the above helps, or even if not. Good luck!
Thank you for the detailed reply! I'll look more into some of these this weekend.
Router - This'll be interesting as I hadn't really thought of how my setup will work out in the end. I plan on setting up some outdoor LED strips around all the windows on my house, and closing the windows on the wire to keep the ESP boards inside. The issue is the wifi get's pretty weak the further you get from the router, so what I may end up doing is setting up multiple routers on their own network. (I was expecting to have to spend a somewhat decent amount on this project but I didn't think I'd be buying routers lol!)
ESP Board - I may end up trying a few others. I bought a pack of 3 off of Amazon, but idk how to determine if that's the issue or not.
Signal - The current setup is far from ideal now that I think about it. I'm just doing tests at the moment, but the ESPs and the computer running Sparkled are by me, and the router is on the other side of the room lol. This is one of the thing's I'll likely test this weekend.
Errors - We're good there
Framerate - I'll also mess with over the weekend as well :)
For my setup, I bought a second hand TP-Link router for $30, no need to break the bank!
I just have the one router running Sparkled, but it sits outside in a waterproofed container so that it's close to all of the ESPs.
My ESPs are also in little waterproofed enclosures, which are a pain to make but let me sit them right near the LED strips outside.
Hmm, that may be the better option for me. I might still need two routers just to maximize coverage, but at least then it's a single Ethernet between the routers rather than snaking one through my house :) I wouldn't be surprised if one router does the job though, it's not an insane distance I just want to make sure the ESPs are as close as possible to the router. I'll do some testing when I get a chance and see what works best. Thanks!