Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

add FileSource pause/resume #9977

Merged
merged 1 commit into from
Oct 17, 2017
Merged

Conversation

tobrun
Copy link
Member

@tobrun tobrun commented Sep 12, 2017

closes #9965,

This PR integrates with FileSource pause/resume when the app state changes (foreground vs background). I'm currently looking into counting ongoing filesource interactions for two reasons:

  • we need to be able to do offline downloads in the background and don't stop them when the app is backgrounded.
  • we need to support showing multiple maps in one Activity/Fragment, we aren't allows to call pause redundantly.

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Sep 12, 2017
@tobrun tobrun added this to the android-v5.2.0 milestone Sep 12, 2017
@tobrun tobrun self-assigned this Sep 12, 2017
@tobrun
Copy link
Member Author

tobrun commented Sep 13, 2017

This PR has been tested for offline integration and showing multiple maps on screen.
Ready for review.

Copy link
Contributor

@ivovandongen ivovandongen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, besides the one comment.


private FileSource(String cachePath, AssetManager assetManager) {
initialize(Mapbox.getAccessToken(), cachePath, assetManager);
}

public void activate() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would opt to make redundant calls possible instead of doing counting here. I suggested a patch to do so here: 034551f

This will also subtly break if the file source would be paused/resumed from another place in the future.

cc @jfirebaugh

Copy link
Member Author

@tobrun tobrun Oct 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfirebaugh could you add your preference on who is responsible for ref counting? the binding or core?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in #10174 (review), my preference is to keep pause/resume as strict as possible -- in particular callable only by the creating thread -- because they otherwise get very difficult to reason about.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ivovandongen can you 👍 this if you are onboard on adding this?

@tobrun tobrun requested a review from zugaldia October 13, 2017 09:06
@tobrun tobrun changed the base branch from master to release-agua October 13, 2017 15:45
@@ -264,6 +264,7 @@ public void onStatusChanged(OfflineRegionStatus status) {
if (status.isComplete()) {
// Download complete
endProgress("Region downloaded successfully.");
offlineRegion.setDownloadState(OfflineRegion.STATE_INACTIVE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobrun Ref counting aside, this looks like new behavior for region downloads. Are there any side effects if a developer (like until now) doesn't manually set the region as inactive?

Copy link
Member Author

@tobrun tobrun Oct 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will result in not pausing the Filesource, in other words will match the same behavior as it is today. For this reason I'm not seeing this as a semver change but an enhancement to API.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobrun Makes sense, thanks for the clarification.

Copy link
Member

@zugaldia zugaldia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on my end.

@tobrun tobrun merged commit d95079a into release-agua Oct 17, 2017
@Guardiola31337 Guardiola31337 mentioned this pull request Oct 19, 2017
20 tasks
@jfirebaugh jfirebaugh deleted the 9965-requests-while-background branch October 24, 2017 20:40
@Guardiola31337 Guardiola31337 mentioned this pull request Oct 26, 2017
20 tasks
@tobrun tobrun mentioned this pull request Nov 3, 2017
21 tasks
This was referenced Nov 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants