iOS - How to suspend Unity internal threads while application is in background

I’m developing an application that needs to run in background, it uses unity engine only when running in foreground, when application enters background mode the unity engine is paused calling UnityPause(true) but seems that there are some internal threads that are still running and draining a lot of battery.

Is there any way to suspend unity internal threads from objective-c code?

FMOD thread is put to sleep for 10 milliseconds quite often generating too many sleep/wake cycles,sometimes causing this crash:
Exception Type: EXC_RESOURCE
Exception Subtype: WAKEUPS
Exception Message: (Limit 150/sec) Observed 187/sec over 300 secs

The workaround for this is to kill the audio session when the application goes in background.
UnitySetAudioSessionActive(false)

I’ve tested this with 5.1.3p1 and the latest 5.2 beta and, and couldn’t find any threads that were still running while the app was background in Instruments. So it might be something specific to your project. Could you create a bug report for this and attach your project (or a stripped version) to it ?

I submitted a bug report and attached a test project that can be used to investigate this issue,note that we are using unity 4.6.7f1.
2265972--151714--Screen Shot 2015-08-25 at 3.23.15 PM.png

Could send me the bug id (the one you received in the email) or just post it here?

I didn’t receive the email.

ah, ok, sometimes it takes a while for system to process it, but it shouldn’t take more than an hour.

I have not received that email yet, did you managed to find my bug report?

Yes, I’ve just found you bug report, not really sure why you didn’t receive a confirmation, though.

We’ll keep you updated on our progress.

This seems to be caused by Input.location.Start, it’s not automatically turned off when the app is move to background, if it’s turned off in settings or the app doesn’t have the necessary permission only ‘usleep’ is called.

Probably the best to solve this is to call Input.location.Stop() in an OnApplicationPause() function. But this means that, you’ll have to restart LocationService when going back from background which might cause a delay.

Turning off location will cause application to be suspended by the iOS, it won’t run until the user reopen it. I need to keep the application running even when minimized to make accelerometer data acquisition.
Please see this: