mlx-swift-examples
mlx-swift-examples copied to clipboard
[Enhancement] Run as background app
I'm not sure if there is any change to MLX Swift or the examples to make it happen other than setting the right capability. But just want to open this since it has come up a couple times as a useful feature.
If it's just a setup thing, maybe we can include a short blurb in the MLX Swift or example docs for how one would go about it.
What do you mean by background app? Making a web service, e.g. some kind of LLM service?
Generally you can't run background apps on iOS -- you can, but they are for very specialized reasons like playing music or downloading a file. MacOS supports any kind of non-foreground application.
What do you mean by background app? Making a web service, e.g. some kind of LLM service?
Good question. Its been mentioned in two contexts:
- Training in the background (e.g. if the phone is plugged and idle)
- Using another phone as a service in like a cluster of phones
I guess neither of those is really possible in iOS?
Probably not -- the system has to protect battery, thermals and other resources (memory). There are mechanisms to run in the background but they all have restrictions:
- https://developer.apple.com/documentation/backgroundtasks/choosing-background-strategies-for-your-app
For example, you can ask that heavy work is performed in the background while plugged in, but you don't get to pick when that starts.
You can keep a device from sleeping:
- https://developer.apple.com/documentation/uikit/uiapplication/1623070-isidletimerdisabled
which might work for these cases (forcing foreground).