model.GetPrediction method returns a null object when the iOS app is running in background mode. The method return correct predictions when app is in foreground. Has anyone else come across this issue?
Couple of things:
You have very limited time to execute arbitrary code when the app is Backgrounded
.
BackgroundTimeRemaining
to determine how much time you have left.BeginBackgroundTask
actionThe foregrounded app (including Springboard) has priority over the GPU.
The foregrounded app GPU processing will not be interrupted to perform your background task-based prediction.
You can request predictions to use the CPU (UsesCpuOnly
) by supplying the MLPredictionOptions
to your prediction call.
Your model should be restricted to the CPU if it might run in the background or if your app has other GPU intensive tasks.