Very slow response for network listener in background

We have a production app built on Catalyst. Many user reports have been received that a network listener for local network events related to our app is extremely slow when our app is not in the foreground. User reports indicate a delay of as many as 13 seconds can occur between the time a network event occurs and the time the app receives the packet.


This has been exceptionally hard to reproduce. I believe it has something to do with the system deciding to put that app into a less active state when the app is not foreground. Our background capabilities are just Background Fetch and Remote Notifications.


Simply putting the app into the background is not sufficient to reproduce. There are other unknown factors. We presume they are system related such as the amount of CPU load the system is under, number of other apps, etc. Basically, the system at some point decides to demote us and then we become unusable with massive 13 second response delays.


On iOS, that is completely reasonable because our app is not visible. On macOS, it is completely absurd because our app is plainly visible and effectively broken.


Is this a known issue with Catalyst? What would be the best workaround? At the moment, I've only been coming up with what are essentially hacks like telling macOS that we are playing audio, or doing something like that to ensure consistent background time. But that seems like a huge OS bug that there must be a better way to handle.

Very slow response for network listener in background
 
 
Q