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.
[android] onMapReady not called in offline mode (for non mapbox:// styles) #4393
Load map with style from http://*.json address
Kill app
Enable airplane mode
Reopen app
Expected result
Map is displayed based on cached and offline data. onMapReady() callback method is invoked.
Actual result
No map is displayed, onMapReady() callback method is not invoked until network becomes available.
Other info
When using one of the predefined mapbox://... styles I get the expected result (being able to show something even with no network connection and callback being invoked).
To clarify -- have you explicitly created an offline region for the http://-based style, or are you expecting it to be cached for other reasons?
@jfirebaugh Yes, I get this behaviour both when I have offline regions (which have finished downloading) as well as when I have no offline regions.
Even with no offline regions added I was hoping that the style would be cached but that was just based on the behaviour I observed when trying the same with the predefined styles.
Even though I never get the onMapReady callback there does seem to be some data loaded at least.
When I zoom in and out I very briefly see parts of the map and the background color is also the one I've specified in the style.
FWIW
The android onMapReady callback is called when we receive DID_FINISH_LOADING event.
The DID_FINISH_LOADING is triggered when render state is RenderState::fully and data is loaded.:
@erikandre The beta.1 release had a bug that prevented offline regions from being used after downloading. This was fixed for beta.2, released today, and I would now expect the behavior in the case where you have an offline region to be as you expect.
In the case where there is not an offline region present, the SDK does do some caching based on ambient use patterns, but makes no guarantee that you'll be able to obtain a complete load of the map if network access is not available, even if you've previously viewed the same style in the same area. If you need that guarantee, create an offline region.
@tobrun I've got a fragment that extends SupportMapFragment that I add programatically.
I've retested this on the 4.0.0beta2 build but I'm still getting the same behaviour. I tried panning zooming as you suggested but even though I sometimes see (very briefly) parts of the map being drawn and then erased I'm not getting the callback.
I've downloaded an offline area that should cover the view that the map is initially showing so I should have all the data needed I think.
It could be true that the combination of having offline ignores the pan/zoom fix I'm referring to (because it's not triggering loading of new content). Need to investigate what is going wrong. For now you could try working around this by using a MapView in your Activity that is inflated through xml.
I'm now thinking that above mentioned issue by me (on master) is not the same as the one mentioned here (on release branch). To reproduce this on the testapp I'm converting the OfflineActivity to a SupportMapFragment approach. This should give us the same results as mentioned in this issue and #4438.
I don't think it is related to offline function but fragment problem. I test only with SupportMapFragmentActivity, not OfflineActivity. Network on, it animate Camera, without network , it stay still.
mapFragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
Log.d(TAG, "Map is ready");
mapboxMap.animateCamera(CameraUpdateFactory.zoomBy(2), 3500);
}
});
I have run into the issue today with the following code both on 4.0.0-rc1 and 4.0.0-SNAPSHOT. Also it seems that I have bumped in this even with mapbox://-style, since I use predefined styles for now.
The mapView in my app is in my custom map fragment and inflated from layout file. The Offline region with style Style.MAPBOX_STREETS is already downloaded, but no luck - the app is trying to reach api.mapbox.com.
@zugaldia Okay, I have tried this with different areas downloaded.
To tell the truth offline regions are really strange and I don't understand what makes them so large.
Anyway, the initial size of my app's data with the region I need already downloaded was 78.34 megabytes and the map was not loading. Now I have tried the region 4 times smaller, the app downloaded half as much resources and the data size became 72.2 megabytes. The issue is still there.
@Fintasys the 4.0.1 contains a fix for an annotations issue, the offline issue is fixed on master and can be verified using the 4.1.0-SNAPSHOT. installation instructions are here.
Activity
jfirebaugh commentedon Mar 18, 2016
To clarify -- have you explicitly created an offline region for the
http://-based style, or are you expecting it to be cached for other reasons?erikandre commentedon Mar 18, 2016
@jfirebaugh Yes, I get this behaviour both when I have offline regions (which have finished downloading) as well as when I have no offline regions.
Even with no offline regions added I was hoping that the style would be cached but that was just based on the behaviour I observed when trying the same with the predefined styles.
erikandre commentedon Mar 18, 2016
Even though I never get the onMapReady callback there does seem to be some data loaded at least.
When I zoom in and out I very briefly see parts of the map and the background color is also the one I've specified in the style.
tobrun commentedon Mar 20, 2016
FWIW
The android
onMapReadycallback is called when we receiveDID_FINISH_LOADINGevent.The
DID_FINISH_LOADINGis triggered when render state isRenderState::fullyand data is loaded.:Will need to do dig deeper into this and do some tests.
tobrun commentedon Mar 20, 2016
@jfirebaugh is waiting for
view.notifyMapChange(MapChangeDidFinishLoadingMap);event not correct when taking in account caching and offline?jfirebaugh commentedon Mar 22, 2016
@erikandre The
beta.1release had a bug that prevented offline regions from being used after downloading. This was fixed forbeta.2, released today, and I would now expect the behavior in the case where you have an offline region to be as you expect.In the case where there is not an offline region present, the SDK does do some caching based on ambient use patterns, but makes no guarantee that you'll be able to obtain a complete load of the map if network access is not available, even if you've previously viewed the same style in the same area. If you need that guarantee, create an offline region.
erikandre commentedon Mar 22, 2016
@jfirebaugh Great! I will try to verify this later today. Thanks
tobrun commentedon Mar 23, 2016
@erikandre how are you adding the Map?
I noticed that the callback is only invoked when you pan/zoom the map for the 2 last ones. #4439
erikandre commentedon Mar 23, 2016
@tobrun I've got a fragment that extends SupportMapFragment that I add programatically.
I've retested this on the 4.0.0beta2 build but I'm still getting the same behaviour. I tried panning zooming as you suggested but even though I sometimes see (very briefly) parts of the map being drawn and then erased I'm not getting the callback.
I've downloaded an offline area that should cover the view that the map is initially showing so I should have all the data needed I think.
tobrun commentedon Mar 23, 2016
It could be true that the combination of having offline ignores the pan/zoom fix I'm referring to (because it's not triggering loading of new content). Need to investigate what is going wrong. For now you could try working around this by using a MapView in your Activity that is inflated through xml.
tobrun commentedon Mar 24, 2016
I'm now thinking that above mentioned issue by me (on master) is not the same as the one mentioned here (on release branch). To reproduce this on the testapp I'm converting the OfflineActivity to a SupportMapFragment approach. This should give us the same results as mentioned in this issue and #4438.
tobrun commentedon Mar 24, 2016
The result after porting is visible here and code is here.
vfaSonnt commentedon Mar 24, 2016
I don't think it is related to offline function but fragment problem. I test only with SupportMapFragmentActivity, not OfflineActivity. Network on, it animate Camera, without network , it stay still.
tobrun commentedon Mar 24, 2016
@vfaSonnt I replied to your issue here.
NamtarR commentedon Mar 28, 2016
I have run into the issue today with the following code both on 4.0.0-rc1 and 4.0.0-SNAPSHOT. Also it seems that I have bumped in this even with mapbox://-style, since I use predefined styles for now.
The mapView in my app is in my custom map fragment and inflated from layout file. The Offline region with style Style.MAPBOX_STREETS is already downloaded, but no luck - the app is trying to reach api.mapbox.com.
zugaldia commentedon Mar 28, 2016
@NamtarR could you please check if you're seeing the same behavior described in #4500?
tobrun commentedon Mar 29, 2016
I believe the fix for #4500 will resolve this
NamtarR commentedon Mar 29, 2016
@zugaldia Okay, I have tried this with different areas downloaded.
To tell the truth offline regions are really strange and I don't understand what makes them so large.
Anyway, the initial size of my app's data with the region I need already downloaded was 78.34 megabytes and the map was not loading. Now I have tried the region 4 times smaller, the app downloaded half as much resources and the data size became 72.2 megabytes. The issue is still there.
jfirebaugh commentedon Mar 29, 2016
Should be fixed by #4512.
Fintasys commentedon May 17, 2016
For me onMapReady still not get called while I'm offline and opening the app. I'm using Mapbox Android SDK 4.0.1. Shouldn't it have been fixed?
tobrun commentedon May 17, 2016
@Fintasys the
4.0.1contains a fix for an annotations issue, the offline issue is fixed on master and can be verified using the 4.1.0-SNAPSHOT. installation instructions are here.Fintasys commentedon May 18, 2016
@tobrun thx ! last time I tried the snapshot didn't work. But now it's working great!