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.

Discuss API refinements, including caching #73

Closed

Description

Over at issue #61 we considered a refactored design for asynchronously loading TileJSON, and at pull request #71 we discussed my issue61 branch with a new approach to solving problems around the asynchronous TileJSON stuff.

The conclusion from #71 seems to be that the general approach in the issue61 branch is sound, but it needs to be packaged within an API which feels consistent with Apple's API's in general, and MKMapKit in particular. So this ticket is for discussing refinements to the API. One of the big open questions is what the caching will look like.

My plan for the moment is:

I'm guessing this iteration will reach a good stopping point by approximately March 20th (next Thursday).

Activity

  1. ghost added this to the 0.3.0 milestone on Mar 11, 2014
  2. ghost added a commit that references this issue on Mar 12, 2014
  3. ghost added a commit that references this issue on Mar 12, 2014
  4. ghost added a commit that references this issue on Mar 14, 2014
  5. ghost added a commit that references this issue on Mar 14, 2014
  6. ghost added a commit that references this issue on Mar 14, 2014
  7. ghost added a commit that references this issue on Mar 14, 2014
  8. 70 remaining items

  9. ghost added a commit that references this issue on Apr 15, 2014
  10. ghost added a commit that references this issue on Apr 15, 2014
  11. ghost added a commit that references this issue on Apr 18, 2014
  12. ghost added a commit that references this issue on Apr 21, 2014
  13. ghost added a commit that references this issue on Apr 21, 2014
  14. ghost added a commit that references this issue on Apr 21, 2014
  15. incanus commented on Apr 22, 2014

    @incanus
    Contributor

    Handy pre-PR link comparing the issue73 branch against master:

    master...issue73

  16. incanus commented on Apr 22, 2014

    @incanus
    Contributor

    This seems really well thought-out, @wsnook! I can't possibly hope to totally grok 65 commits and 32 changed files with 4,961 additions and 5 deletions just yet, particularly the whole functionality of MBXOfflineMapDownloader and its dual queue system, but here's how I see things proceeding:

    1. We address some more important comments below leading up to / when we voice Tuesday.
    2. We consider some other comments, more as backburner things that we can discuss on GitHub.
    3. We squash these into a new commit or handful of commits and open a pull request for more in-depth review and testing, getting it into master for some testing before release of 0.3.0.

    Main comments (voice)

    • Overall, and I mean this from a general "Mapbox how we do it" angle, it would help in future if you could more clearly highlight how to test the new functionality. I'm able to read through all the source myself and figure it out, but it takes a while and having a nice "run this app and press X button" comment would really help before I dive all in, since I've been away from these for some weeks / never used your example app directly anyway.
    • Related to the above, we need to clean up all the v030 stuff and just make the final proposed-merge branch reflect the state that master should be. In a branch, don't be shy about blowing away our current view controller/sample app/whatever. Branches are cheap and non-permanent.
    • If I'm understanding things properly, MBXOfflineMapDatabase instances, though referenced by the MBXOfflineMapDownloader and used as arguments by the delegate methods and -removeOfflineMapDatabase:, are meant to be opaque, "private" items. We should consider making all the methods and most/all of the properties on MBXOfflineMapDatabase private, with a category inside MBXOfflineMapDownloader / any other class that needs to use them directly. That is to say the "public" should never be calling these methods. As a descendent of NSObject, too, you can throw an exception inside of a declared -init to discourage such direct use. Otherwise, believe me, it's gonna happen / generate support inquiries.
    • Why is the delegate passed in -[MBXRasterTileOverlay initWithOfflineMapDatabase:delegate:]? How is this different from instantiating with a mapID? I'm asking both out of implementation curiosity but also as a future potential confused user of the API.

    Minor comments (online)

    • Properties like these should be more declarative and explain what they are for. metadata says "data structure" to me, not a BOOL value. Similar for markers, which says "image data or GeoJSON", not a boolean value. Probably something like hasMetadata? This is especially confusing when reading code like
      if(metadata)
      {
      [self asyncLoadMetadata];
      }
      else
      {
      _didFinishLoadingMetadata = YES;
      }
      where it's not really obvious what's happening. Does metadata = YES mean that metadata is not loaded?
    • Thinking ahead to how MBXOfflineMapDatabase will be used, could we maybe take -initWithContentsOfFile: one step further as we do over in https://github.com/mapbox/mapbox-ios-sdk/blob/3a1835bc8871dfba53befa20b41bddfdf1f4ca33/MapView/Map/RMMBTilesSource.h#L53-L63. These examples allow the user to specify a bundle resource or even just the first part of the filename (assuming .mbtiles) and the framework does the rest. Similarly, for offline map databases, these are basically always going to be in the app jail and either in the documents folder or the caches folder. I would recommend some default, but changeable, file extension (.mboffline?) perhaps before your .partial/.complete or even nothing appended to .mboffline in place of .complete, and then something like -initWithDatabaseName:inDocuments:, the latter argument being a BOOL defaulting to YES.
    • Related to the above, we should make iCloud backup configurable (
      // Make sure the offline map directory exists and that it will be excluded from iCloud backups
      ) per our discussions in Exclude db cache from iCloud backup, with option to include DEPRECATED-mapbox-ios-sdk#410. Defaulting as you've done but with the ability to change seems like good practice.
    • I like how the user agent for background downloads is differentiated (
      #if TARGET_OS_IPHONE
      userAgent = [NSString stringWithFormat:@"MBXMapKit (%@/%@) -- offline map", [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion]];
      #else
      userAgent = [NSString stringWithFormat:@"MBXMapKit (OS X/%@) -- offline map", [[NSProcessInfo processInfo] operatingSystemVersionString]];
      #endif
      ) but we should allow customization there, as well as setting it in one place for all uses of the SDK to avoid code duplication. The iOS SDK has a good model for this now in https://github.com/mapbox/mapbox-ios-sdk/blob/3a1835bc8871dfba53befa20b41bddfdf1f4ca33/MapView/Map/RMConfiguration.h#L52. It's just crazy simple there, as it should be.
    • Inside of -completeDatabaseAndInstantiateOfflineMapWithError: the idea of moving a file from a background thread (albeit supposedly a single-concurrency one) is kind of gross to me. Maybe an assert or dispatch_sync() to main queue there? Just something that ensures that the -setMaxConcurrentOperationCount:1 has happened elsewhere rather than implicitly linking these by intent, which will eventually be lost to the sands of time.
    • Why isn't -[MBXOfflineMapDownloader delegate] a property as is custom? Why is this write-only? That's weird for a delegate.
  17. ghost closed this as completedon Apr 22, 2014
  18. ghost added a commit that references this issue on May 18, 2014
    ca269a0
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