AppIntents Shortcut Parameter Processing
I’ve been trying to hunt down a bug with audio playback stuttering on iOS 16.3, after 3 days I think I may have tracked it down to App Intents of all things.
Portal 3.7 switched over to the new App Intents framework when running on iOS 16. This allows for pre-prepared Siri Shortcuts which are a really nice addition. In order for Siri to create these Shortcuts and keep them in sync you need to call
updateAppShortcutParameters whenever your list of
AppEntity records changes.
updateAppShortcutParameters whenever a customer adds or removes a portal. Unfortunately the Apple docs contain no info at all about this functions behaviour so who knows what is supposed to happen. But from what I can see the call returns immediately to the callee, then, still inside your App process, it loops through and injests all your App Entities. This includes re-cloning the images provided for every
AppEntity you have. If you have a collection of 20 Entities all with images this process seems to take as long as 20 seconds to complete in my testing.
So now we have an issue where there is a bunch of background work going on in our process that can run for a while and we have no idea when it’s complete. The side-effect of this is that in certain situations we end up calling
updateAppShortcutParameters too regularly and these background tasks compound causing jitter elsewhere in the App.
I don’thave a great solution to this but currently we have settled on limiting calls to
updateAppShortcutParameters to only cases where we know data has 100% changed and throttling calls to no more than once a minute to try and avoid tasks stacking up. Ideally we’d love it if Apple could make
updateAppShortcutParameters an async call that could block until completion, that way we could manage scheduling and queuing ourselves.
The fix should be available in Portal 3.7.4 and I’m really hoping this fixes the audio issues for those that have reported it.