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 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Cancel Save Of Offline Map In Android Not Working #4229
However when this is called the downloading continues on as evidence by using log statements within the onStatusChanged() method of the OfflineRegion.OfflineRegionObserver()
However when this is called the downloading continues on as evidence by using log statements within the onStatusChanged() method of the OfflineRegion.OfflineRegionObserver()
This doesn't necessarily indicate an issue. offlineRegion.setDownloadState is not synchronous; the stop request has to be posted to the offline thread's queue.
Is it actually never stopping, or is it just not stopping immediately?
I’ll double-check what I’ve got going in #4221, but currently, setting the download state to inactive in the iOS SDK doesn’t ever stop the download and in fact queues up a complete re-download of the region. mbgl::OfflineRegionObserver::statusChanged() always gets called with an mbgl::OfflineRegionStatus::downloadState of Inactive even when the download is active.
In the case where all the resources are actually already in the database, I'm not sure we're going to be able to fix the observed behavior of "going to 100% without stopping". The TLDR reason is: we don't have a mechanism for thread messages to preempt previously-queued messages.
Longer explanation: when OfflineDownload is activated, the tasks needed to figure which resources are already in the database are queued on the offline thread task queue. That task queue is FIFO: there isn't a way for a task to "preempt" a previously-queued task. Deactivating a download involves posting another task on that queue, but that task will be processed after all previous tasks, including the tasks which check for resources that are already complete. So if it turns out that every resource is already in the database, the observer will get a status notifications each of them, and then the "deactivate download" task will run -- but the download will already be complete.
There is a bug relating to how the downloadState member of the status is reported, which #4233 fixes. I'll merge that.
1299353 adds the ability to stop an in-progress download to the command-line offline test binary, and it works as expected when resources aren't already in the database.
@jfirebaugh Thanks for the insight into how Core GL is actually doing the processing. That makes much more sense now. It looks like #4233 made it in to master last night so today's SNAPSHOT should have it. I'll test it out to see what impact it has and report back.
I just ran a local test using today's SNAPSHOT (Number 41) and confirmed that the Cancel process now works as described above (adding a cancel job to the regular work queue). To be clear, the downloading continue on for a few seconds (as evidence by the logs) but it did eventually stop short of completing. In my test I set the "Cancel" flag when it was at 3% of download and it eventually stopped when it had reached 30%. This tells me that it did "work" but that Cancel is very much going to be a YMMV situation depending on the region selected and when the Cancel flag is set. It's very possible to have situations where the Cancel is requested "too late" and that the downloading will complete before the Cancel job can go into effect.
Next steps are for @1ec5 to verify that he's seeing this too on iOS now. After that we can discuss (if need be) whether or not this is will be acceptable functionality for the first release.
Yes, now canceling eventually works on iOS. When downloading a tile pyramid that largely overlaps with another tile pyramid, the download still races most of the way to completion (probably for the overlapping resources) but does eventually stop. I also see that the expected resource count is now marked as imprecise initially, which is great to see.
Activity
jfirebaugh commentedon Mar 7, 2016
This doesn't necessarily indicate an issue.
offlineRegion.setDownloadStateis not synchronous; the stop request has to be posted to the offline thread's queue.Is it actually never stopping, or is it just not stopping immediately?
bleege commentedon Mar 7, 2016
It is actually never stopping until 100% is achieved and
OfflineRegionStatus.isCompleted()returns true.1ec5 commentedon Mar 7, 2016
I’ll double-check what I’ve got going in #4221, but currently, setting the download state to inactive in the iOS SDK doesn’t ever stop the download and in fact queues up a complete re-download of the region.
mbgl::OfflineRegionObserver::statusChanged()always gets called with anmbgl::OfflineRegionStatus::downloadStateofInactiveeven when the download is active.jfirebaugh commentedon Mar 8, 2016
Are you testing with offline regions whose required resources are already in the database, because they're shared with another region?
1ec5 commentedon Mar 8, 2016
Yes. Some of these resources are also in the non-offline cache, if that matters.
jfirebaugh commentedon Mar 8, 2016
In the case where all the resources are actually already in the database, I'm not sure we're going to be able to fix the observed behavior of "going to 100% without stopping". The TLDR reason is: we don't have a mechanism for thread messages to preempt previously-queued messages.
Longer explanation: when OfflineDownload is activated, the tasks needed to figure which resources are already in the database are queued on the offline thread task queue. That task queue is FIFO: there isn't a way for a task to "preempt" a previously-queued task. Deactivating a download involves posting another task on that queue, but that task will be processed after all previous tasks, including the tasks which check for resources that are already complete. So if it turns out that every resource is already in the database, the observer will get a status notifications each of them, and then the "deactivate download" task will run -- but the download will already be complete.
There is a bug relating to how the
downloadStatemember of the status is reported, which #4233 fixes. I'll merge that.jfirebaugh commentedon Mar 8, 2016
1299353 adds the ability to stop an in-progress download to the command-line offline test binary, and it works as expected when resources aren't already in the database.
bleege commentedon Mar 8, 2016
@jfirebaugh Thanks for the insight into how Core GL is actually doing the processing. That makes much more sense now. It looks like #4233 made it in to
masterlast night so today's SNAPSHOT should have it. I'll test it out to see what impact it has and report back.bleege commentedon Mar 8, 2016
I just ran a local test using today's SNAPSHOT (Number 41) and confirmed that the Cancel process now works as described above (adding a cancel job to the regular work queue). To be clear, the downloading continue on for a few seconds (as evidence by the logs) but it did eventually stop short of completing. In my test I set the "Cancel" flag when it was at 3% of download and it eventually stopped when it had reached 30%. This tells me that it did "work" but that Cancel is very much going to be a YMMV situation depending on the region selected and when the Cancel flag is set. It's very possible to have situations where the Cancel is requested "too late" and that the downloading will complete before the Cancel job can go into effect.
Next steps are for @1ec5 to verify that he's seeing this too on iOS now. After that we can discuss (if need be) whether or not this is will be acceptable functionality for the first release.
1ec5 commentedon Mar 8, 2016
Yes, now canceling eventually works on iOS. When downloading a tile pyramid that largely overlaps with another tile pyramid, the download still races most of the way to completion (probably for the overlapping resources) but does eventually stop. I also see that the expected resource count is now marked as imprecise initially, which is great to see.
jfirebaugh commentedon Mar 8, 2016
#4248 makes status reporting more predictable, and may also reduce the latency in deactivation.
nitaliano commentedon Oct 26, 2017
@jfirebaugh @zugaldia I'm seeing the above behavior of not being able to suspend the download.
Steps(using Android SDK 5.1.4)
based off what I was reading here this seems like expected behavior or a known issue just wanted to double check?
One thing to note is everything works fine if I don't have the region overlap.