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.

Crash: When Attempting to Download Offline Region #7137

Closed

Description

@cammace

Original post mapbox/mapbox-java#215:

I receive this error when I attempt to download an Offline Region:

11-21 12:32:01.558 com.offgrid.electric.zola.sales.staging A/libc: /usr/local/google/buildbot/src/android/ndk-r12-release/ndk/sources/cxx-stl/llvm-libc++abi/libcxxabi/src/abort_message.cpp:74: void abort_message(const char *, ...): assertion "terminating with uncaught exception of type std::bad_alloc: std::bad_alloc" failed
11-21 12:32:01.559 com.offgrid.electric.zola.sales.staging A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 12494 (DefaultFileSour)

I'm using the following version:

compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.0-beta.5@aar') {
        transitive = true
        exclude group: "com.google.guava"
    }

Here's the code:

public void createOfflineRegion (String styleUrl, LatLngBounds latLngBounds, float density)
    {
        offlineManager.createOfflineRegion(
                getDefinition( styleUrl, latLngBounds, density ),
                getMetaData(),
                new OfflineManager.CreateOfflineRegionCallback()
                {
                    @Override
                    public void onCreate (OfflineRegion offlineRegion)
                    {
                        offlineRegion.setDownloadState( OfflineRegion.STATE_ACTIVE );
                        offlineRegion.setObserver( new OfflineRegion.OfflineRegionObserver()
                        {
                            @Override
                            public void onStatusChanged (OfflineRegionStatus status)
                            {
                                if ( status.isComplete() )
                                {
                                    Timber.i( "Region downloaded successfully." );
                                }
                            }

                            @Override
                            public void onError (OfflineRegionError error)
                            {
                                Timber.e( "onError reason: " + error.getReason() );
                                Timber.e( "onError message: " + error.getMessage() );
                            }

                            @Override
                            public void mapboxTileCountLimitExceeded (long limit)
                            {
                                // Notify if offline region exceeds maximum tile count
                                Timber.e( "Mapbox tile count limit exceeded: " + limit );
                            }
                        } );
                    }

                    @Override
                    public void onError (String error)
                    {
                        Timber.e( "Error: " + error );
                    }
                } );
    }

Pretty much just copied from the Sample. Any ideas what could be causing this crash? Thanks

Hey @adavis, I modified the sample code a bit using the same code you provided and wasn't able to reproduce the crash. Could you provide the getMetaData() and getDefinition() methods also along with what parameters you are passing into createOfflineRegion(). If you are getting any additional logcat output when the crash occurs, that might help.

cc: @zugaldia

