onaio / kujaku

Mapping and check-in library for Android using MapBox SDK
https://ona.io
BSD 2-Clause "Simplified" License
18 stars 11 forks source link

Fix offline map download resumption #273

Closed ekigamba closed 5 years ago

ekigamba commented 5 years ago

Fixes #194

To test, my guess is turning off the internet(Wifi in case it's the source) and turning it back on after 5 mins and 11-13 mins to see if the download continues. It should resume within a few seconds of connecting back.

You should also monitor the log for error-tag logs from Mapbox. The only error-tag logs from Mapbox should be after disconnecting the internet. Error-tag logs while the internet is off indicates that Mapbox is still retrying the connection

More notes are on the issue

ekigamba commented 5 years ago

BLOCKED waiting for the other PRs to be merged

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 1257


Changes Missing Coverage Covered Lines Changed/Added Lines %
library/src/main/java/io/ona/kujaku/downloaders/MapBoxOfflineResourcesDownloader.java 12 16 75.0%
library/src/main/java/io/ona/kujaku/services/MapboxOfflineDownloaderService.java 0 4 0.0%
sample/src/main/java/io/ona/kujaku/sample/activities/OfflineRegionsActivity.java 0 15 0.0%
<!-- Total: 12 35 34.29% -->
Files with Coverage Reduction New Missed Lines %
library/src/main/java/io/ona/kujaku/services/MapboxOfflineDownloaderService.java 1 56.9%
sample/src/main/java/io/ona/kujaku/sample/activities/OfflineRegionsActivity.java 1 0.0%
<!-- Total: 2 -->
Totals Coverage Status
Change from base Build 1240: 0.1%
Covered Lines: 1643
Relevant Lines: 4983

💛 - Coveralls
vincent-karuri commented 5 years ago

screenshot_20190306-175100

Getting very many error notification messages when wifi is turned off while downloading map.

Samsung J5 physical phone.

vincent-karuri commented 5 years ago

screenshot_20190306-175410

Looks like there are duplicated offline region details when you first open the activity after a period of online and offline wifi resumption.

Opening the offline downloads activity again will then show the correct information.

vincent-karuri commented 5 years ago

screenshot_20190306-180507

Not sure if this is an issue but the notification shows 42.29mb downloaded at 100% while the activity above shows 44.34mb?

vincent-karuri commented 5 years ago

For some reason, I can still download maps even when wifi is off, after downloading a previous map with wifi available.

vincent-karuri commented 5 years ago

When you then turn on the wifi and turn it off, it shows the error notification.

However, on wifi resumption, it takes a while for the app to resume downloading.

ekigamba commented 5 years ago

For some reason, I can still download maps even when wifi is off, after downloading a previous map with wifi available.

Mapbox shares resources if the two or more maps use the same resources. If you download two areas in the same area, or covering some shared area, Mapbox does not redownload such tiles, fonts or other kind of resources

ekigamba commented 5 years ago

When you then turn on the wifi and turn it off, it shows the error notification.

However, on wifi resumption, it takes a while for the app to resume downloading.

If it takes less than a minute or around there off, then it is OK. The download progress should be picked up as soon as the device itself establishes that it has a connection/internet connection(If I am not wrong). Longer than that would be an issue

Is it clear after how long the download resumes and does the device connect immediately and internet connectivity resume immediately

vincent-karuri commented 5 years ago

When you then turn on the wifi and turn it off, it shows the error notification.

However, on wifi resumption, it takes a while for the app to resume downloading.

If it takes less than a minute or around there off, then it is OK. The download progress should be picked up as soon as the device itself establishes that it has a connection/internet connection(If I am not wrong). Longer than that would be an issue

Is it clear after how long the download resumes and does the device connect immediately and internet connectivity resume immediately

Took about 4 min in this scenario. Internet resumes immediately.

ekigamba commented 5 years ago

When you then turn on the wifi and turn it off, it shows the error notification.

However, on wifi resumption, it takes a while for the app to resume downloading.

If it takes less than a minute or around there off, then it is OK. The download progress should be picked up as soon as the device itself establishes that it has a connection/internet connection(If I am not wrong). Longer than that would be an issue Is it clear after how long the download resumes and does the device connect immediately and internet connectivity resume immediately

Took about 4 min in this scenario. Internet resumes immediately.

Would it be possible to provide the specific time after which you resumed internet(So that I can test using the same time on my side)? And probably the logs if possible

vincent-karuri commented 5 years ago

When you then turn on the wifi and turn it off, it shows the error notification.

However, on wifi resumption, it takes a while for the app to resume downloading.

If it takes less than a minute or around there off, then it is OK. The download progress should be picked up as soon as the device itself establishes that it has a connection/internet connection(If I am not wrong). Longer than that would be an issue Is it clear after how long the download resumes and does the device connect immediately and internet connectivity resume immediately

Took about 4 min in this scenario. Internet resumes immediately.

Would it be possible to provide the specific time after which you resumed internet(So that I can test using the same time on my side)? And probably the logs if possible

Try 5 min.

ekigamba commented 5 years ago

screenshot_20190307-192828 screenshot_20190307-192852 screenshot_20190307-192856 screenshot_20190307-192911

Are there any special permissions that are not provided on your phone? This was my result after turning off the WIFI at 7:22/23 pm and resuming at 7:28. It started almost immediately. Took around 10 seconds which is justifiable

You can see that the error notification showed up at 7:22 pm and in the second screenshot, my WIFI is on and the download progress had changed

vincent-karuri commented 5 years ago

The test flow I mentioned happened after this https://github.com/onaio/kujaku/pull/273#issuecomment-470527505.

Is that what you followed?

If it's still unclear, let's take do this in-person to save on time.

ekigamba commented 5 years ago

The test flow I mentioned happened after this #273 (comment).

Is that what you followed?

If it's still unclear, let's take do this in-person to save on time.

Cool

ekigamba commented 5 years ago

Fixed the issue, the ConnectivityReceiver count was going -1 so on reactivating it would be 0 and not 1 which is the point at which the broadcast receiver is enabled