mlx-swift-examples icon indicating copy to clipboard operation
mlx-swift-examples copied to clipboard

[Enhancement] Run as background app

Open awni opened this issue 1 year ago • 3 comments

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.

awni avatar Jun 15 '24 13:06 awni

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.

davidkoski avatar Jun 15 '24 21:06 davidkoski

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?

awni avatar Jun 16 '24 12:06 awni

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).

davidkoski avatar Jun 16 '24 14:06 davidkoski