iOS18 AudioPlaybackIntent respond too slow when app not launched

here's my case, i develop a control widget, user can push a controlwidget to play music without open the app. i bind a AudioPlaybackIntent to the widget. when user click the widget, the app will receive the intent and start to play music.
it works perfect when app running in background or foreground. but when app not launched, the respond is too slow, it takes several seconds to start play music.

is there any way to make the respond faster when app not launched? if i want to do something when app not launched, what should i do?

Answered by DTS Engineer in 799538022

Have you looked at analyzing your app's launch speed, and removing any bottlenecks, even outside of an intent invocation? Instruments will capture all of the work that happens at launch in a Time Profiler trace. The work you do to optimize your app launch time will then pay benefits when you are launched through an intent.

We have a lot of supporting resources for this subject. Here's two starting points:

—Ed Ford,  DTS Engineer

Have you looked at analyzing your app's launch speed, and removing any bottlenecks, even outside of an intent invocation? Instruments will capture all of the work that happens at launch in a Time Profiler trace. The work you do to optimize your app launch time will then pay benefits when you are launched through an intent.

We have a lot of supporting resources for this subject. Here's two starting points:

—Ed Ford,  DTS Engineer

I've added the intent to both the Extension and the App. When debugging, I set a breakpoint in the App's perform method, and there is a significant delay before this breakpoint is hit [...]

Where is the intent running, in an extension process or in the app process? If it's in the app process, you can profile with Instruments. If it's in an extension, then that's a bit harder.

Aside from profiling with Instruments, which I still recommend you do, another plan of attack you can use here is to create a test app whose setup is modeled after your real setup, but does no real work. By this, I mean the project has only a minimal amount of code to construction your app intent, and return successfully, in exactly the same way as your real app, without actually starting media playback. This means you'll have a baseline of what the system is capable of, with the rest of your code is ruled out, as well as any dependencies you're importing. How fast is this scenario, and what's the difference from your real app?

I suspect the issue lies with AudioPlaybackIntent. I tried switching to AppIntent,

I don't follow. AudioPlaybackIntent is an AppIntent through protocol conformance. Can you clarify what you mean?

—Ed Ford,  DTS Engineer

iOS18 AudioPlaybackIntent respond too slow when app not launched
 
 
Q