Activity

  1. added
    Android
    on Nov 21, 2016
  2. adavis commented on Nov 21, 2016

    @adavis

    Parameters:

    String styleUrl = Style.SATELLITE;
    
    LatLngBounds latLngBounds = new LatLngBounds.Builder()
              .include( new LatLng( -2.6740, 35.977 ) )
              .include( new LatLng( -4.0559, 37.142 ) )
              .build();
    
    float density = 2.0f;
    
    offlineManager.createOfflineRegion( styleUrl, latLngBounds, getDensity() );
    

    The other methods:

    private OfflineRegionDefinition getDefinition (String styleUrl, LatLngBounds latLngBounds, float density)
        {
            return new OfflineTilePyramidRegionDefinition( styleUrl,
                                                           latLngBounds,
                                                           MIN_ZOOM,
                                                           MAX_ZOOM,
                                                           density );
        }
    
        private byte[] getMetaData ()
        {
            byte[] metadata;
            try
            {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put( JSON_FIELD_REGION_NAME, SALES_AREA );
                String json = jsonObject.toString();
                metadata = json.getBytes( JSON_CHARSET );
            }
            catch ( Exception e )
            {
                Timber.e( e, "Failed to encode metadata: " + e.getMessage() );
                metadata = null;
            }
    
            return metadata;
        }
    
  3. adavis commented on Nov 21, 2016

    @adavis

    @cammace I also see this in the logs:

    11-21 18:11:14.021 com.offgrid.electric.zola.sales.staging D/libc-netbsd: [getaddrinfo]: hostname=api.mapbox.com; servname=(null); netid=0; mark=0
    11-21 18:11:14.021 com.offgrid.electric.zola.sales.staging D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0
    11-21 18:11:14.022 com.offgrid.electric.zola.sales.staging D/libc-netbsd: [getaddrinfo]: hostname=api.mapbox.com; servname=(null); netid=0; mark=0
    11-21 18:11:14.022 com.offgrid.electric.zola.sales.staging D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
    11-21 18:11:14.022 com.offgrid.electric.zola.sales.staging D/libc-netbsd: getaddrinfo: api.mapbox.com get result from proxy gai_error = 0
    11-21 18:11:14.024 com.offgrid.electric.zola.sales.staging D/Posix: [Posix_connect Debug]Process com.offgrid.electric.zola.sales.staging :443 
    11-21 18:11:14.032 com.offgrid.electric.zola.sales.staging D/libc-netbsd: getaddrinfo: api.mapbox.com get result from proxy gai_error = 0
    11-21 18:11:14.033 com.offgrid.electric.zola.sales.staging D/Posix: [Posix_connect Debug]Process com.offgrid.electric.zola.sales.staging :443 
    11-21 18:11:14.062 com.offgrid.electric.zola.sales.staging D/libc-netbsd: [getaddrinfo]: hostname=api.mapbox.com; servname=(null); netid=0; mark=0
    11-21 18:11:14.062 com.offgrid.electric.zola.sales.staging D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0
    11-21 18:11:14.070 com.offgrid.electric.zola.sales.staging D/libc-netbsd: [getaddrinfo]: hostname=api.mapbox.com; servname=(null); netid=0; mark=0
    11-21 18:11:14.071 com.offgrid.electric.zola.sales.staging D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0
    
  4. cammace commented on Nov 22, 2016

    @cammace
    ContributorAuthor

    I've been tweaking around with the OfflineTilePyramidRegionDefinition parameters using the same bounding box, style, and pixel density provided by @adavis (thanks!). While I can't produce the exact same crash, if I tweak the max zoom level beyond 18 the region fails to complete downloading and results in the activity being destroyed:

    ezgif com-video-to-gif

    No logcat errors are shown.

    cc: @ivovandongen

  5. adavis commented on Nov 22, 2016

    @adavis

    Thanks @cammace, so I reduced the MAX_ZOOM to 18 and now the crash is gone. Would be useful to have some logs around it though.

  6. zugaldia commented on Nov 22, 2016

    @zugaldia
    Member

    No logcat errors are shown.
    Would be useful to have some logs around it though.

    The absence of any logs is truly strange.

  7. ivovandongen commented on Nov 28, 2016

    @ivovandongen
    Contributor

    @cammace Have you tried to get the error by disabling the filters in Android Studio? The native crash stacktrace usually doesn't show up with the filters enabled.

    screen shot 2016-11-28 at 10 41 03

  8. cammace commented on Nov 28, 2016

    @cammace
    ContributorAuthor

    Yes @ivovandongen, I'll try reproducing this in the testapp on a branch later today.

  9. abourtema commented on Dec 23, 2016

    @abourtema

    I have problem , I use Mapbox in android , the app run good but when download map show me Mapbox tile count limit exceeded: 6000 , I use less 4000 tile

  10. zugaldia commented on Jan 2, 2017

    @zugaldia
    Member

    @cammace Any luck getting further crash logs as suggested by @ivovandongen ?

    @abourtema Your issue seems to be a different one. Do you mind opening a separate ticket including the code or settings that you're using to download the offline region so that we can reproduce it? Thanks.

  11. tobrun commented on Apr 19, 2017

    @tobrun
    Member

    @cammace Any update on this?

  12. abourtema commented on Apr 22, 2017

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

    Androidbugoffline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions