You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 25, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 25, 2023. It is now read-only.
Infinite failing TileJSON requests when app launches in airplane mode #24
If you launch an MBXMapKit app for the first time with airplane mode enabled, it will show an empty map grid and give a steady stream of log messages like this:
2014-01-21 22:53:33.063 MBXMapKit iOS[12416:5503] Error parsing TileJSON for map ID justin.map-pgygbwdm - retrying! (Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (No value.) UserInfo=0x9af85f0 {NSDebugDescription=No value.})
2014-01-21 22:53:33.066 MBXMapKit iOS[12416:1303] Error parsing TileJSON for map ID justin.map-pgygbwdm - retrying! (Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (No value.) UserInfo=0xb8568b0 {NSDebugDescription=No value.})
2014-01-21 22:53:33.069 MBXMapKit iOS[12416:7623] Error parsing TileJSON for map ID justin.map-pgygbwdm - retrying! (Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (No value.) UserInfo=0x1326cef0 {NSDebugDescription=No value.})
This is happening because updateOverlay in MBXMapView includes this stuff:
else
{
NSLog(@"Error parsing TileJSON for map ID %@ - retrying! (%@)", _mapID, parseError);
[weakSelf updateOverlay];
}
}
else
{
NSLog(@"Error downloading TileJSON for map ID %@ - retrying! (%@)", _mapID, error);
[weakSelf updateOverlay];
}
It seems to me that the ideal way to handle this would be to attempt downloading the TileJSON for a map id only one time, and if that fails, there should be a delegate callback to announce the error. That would give the app an opportunity to retry, display an error dialog about network connectivity, etc.
I suppose putting the effort into making that stuff all fancy and automatic might not make sense though, depending on what direction MBXMapKit is headed.
I think the way to address the infinite fail here is to do an exponential backoff for TileJSON requests. This leaves performance up to MBX and end use (detect online/offline, notify user, etc.) to the implementing developer.
One thing we should definitely be doing over here is learning from our if (data) lesson over in #23 and paying more attention to NSURLSession's error object to catch airplane mode or other offline issues directly.
Then, we should combine that with exponential back off. We probably don't have to continue that forever, but we should do a reasonable 2-3 tries, then maybe update the -setMapID: method to take a completion callback argument as well? I'm learning a bit from mapbox/DEPRECATED-mapbox-ios-sdk#397 and friends that we probably should get out of the habit of treating such async network-based setters as atomic operations and should give the developer a chance to respond to potential failures. I could see the user story like this:
-setMapID:... succeeds. Callback lets developer show the ultimate map, or possibly just do nothing and allow it to load per normal.
-setMapID:... fails for some reason. Developer gets callback and for cases when they care, could re-init the map view entirely or hide it or pop an error or what-have-you. The important thing is to not leave them in the dark.
Since I mentioned this last night while working on a proof of concept for #47 I thought I'd chime in here and vote for @wsnook proposal above which, as I understand it is:
Make a request, if it fails notify delegate. As the app developer, I'd rather not have mbxmapkit retrying network requests for me. Just let me know if something went wrong and I'll retry if I think that makes sense.
This will help keep mbxmapkit implementation simple and will help make mbxmapkit more easily testable. Perhaps auto-retry could be added in the future as a feature but it's definitely something I think most app developers would want to opt into and not be forced to use with no control. Even a simple backoff strategy (that I can't control) would be bad, IMO.
Activity
incanus commentedon Jan 22, 2014
Yeah, this needs freshening up for sure. That was built out pretty rough.
incanus commentedon Feb 18, 2014
Yeah, I want to avoid automatic reachability detection as this is well handled by Apple's commonly-used external library and/or things like https://github.com/tonymillion/Reachability
I think the way to address the infinite fail here is to do an exponential backoff for TileJSON requests. This leaves performance up to MBX and end use (detect online/offline, notify user, etc.) to the implementing developer.
incanus commentedon Feb 24, 2014
One thing we should definitely be doing over here is learning from our
if (data)lesson over in #23 and paying more attention toNSURLSession's error object to catch airplane mode or other offline issues directly.Then, we should combine that with exponential back off. We probably don't have to continue that forever, but we should do a reasonable 2-3 tries, then maybe update the
-setMapID:method to take a completion callback argument as well? I'm learning a bit from mapbox/DEPRECATED-mapbox-ios-sdk#397 and friends that we probably should get out of the habit of treating such async network-based setters as atomic operations and should give the developer a chance to respond to potential failures. I could see the user story like this:-setMapID:...succeeds. Callback lets developer show the ultimate map, or possibly just do nothing and allow it to load per normal.-setMapID:...fails for some reason. Developer gets callback and for cases when they care, could re-initthe map view entirely or hide it or pop an error or what-have-you. The important thing is to not leave them in the dark.Thoughts, anyone?
incanus commentedon Feb 27, 2014
Just a note that airplane mode problems are solved, though we still need backoff as described in this ticket.
incanus commentedon Feb 27, 2014
Yes, we basically need to get out of an infinite attempt loop, regardless of why we got there.
boundsj commentedon Feb 27, 2014
Since I mentioned this last night while working on a proof of concept for #47 I thought I'd chime in here and vote for @wsnook proposal above which, as I understand it is:
Make a request, if it fails notify delegate. As the app developer, I'd rather not have mbxmapkit retrying network requests for me. Just let me know if something went wrong and I'll retry if I think that makes sense.
This will help keep mbxmapkit implementation simple and will help make mbxmapkit more easily testable. Perhaps auto-retry could be added in the future as a feature but it's definitely something I think most app developers would want to opt into and not be forced to use with no control. Even a simple backoff strategy (that I can't control) would be bad, IMO.
Thanks!