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.

Stop delivering status updates when offline download is canceled  #5538

Closed

Description

@danswick

Platform: iOS and Android
Mapbox SDK version: latest of each

Steps to trigger behavior

  1. Initiate an offline download
  2. Cancel the download

Expected behavior

Download immediately stops and no further messages are sent.

Actual behavior

Messages continue to be sent.

Related issues: #5531, #4418, #4229

Activity

  1. added
    iOS
    Android
    on Jul 1, 2016
  2. 1ec5 commented on Jul 1, 2016

    @1ec5
    Contributor

    Should the region (pack) go back to reporting its state as inactive? Is it safe for the developer to resume downloading the region at that point, before region would’ve stopped updating (with the current code)?

  3. zugaldia commented on Jul 1, 2016

    @zugaldia
    Member

    /sub

  4. dagatsoin commented on Jul 9, 2016

    @dagatsoin

    Just to be sure is

    public void cancelDownload(){
            _offlineRegion.setDownloadState(OfflineRegion.STATE_INACTIVE);
        }
    

    the good way to cancel a download ?

  5. zugaldia commented on Jul 14, 2016

    @zugaldia
    Member

    Android has enabled an API to achieve this via #5696. Setting OfflineRegion.setDeliverInactiveMessages(true/false) will let you enable/disable the delivery of messages once a region has been set inactive.

  6. added
    Core
    and removed
    Android
    iOS
    on Jul 14, 2016
  7. 1ec5 commented on Jul 14, 2016

    @1ec5
    Contributor

    We’re leaving this ticket open to track a fix in mbgl that would obviate the API added in #5696.

  8. madsodgaard commented on Jul 26, 2016

    @madsodgaard

    Any update on iOS ETA?

  9. 1ec5 commented on Jul 26, 2016

    @1ec5
    Contributor

    There are no plans to add a dedicated API to work around this issue on iOS and macOS. Instead, this ticket is tracking a fix in core that would stop sending these notifications when appropriate. We consider it essentially a bug in core that the state is still reported as active and notifications keep coming in.

    In the meantime, if you absolutely need the cancelation to appear to take effect immediately, the workaround on iOS and macOS is to keep track of the packs you've canceled or keep track of the fact that this particular pack has been canceled, and ignore progress notifications based on that.

    /cc @jfirebaugh

  10. 1ec5 commented on Aug 19, 2016

    @1ec5
    Contributor

    One consequence of this issue is that progress updates may be coming in after the developer has attempted to remove the offline pack. The errant progress updates would lead to bad memory access, as seen in #6092. The approach in #5696 wouldn’t address this race condition on iOS and macOS, because the MGLOfflinePack object has already been reclaimed by ARC by this point.

  11. jfirebaugh commented on Aug 27, 2016

    @jfirebaugh
    Contributor

    It's not possible to fix this at the core level. The status updates that to the main thread appear to come after the request to cancel a download were in fact sent by the asynchronous worker before it processed the request to cancel the download.

    iOS and macOS should apply a fix similar to that applied on Android, where the main thread ignores notifications delivered after the request to cancel the download has been sent to the asynchronous worker.

  12. added
    iOS
    macOS
    and removed
    Core
    on Aug 27, 2016
  13. 1ec5 commented on Aug 27, 2016

    @1ec5
    Contributor

    In that case, I don’t think it makes sense to add a dedicated “deliverInactiveMessages” property, as #5696 did, to the iOS/macOS SDK. The SDK should just do the right thing, which apparently means dropping these notifications.

  14. jfirebaugh commented on Sep 12, 2016

    @jfirebaugh
    Contributor

    #5508 is also related.

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

    iOSmacOSoffline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions