Skip to content
This repository was archived by the owner on Aug 25, 2023. It is now read-only.
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

Closed

Description

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.

Activity

  1. incanus commented on Jan 22, 2014

    @incanus
    Contributor

    Yeah, this needs freshening up for sure. That was built out pretty rough.

  2. incanus commented on Feb 18, 2014

    @incanus
    Contributor

    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.

    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.

  3. added this to the 0.3.0 milestone on Feb 21, 2014
  4. incanus commented on Feb 24, 2014

    @incanus
    Contributor

    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.

    Thoughts, anyone?

  5. incanus commented on Feb 27, 2014

    @incanus
    Contributor

    Just a note that airplane mode problems are solved, though we still need backoff as described in this ticket.

  6. incanus commented on Feb 27, 2014

    @incanus
    Contributor

    Yes, we basically need to get out of an infinite attempt loop, regardless of why we got there.

  7. boundsj commented on Feb 27, 2014

    @boundsj

    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!

  8. ghost closed this as completedon Mar 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions