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

Android N Crash after downloading map #6752

Closed
art2limit opened this issue Oct 19, 2016 · 5 comments
Closed

Android N Crash after downloading map #6752

art2limit opened this issue Oct 19, 2016 · 5 comments
Labels
Android Mapbox Maps SDK for Android needs information

Comments

@art2limit
Copy link

art2limit commented Oct 19, 2016

Platform: Android 7.0
Mapbox SDK version:4.2.0-beta.3 (same on stable)

Steps to trigger behavior

  1. Start download offline map on Android Nougat
  2. Wait
  3. Receive crash

Logs:

10-19 15:40:09.023 3978-4008/com.myapp A/libc: Fatal signal 11 (SIGSEGV), code >128, fault addr 0x0 in tid 4008 (AsyncTask #1)
10-19 15:40:09.095 4076-4076/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
10-19 15:40:09.095 4076-4076/? A/DEBUG: Build fingerprint: >'Android/sdk_google_phone_x86_64/generic_x86_64:7.0/NYC/3287311:userdebug/test-keys'
10-19 15:40:09.095 4076-4076/? A/DEBUG: Revision: '0'
10-19 15:40:09.095 4076-4076/? A/DEBUG: ABI: 'x86_64'
10-19 15:40:09.095 4076-4076/? A/DEBUG: pid: 3978, tid: 4008, name: AsyncTask #1 >>> com.myapp <<<
10-19 15:40:09.095 4076-4076/? A/DEBUG: signal 11 (SIGSEGV), code 128 (SI_KERNEL), fault addr 0x0
10-19 15:40:09.096 4076-4076/? A/DEBUG: rax 0000000000000000 rbx 0001783c00000024 rcx 00007ffed7e77a08 rdx 00007ffed7e00000
10-19 15:40:09.096 4076-4076/? A/DEBUG: rsi 0001783c0000001c rdi 0001783c00000024
10-19 15:40:09.096 4076-4076/? A/DEBUG: r8 0000000000000077 r9 00007ffef3f12270 r10 0000000000000000 r11 0000000000000206
10-19 15:40:09.096 4076-4076/? A/DEBUG: r12 00007ffed7e00000 r13 00007ffed6c89788 r14 0001783c0000001c r15 00007ffed7e77a08
10-19 15:40:09.096 4076-4076/? A/DEBUG: cs 0000000000000033 ss 000000000000002b
10-19 15:40:09.096 4076-4076/? A/DEBUG: rip 00007ffef3ea0ac4 rbp 00007ffedafff6b8 rsp 00007ffedafff2b0 eflags 0000000000000246
10-19 15:40:09.096 4076-4076/? A/DEBUG: backtrace:
10-19 15:40:09.097 4076-4076/? A/DEBUG: #00 pc 000000000008aac4 /system/lib64/libc.so (pthread_mutex_lock+20)
10-19 15:40:09.097 4076-4076/? A/DEBUG: #1 pc 00000000000a2e90 /system/lib64/libc.so (je_arena_dalloc_large+32)
10-19 15:40:09.097 4076-4076/? A/DEBUG: #2 pc 00000000000b7de3 /system/lib64/libc.so (je_free+115)
10-19 15:40:09.097 4076-4076/? A/DEBUG: #3 pc 000000000008a36e /system/lib64/libc.so (_Z21pthread_key_clean_allv+142)
10-19 15:40:09.097 4076-4076/? A/DEBUG: #4 pc 0000000000089e9b /system/lib64/libc.so (pthread_exit+91)
10-19 15:40:09.097 4076-4076/? A/DEBUG: #5 pc 0000000000089739 /system/lib64/libc.so (_ZL15__pthread_startPv+185)
10-19 15:40:09.097 4076-4076/? A/DEBUG: #6 pc 00000000000299eb /system/lib64/libc.so (__start_thread+11)
10-19 15:40:09.097 4076-4076/? A/DEBUG: #7 pc 000000000001ca65 /system/lib64/libc.so (__bionic_clone+53)

@cammace cammace added the Android Mapbox Maps SDK for Android label Oct 19, 2016
@cammace
Copy link
Contributor

cammace commented Oct 19, 2016

Hey there, thanks for reaching out and reporting this. I wasn't able to reproduce this crash on a Nexus 5x running Nougat and the code found in the demo app, OfflineManagerActivity.java. Could you ensure you are downloading the region correctly. If you are still running into issues, any code snippets or additional information will help resolve this issue.

ezgif com-video-to-gif 3

@art2limit
Copy link
Author

art2limit commented Oct 20, 2016

DIfference between my project and example:

— Downloading map in Service, in AsyncTask (method name downloadMap below):

private static final String JSON_CHARSET = "UTF-8";
private static final String JSON_FIELD_REGION_NAME = "FIELD_REGION_NAME";

public static final String REGION_NAME = "MyApp";

private void downloadMap() {
        try {
            LatLng northeastLatLng = new LatLng(Double.parseDouble(getString(R.string.map_northeast_lat)),
                    Double.parseDouble(getString(R.string.map_northeast_lon)));
            LatLng southwestLatLng = new LatLng(Double.parseDouble(getString(R.string.map_southwest_lat)),
                    Double.parseDouble(getString(R.string.map_southwest_lon)));
            OfflineManager offlineManager = OfflineManager.getInstance(this);

            LatLngBounds latLngBounds = new LatLngBounds.Builder()
                    .include(northeastLatLng).include(southwestLatLng).build();

            OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
                    Style.MAPBOX_STREETS, latLngBounds,
                    Double.parseDouble(getString(R.string.map_min_zoom)),
                    Double.parseDouble(getString(R.string.map_max_zoom)),
                    getResources().getDisplayMetrics().density);

            JSONObject jsonObject = new JSONObject();
            jsonObject.put(JSON_FIELD_REGION_NAME, REGION_NAME);
            byte[] metadata = jsonObject.toString().getBytes(JSON_CHARSET);

            offlineManager.createOfflineRegion(definition, metadata, new OfflineRegionCallback());
        } catch (Exception e) {
            e.printStackTrace();
            showErrorNotification(null);
            if (BuildConfig.DEBUG) Log.e(Constants.LOG_TAG, "downloadMapError: " + e.getMessage());
        }
    }

 private class OfflineRegionCallback implements OfflineManager.CreateOfflineRegionCallback {

        @Override
        public void onCreate(OfflineRegion offlineRegion) {
            offlineRegion.setDownloadState(OfflineRegion.STATE_ACTIVE);
            offlineRegion.setObserver(new OfflineRegion.OfflineRegionObserver() {
                @Override
                public void onStatusChanged(OfflineRegionStatus status) {
                    isMapStartDownloaded = true;
                    double completePercentage = status.getRequiredResourceCount() >= 0 ?
                            ((MAX_PROGRESS - START_OFFSET_PROGRESS) * status.getCompletedResourceCount() / status.getRequiredResourceCount()) : 0.0;
                    if (status.isComplete()) {
                        isMapDownloaded = true;
                        showCompletedNotification(null);
                    } else {
                        notificationBuilder.setProgress(MAX_PROGRESS, (int) (START_OFFSET_PROGRESS + completePercentage), false);
                        Intent intent = new Intent(Actions.ACTION_PERCENT_UPDATE);
                        intent.putExtra(Constants.EXTRA_PACKAGE, getApplicationContext().getPackageName());
                        intent.putExtra(Constants.EXTRA_DATA_1, (int) (START_OFFSET_PROGRESS + completePercentage));
                        sendBroadcast(intent);
                        notification = notificationBuilder.build();
                        updateNotification();
                    }
                }

                @Override
                public void onError(OfflineRegionError error) {
                    showErrorNotification(null);
                    if (BuildConfig.DEBUG) {
                        Log.e(Constants.LOG_TAG, "onError reason: " + error.getReason());
                        Log.e(Constants.LOG_TAG, "onError message: " + error.getMessage());
                    }
                }

                @Override
                public void mapboxTileCountLimitExceeded(long limit) {
                    if (BuildConfig.DEBUG) Log.e(Constants.LOG_TAG, "Error limit: " + limit);
                }
            });
        }

        @Override
        public void onError(String error) {
            showErrorNotification(null);
            if (BuildConfig.DEBUG) Log.e(Constants.LOG_TAG, "Error: " + error);
        }
    }

— Do not show map as View, only call:

    MapboxAccountManager.start(this, getString(R.string.map_token));

in Application class, onCreate method.

To be more precise, error occurs during the download. If error still not reproduce i create demo project with my logic, just say.

@art2limit
Copy link
Author

@cammace it is very important, do you reproduce this crash?

@cammace
Copy link
Contributor

cammace commented Oct 25, 2016

Looking over this again, the original crash report you posted, doesn't seem to mention Mapbox anywhere, could you confirm that this is an issue with the SDK and not the service/async task. A demo project would be helpful, you shouldn't need to place the offline downloading code inside a service or worry about doing it asynchronously, we already handle this for you.

@cammace
Copy link
Contributor

cammace commented Nov 9, 2016

Please reach out either through Stack Overflow or through our contact page if you have any questions. Closing

@cammace cammace closed this as completed Nov 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android needs information
Projects
None yet
Development

No branches or pull requests

2 participants