Search code examples
iosswiftalamofire

Alamofire request stuck on return to foreground?


It appears our Alamofire request gets "stuck" when we have a long running request where the app goes to background and then returns to foreground.

I understood that the request should be paused on background and resumed on foreground. It appears the resume isn't happening.

How should you handle this scenario? Is there some background specific implementation required here?

The request is a standard REST request to load data (with a default 60 second timeout). The case where we get "stuck" is when we have poor network connectivity. With decent network speed our request completes in less than a second.


Solution

  • It turns out I misdiagnosed the issue. The Alamofire request was still running and resuming when brought to foreground. The issue was really our UIRefreshControl got stuck due to a bug in the UIRefreshControl UIKit library. Implemented a workaround for that issue and we were good.