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.

[android] onMapReady not called in offline mode (for non mapbox:// styles) #4393

Closed

Description

@erikandre

Build

Latest 4.0.0 SNAPSHOT build (as of March 18th)

Steps to reproduce

(the attached log covers step 3-4) log.txt

  1. Load map with style from http://*.json address
  2. Kill app
  3. Enable airplane mode
  4. 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).

Activity

  1. added
    Android
    on Mar 18, 2016
  2. jfirebaugh commented on Mar 18, 2016

    @jfirebaugh
    Contributor

    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?

  3. erikandre commented on Mar 18, 2016

    @erikandre
    Author

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

  4. erikandre commented on Mar 18, 2016

    @erikandre
    Author

    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.

  5. tobrun commented on Mar 20, 2016

    @tobrun
    Member

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

    void Map::renderSync() {
        ....
       } else if (renderState != RenderState::fully) {
            renderState = RenderState::fully;
            view.notifyMapChange(MapChangeDidFinishRenderingMapFullyRendered);
            if (data->loading) {
                data->loading = false;
                view.notifyMapChange(MapChangeDidFinishLoadingMap);
            }
        }
        ....
    }

    Will need to do dig deeper into this and do some tests.

  6. tobrun commented on Mar 20, 2016

    @tobrun
    Member

    @jfirebaugh is waiting for view.notifyMapChange(MapChangeDidFinishLoadingMap); event not correct when taking in account caching and offline?

  7. jfirebaugh commented on Mar 22, 2016

    @jfirebaugh
    Contributor

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

  8. erikandre commented on Mar 22, 2016

    @erikandre
    Author

    @jfirebaugh Great! I will try to verify this later today. Thanks

  9. tobrun commented on Mar 23, 2016

    @tobrun
    Member

    @erikandre how are you adding the Map?

    • Layout file
    • MapFragment
    • Programatically

    I noticed that the callback is only invoked when you pan/zoom the map for the 2 last ones. #4439

  10. erikandre commented on Mar 23, 2016

    @erikandre
    Author

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

  11. tobrun commented on Mar 23, 2016

    @tobrun
    Member

    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.

  12. tobrun commented on Mar 24, 2016

    @tobrun
    Member

    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.

  13. tobrun commented on Mar 24, 2016

    @tobrun
    Member

    The result after porting is visible here and code is here.

  14. vfaSonnt commented on Mar 24, 2016

    @vfaSonnt

    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);
                }
            });
    
  15. tobrun commented on Mar 24, 2016

    @tobrun
    Member

    @vfaSonnt I replied to your issue here.

  16. NamtarR commented on Mar 28, 2016

    @NamtarR

    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.

        mMapView.setStyleUrl(Style.MAPBOX_STREETS);
        mMapView.getMapAsync(new OnMapReadyCallback() {
                @Override
                public void onMapReady(@NonNull MapboxMap mapboxMap) {
                        mMapboxMap = mapboxMap;
                        mWhiteScreen.setVisibility(View.GONE);
                        mProgress.setVisibility(View.GONE);
                        setupMapView();
                }
        });

    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.

  17. added this to the android-v4.0.0 milestone on Mar 28, 2016
  18. zugaldia commented on Mar 28, 2016

    @zugaldia
    Member

    @NamtarR could you please check if you're seeing the same behavior described in #4500?

  19. tobrun commented on Mar 29, 2016

    @tobrun
    Member

    I believe the fix for #4500 will resolve this

  20. self-assigned this
    on Mar 29, 2016
  21. NamtarR commented on Mar 29, 2016

    @NamtarR

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

  22. jfirebaugh commented on Mar 29, 2016

    @jfirebaugh
    Contributor

    Should be fixed by #4512.

  23. Fintasys commented on May 17, 2016

    @Fintasys

    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?

  24. tobrun commented on May 17, 2016

    @tobrun
    Member

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

  25. Fintasys commented on May 18, 2016

    @Fintasys

    @tobrun thx ! last time I tried the snapshot didn't work. But now it's working great!

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

Metadata

Metadata

Assignees

Labels

Android

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions