I got an interesting bug report today from folks running a utility I ported to Juce on iOS today. A little testing found a related issue on Android.
The utility does a bunch of network interaction with external hardware/software. On iOS, when you press the Home button and an app goes in the background, it stops cold, but sockets remain open. So the app leaves the other ends of the connections tied up, waiting for inactivity timeouts, which is badly behaved.
On Android, the socket thread keeps running (until resources run low and it is abruptly killed, but this isn’t really user expectation. When the app can’t be seen, it shouldn’t be tying up the resources and killing the battery life.
So I added delegates for appDidEnterBackground (iOS), onPause (Android), WM_POWERBROADCAST (Windows), etc., and extended the application class to include suspend and resume methods that can be overridden in my app.
That was the quickest way to resolve the issue, but it struck me that this has probably come up before. Is there another mechanism that I have missed? I see a Process class, but it wasn’t clear to me how it would be used, and the plumbing didn’t seem to be there to get the information from the underlying platforms.
Thanks in advance!