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

Closed

Description

@bleege

The current process for cancelling a Region that's in the process of downloading it's resources is to use:

OfflineRegion offlineRegion = ...;
offlineRegion.setDownloadState(OfflineRegion.STATE_INACTIVE);

However when this is called the downloading continues on as evidence by using log statements within the onStatusChanged() method of the OfflineRegion.OfflineRegionObserver()

/cc @zugaldia @jfirebaugh @1ec5

Activity

  1. added
    Android
    on Mar 7, 2016
  2. added this to the android-v4.0.0 milestone on Mar 7, 2016
  3. added
    iOS
    macOS
    on Mar 7, 2016
  4. self-assigned this
    on Mar 7, 2016
  5. jfirebaugh commented on Mar 7, 2016

    @jfirebaugh
    Contributor

    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?

  6. bleege commented on Mar 7, 2016

    @bleege
    ContributorAuthor

    Is it actually never stopping, or is it just not stopping immediately?

    It is actually never stopping until 100% is achieved and OfflineRegionStatus.isCompleted() returns true.

  7. 1ec5 commented on Mar 7, 2016

    @1ec5
    Contributor

    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.

  8. jfirebaugh commented on Mar 8, 2016

    @jfirebaugh
    Contributor

    Are you testing with offline regions whose required resources are already in the database, because they're shared with another region?

  9. 1ec5 commented on Mar 8, 2016

    @1ec5
    Contributor

    Yes. Some of these resources are also in the non-offline cache, if that matters.

  10. jfirebaugh commented on Mar 8, 2016

    @jfirebaugh
    Contributor

    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.

  11. jfirebaugh commented on Mar 8, 2016

    @jfirebaugh
    Contributor

    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.

  12. bleege commented on Mar 8, 2016

    @bleege
    ContributorAuthor

    @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.

  13. bleege commented on Mar 8, 2016

    @bleege
    ContributorAuthor

    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.

  14. 1ec5 commented on Mar 8, 2016

    @1ec5
    Contributor

    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.

  15. jfirebaugh commented on Mar 8, 2016

    @jfirebaugh
    Contributor

    #4248 makes status reporting more predictable, and may also reduce the latency in deactivation.

  16. nitaliano commented on Oct 26, 2017

    @nitaliano
    Contributor

    @jfirebaugh @zugaldia I'm seeing the above behavior of not being able to suspend the download.

    Steps(using Android SDK 5.1.4)

    1. Have a near identical offline region in the db
    2. Delete the offline region
    3. Create a new offline region with a region similar to step 1
    4. Attempting to set the offline region to inactive will not prevent the status updates from going to 100%.

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

AndroidbugiOSmacOSoffline

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions