Open ysaliens opened 6 years ago
While bugs are a possibility, the "catch up" is mainly Android deprioritizing the app, buffering its network requests, and then dispatching them all at once. Linux doesn't have any sense of "real-time UDP" (or for that matter, real-time anything), and understandably, the system prefers to buffer small packets. Early on, it was a major issue preventing anything close to a synchronized show.
The app stopping after a while seems to be an Android 8.0 issue. Oreo got a lot more aggressive about battery protection, and so running a service has become a little more challenging. I think the actual problem is the connection between Spotify and Music Blitz is what's stopped; Music Blitz relies on getting broadcast messages from Spotify for play/pause events, so if the system decides that message receiver isn't relevant any longer, then Music Blitz stops.
This is an even bigger problem when playing Spotify on a different device. Android will continue to dispatch the broadcasts for a while, but then I think the Spotify service that's handling it gets cut off.
In short, there are a lot of variables, and not a real way to debug it. I haven't necessarily found a deterministic set of conditions to predict when it'll stop getting notifications.
My main hope is to develop in a direction to remove the Spotify dependence all together. There's a lot of great data that they make available, but it limits the app in these other directions.
Yup, I feared that's the case.
There might be a way to coax Android 8.0 into allowing the service as a high priority even with the screen off, I know several other apps have done that. It requires you to keep a notification that's happening (or manually allow the app under settings to not be battery-optimized) but it might work. Worth looking into. Is the service currently being ran as a foreground service?
The lights service itself (which handles dispatching messages to the bulbs) is started (in Oreo) with startForegroundService
and uses a persistent notification. But this is called from the broadcast receiver that picks up the messages from Spotify. I need to set up this receiver within a service started in the foreground to ensure it doesn't get killed. I think that would fix the issue.
Stock Android 8.0 - App works great but over time always dies / stops changing colors. On occasion I also get "rubberbanding"....lights stop changing for a few seconds and then all of a sudden "catch up", flashing all the transitions they would have.
I suspect Android may be trying to kill the service (or there may be a bug somewhere) or heck maybe network but my lights are in the same room as the router and it's a nice router.