Description
When the AI menu text detection is running and the user leaves the app (switches to another app or goes to home screen), the detection process fails or stops.
Current Behavior
- User triggers AI menu detection (via the ✨ AI Generate button)
- A full-screen loading overlay is shown with progress logs
- If the user switches away from the app (e.g., press home, switch to another app), the network request / SSE stream is interrupted and the detection fails
Expected Behavior
- The AI detection process should continue running in the background even when the user leaves the app
- When the user returns, they should see the result (success or failure)
Technical Context
The detection is implemented as a Swift Task in MenuTextDetectionButtonComponent that calls a Gradio API endpoint and listens to an SSE stream for results (MenuTextDetectionService.swift). When the app enters background, iOS may suspend the URLSession tasks.
Possible approaches:
- Use
BGProcessingTask or BGAppRefreshTask for background execution
- Use a background
URLSession configuration (URLSessionConfiguration.background) so the OS manages the download
- Request extended background execution time with
beginBackgroundTask(expirationHandler:)
Description
When the AI menu text detection is running and the user leaves the app (switches to another app or goes to home screen), the detection process fails or stops.
Current Behavior
Expected Behavior
Technical Context
The detection is implemented as a Swift
TaskinMenuTextDetectionButtonComponentthat calls a Gradio API endpoint and listens to an SSE stream for results (MenuTextDetectionService.swift). When the app enters background, iOS may suspend theURLSessiontasks.Possible approaches:
BGProcessingTaskorBGAppRefreshTaskfor background executionURLSessionconfiguration (URLSessionConfiguration.background) so the OS manages the downloadbeginBackgroundTask(expirationHandler:)