DEPRECATED-mapbox-ios-sdk icon indicating copy to clipboard operation
DEPRECATED-mapbox-ios-sdk copied to clipboard

Background downloads request getting deallocated

Open hasanadil opened this issue 10 years ago • 4 comments

Hi, Successive calls to RMTileCache.beginBackgroundCacheForTileSource cause previous download calls to be not completed, if they were in the process of being download.

I suspect this is because the current operation queue is deallocated upon new allocation in each call to the method, and thus the operations retained in it are also deallocated.

  • (void)beginBackgroundCacheForTileSource:(id <RMTileSource>)tileSource southWest:(CLLocationCoordinate2D)southWest northEast:(CLLocationCoordinate2D)northEast minZoom:(float)minZoom maxZoom:(float)maxZoom { ... (262) _backgroundFetchQueue = [[NSOperationQueue alloc] init]; ... }

Maybe its better to create the queue in the initWithExpiryPeriod method of RMTileCache. Thanks

hasanadil avatar Jun 22 '14 20:06 hasanadil

The background queue property is assigned to a new NSOperationQueue, yes, but due to ARC this will release the old one. Previous download calls aren't cancelable anyway and should be retained by their queue, but not vice-versa — operations don't retain their queue. So I'm not sure what you see as a good solution here @hasanadil.

incanus avatar Aug 27 '14 00:08 incanus

Also, if -[RMTileCache beginBackgroundCacheForTileSource:] is called while another is running, a new one isn't activated.

incanus avatar Aug 27 '14 00:08 incanus

Hi, How about a shared operation queue that is used by successive calls for tile caching.

hasanadil avatar Aug 27 '14 16:08 hasanadil

In order for it to be shared, it would have to exist outside of an individual RMTileCache, which starts to get unwieldy. Maybe a singleton could work, but future tile caches would have to be created before previous ones were ever released and this would have to be enforced or else we'd just get back to the same problem.

incanus avatar Aug 27 '14 19:08 incanus