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.
This issue is for discussing what needs to be done to polish the pile of commits from #73 into shape for merging into master. The changes implement a substantially revised API for MBXMapKit, including performance caching and offline maps. The offline maps part just recently hit the point of functionality, and now it needs some polish.
A couple notes:
I created the mapbox/issue79 branch which squashes all the commits from the issue73 branch.
Track down and fix any glitches with the sample app (in particular, check state transitions for offline maps)
Move the v030 iOS sample app to replace the old sample app
Figure out what to do about OS X support and the OS X sample app (see cut OS X support #78)
Revise the readme including a conceptual overview of how the new API works and how it's meant to be used. See How Does Carmen Work?
Write something up about how to use the sample app to demo and test the API. Perhaps this belongs in the readme, or perhaps it should go elsewhere
De-cruft the code and the API: check for orphaned code, unnecessary stuff in header files, anything that's likely to cause confusion about proper usage, etc.
Implement an option to enable iCloud backups for offline maps (the default is to disable backups)
MBXRasterTileOverlay's delegate property is weird. Make it normal.
MBXOfflineMapDownloader's delegate property is weird. Make it normal.
Make sure alloc/dealloc is solid for offline tile blob data coming from sqlite!
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:
We address some more important comments below leading up to / when we voice Tuesday.
We consider some other comments, more as backburner things that we can discuss on GitHub.
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
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 (
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.
ghost added a commit that references this issue on Apr 23, 2014
#79 Previous markers/metadata commit was broken. Fixed it.
I am open to suggestions about how and where to draw the lines about attempting to enforce Java style public/private/protected stuff which isn't supported in the same way by objective c.
You could always try this, which is a compiler hint, but still:
I'm open to alternate approaches which account for the let's-not-crash-the-app concern.
The code smell for me here is that setting/unsetting or having/not having a delegate shouldn't 1) be required or 2) cause any sort of instability. Even if delegate methods are marked @required, a delegate is an opt-in sort of "notify me" construct. Contrast with UITableViewDataSource, which is 1) required and 2) still allowed to be set after instantiation, though in the same pass of the run loop.
could we maybe take -initWithContentsOfFile: one step further
Disregard this -- you are right in that a user should only be able to obtain an offline database through the methods, not by name.
Attempting to make something for moving offline map databases between devices using iCloud seems like it would quickly run afoul of both Apple's storage guidelines
I can see and have seen cases where offline downloads will be considered "documents" that a user possibly paid for the rights to download and thus should be backed up, even if they could re-download them in future. It's up to the dev to argue this point with Apple, but we want to technically accommodate them, IMHO.
Re: the GCD/operation queue stuff, don't worry about it. It was just a suggestion for a check on the developer, but based on our voice yesterday I think there's enough of this going on that if we ensure it works as a whole we don't have to get to these sorts of fine details.
ghost added a commit that references this issue on Apr 23, 2014
#79 Private API using categories on MBXOfflineMapDatabase
NSException* myException = [NSExceptionexceptionWithName:@"FileNotFoundException"reason:@"File Not Found on System"userInfo:nil];
@throw myException;
// [myException raise]; /* equivalent to above directive */
Pretty sure iCloud backups are device-specific. The only way to restore is to to wipe a device and apply a backup set, so effectively I think this is kosher. It could be another device, but I doubt anyone's doing this for fun or profit.
ghost added a commit that references this issue on Apr 23, 2014
I am facing the issue in my app, when the user come instant online we got the following assertion error,
This is random behaviour, Please guide me how can i resolve this issue.
Console message:
Assertion failed: (_activeDataSessionTasks > 0), function -[MBXOfflineMapDownloader sqliteSaveDownloadedData:forURL:], file /Users/vinod/VINOD/RAW/PROJECTS/AGRALOGICS/SOURCE_CODE/agls-grower-app-ios/Agralogic/ThirdParty/MBXMapKit/MBXOfflineMapDownloader.m, line 442.
@vinod1988 It sounds like you might be trying to begin an offline map download without checking whether there is currently one in progress. Are you maybe kicking off a download resume yourself, when the library is also doing this automatically?
Activity
#79 Clearer property names for including markers & metadata
incanus commentedon Apr 23, 2014
Carryover of comment from #73
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
MBXOfflineMapDownloaderand its dual queue system, but here's how I see things proceeding:masterfor some testing before release of0.3.0.Main comments (voice)
v030stuff and just make the final proposed-merge branch reflect the state thatmastershould be. In a branch, don't be shy about blowing away our current view controller/sample app/whatever. Branches are cheap and non-permanent.MBXOfflineMapDatabaseinstances, though referenced by theMBXOfflineMapDownloaderand 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 onMBXOfflineMapDatabaseprivate, with a category insideMBXOfflineMapDownloader/ any other class that needs to use them directly. That is to say the "public" should never be calling these methods. As a descendent ofNSObject, too, you can throw an exception inside of a declared-initto discourage such direct use. Otherwise, believe me, it's gonna happen / generate support inquiries.-[MBXRasterTileOverlay initWithOfflineMapDatabase:delegate:]? How is this different from instantiating with amapID? I'm asking both out of implementation curiosity but also as a future potential confused user of the API.Minor comments (online)
metadatasays "data structure" to me, not aBOOLvalue. Similar formarkers, which says "image data or GeoJSON", not a boolean value. Probably something likehasMetadata? This is especially confusing when reading code likembxmapkit/v030/MBXRasterTileOverlay.m
Lines 208 to 215 in 7ca0eca
metadata = YESmean that metadata is not loaded?MBXOfflineMapDatabasewill 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/.completeor even nothing appended to.mbofflinein place of.complete, and then something like-initWithDatabaseName:inDocuments:, the latter argument being aBOOLdefaulting toYES.mbxmapkit/v030/MBXOfflineMapDownloader.m
Line 80 in 7ca0eca
mbxmapkit/v030/MBXOfflineMapDownloader.m
Lines 163 to 167 in 7ca0eca
-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 ordispatch_sync()to main queue there? Just something that ensures that the-setMaxConcurrentOperationCount:1has happened elsewhere rather than implicitly linking these by intent, which will eventually be lost to the sands of time.-[MBXOfflineMapDownloader delegate]a property as is custom? Why is this write-only? That's weird for a delegate.#79 Previous markers/metadata commit was broken. Fixed it.
incanus commentedon Apr 23, 2014
You could always try this, which is a compiler hint, but still:
http://www.nscrypto.com/blog/2013/05/14/at-private-instance-variables-in-objective-c/
The code smell for me here is that setting/unsetting or having/not having a delegate shouldn't 1) be required or 2) cause any sort of instability. Even if delegate methods are marked
@required, a delegate is an opt-in sort of "notify me" construct. Contrast withUITableViewDataSource, which is 1) required and 2) still allowed to be set after instantiation, though in the same pass of the run loop.Disregard this -- you are right in that a user should only be able to obtain an offline database through the methods, not by name.
I can see and have seen cases where offline downloads will be considered "documents" that a user possibly paid for the rights to download and thus should be backed up, even if they could re-download them in future. It's up to the dev to argue this point with Apple, but we want to technically accommodate them, IMHO.
Re: the GCD/operation queue stuff, don't worry about it. It was just a suggestion for a check on the developer, but based on our voice yesterday I think there's enough of this going on that if we ensure it works as a whole we don't have to get to these sorts of fine details.
#79 Private API using categories on MBXOfflineMapDatabase
incanus commentedon Apr 23, 2014
That's pretty good, but you could just as soon do (from https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Exceptions/Tasks/RaisingExceptions.html):
incanus commentedon Apr 23, 2014
Pretty sure iCloud backups are device-specific. The only way to restore is to to wipe a device and apply a backup set, so effectively I think this is kosher. It could be another device, but I doubt anyone's doing this for fun or profit.
#79 Fixed the suspend/resume/cancel glitching
12 remaining items
#79 Massive revision of README
#79 More README edits
#79 Yet more README edits
#79 Even more README edits
#79 Another round of README edits
#79 README: conceptual overview, spelling
#79 #65 attribution property and alert dialog
#79 README: guide to sample ap
#79 fix markdown glitch
incanus commentedon May 1, 2014
#81 merged.
vinod1988 commentedon Feb 18, 2015
Hi mapbox team,
I am facing the issue in my app, when the user come instant online we got the following assertion error,
This is random behaviour, Please guide me how can i resolve this issue.
Console message:
Assertion failed: (_activeDataSessionTasks > 0), function -[MBXOfflineMapDownloader sqliteSaveDownloadedData:forURL:], file /Users/vinod/VINOD/RAW/PROJECTS/AGRALOGICS/SOURCE_CODE/agls-grower-app-ios/Agralogic/ThirdParty/MBXMapKit/MBXOfflineMapDownloader.m, line 442.
Mapbox library assertion break:
#pragma mark - Implementation: sqlite stuff
{
assert(![NSThread isMainThread]);
assert(_activeDataSessionTasks > 0);
Class name: MBXOfflineMapDownloader.
Please help me
Thanks in advance
incanus commentedon Feb 18, 2015
@vinod1988 It sounds like you might be trying to begin an offline map download without checking whether there is currently one in progress. Are you maybe kicking off a download resume yourself, when the library is also doing this automatically?