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 Jun 14, 2024. It is now read-only.
In OfflinePackExample.swift, when downloading an offline pack there is a test to determine whether the Completed Resources is equal to the Expected Resources.
The test that determines download complete fires more than once, and I'm looking for suggestions on how to improve handling this.
Idea # 1: Add an instance variable, allDownloaded or whatever, in the class OfflinePackExample_Swift that tracks the first time that completedResources == expectedResources, and never enter that clause again.
Or, a fix on the Mapbox GL native side of the code
Fixes need to be added to ObjC sample as well
File this issue under improve existing examples.
Goal of this issue is to request an update to the Mapbox Examples code
In practice, we want to use the state that all expected resources have downloaded, and update a user interface. In our app, the test for completedResources == expectedResources is true more than twice.
This issue occurs when downloading from the following apps:
The app in this repo, Examples, using iOS SDK 6.2.1 and creating an offline pack from Mapbox dark style
Our app, using iOS SDK 5.6.1 and our custom style
Log from Examples, where the completed state is logged twice.
Offline pack “My Offline Pack” has 4 of 545 resources — 0.73%.
Offline pack “My Offline Pack” has 69 of 545 resources — 12.66%.
... <snip a bunch>
Offline pack “My Offline Pack” has 544 of 545 resources — 99.82%.
Offline pack “My Offline Pack” completed: 7 MB, 545 resources
Offline pack “My Offline Pack” completed: 7 MB, 545 resources
Our Apps' offline packs support downloading non-contiguous grids. In our case, our UI reports that 4 out of 2 grids have been downloaded.
The text was updated successfully, but these errors were encountered:
@roblabs, thank you for providing this feedback. I'm still looking into why completedResources == expectedResources is called twice, however, in the meantime, you can replace this with pack.state == .completed, which will only be called once.
@ZiZasaurus — thank you for the tip on handling status via pack.state. I tried your suggestion, but I am still seeing the complete state report being reported more than once. I think the proper fix in our case would be to:
check for pack.state == MGLOfflinePackStateComplete
exit out of the method offlinePackProgressDidChange()
by an instance variable in the class or some other structure to track
Log after deleting app and restarting (on simulator)
// If this pack has finished, print its size and resource count.
if pack.state ==.complete {letbyteCount=ByteCountFormatter.string(fromByteCount:Int64(pack.progress.countOfBytesCompleted), countStyle:ByteCountFormatter.CountStyle.memory)print("Offline pack “\(userInfo["name"]??"unknown")” completed: \(byteCount), \(completedResources) resources")}
Objective-C Change
// If this pack has finished, print its size and resource count.if (pack.state == MGLOfflinePackStateComplete) {
NSString *byteCount = [NSByteCountFormatterstringFromByteCount:progress.countOfBytesCompleted countStyle:NSByteCountFormatterCountStyleMemory];
NSLog(@"Offline pack “%@” completed: %@, %llu resources", userInfo[@"name"], byteCount, completedResources);
}
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In
OfflinePackExample.swift
, when downloading an offline pack there is a test to determine whether the Completed Resources is equal to the Expected Resources.The test that determines download complete fires more than once, and I'm looking for suggestions on how to improve handling this.
allDownloaded
or whatever, in the classOfflinePackExample_Swift
that tracks the first time thatcompletedResources == expectedResources
, and never enter that clause again.https://github.com/mapbox/ios-sdk-examples/blob/5fff10393e0d48f0fdc2b98e1b0be199feb8e017/Examples/Swift/OfflinePackExample.swift#L101,L103
In practice, we want to use the state that all expected resources have downloaded, and update a user interface. In our app, the test for
completedResources == expectedResources
is true more than twice.This issue occurs when downloading from the following apps:
Log from Examples, where the
completed
state is logged twice.Our Apps' offline packs support downloading non-contiguous grids. In our case, our UI reports that 4 out of 2 grids have been downloaded.
The text was updated successfully, but these errors were encountered: