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

Custom icon potentially causing crash on certain devices #3031

Closed
danswick opened this issue Nov 13, 2015 · 27 comments
Closed

Custom icon potentially causing crash on certain devices #3031

danswick opened this issue Nov 13, 2015 · 27 comments
Labels
Android Mapbox Maps SDK for Android crash

Comments

@danswick
Copy link
Contributor

While testing the Mapbox Android SDK custom marker example, I ran into some errors running a simple version on a Nexus 5x. Here are the steps I took:

  • Open the app as-is in AVD (both API 21 and 23): App installs and opens without error. Custom marker is present.
  • Open the app as-is on my Nexus 5x via ADB: app installs and opens, but force closes right away. Nothing is printed to logcat in Android Studio.
  • Open the app on my Nexus 5x with mimpap instead of drawable in R.drawable.ic_directions_boat_black_18dp (and created corresponding image files in the proper mipmap_ directories): same result as above.
  • Open the app on my Nexus 5x without .icon(icon): app installs and opens without error.

cc: @zugaldia @bleege

@danswick danswick added the Android Mapbox Maps SDK for Android label Nov 13, 2015
@zugaldia
Copy link
Member

@danswick Hey Dan, thanks for the feedback. I just created a new project with the custom marker sample code but I couldn't reproduce your issue.

I'd love to see if we could get some crash logs to investigate further. Could you re-rerun your sample code making sure this dropdown in Android Studio is set as "no-filters"?

image

@danswick
Copy link
Contributor Author

Thanks, @zugaldia. Remembered my USB-C cable today and here's the unfiltered log:

11-17 18:07:51.706 32137-32137/com.mycompany.myfirstglapp A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 32137 (ny.myfirstglapp)
11-17 18:07:51.810 3249-3249/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-17 18:07:51.810 3249-3249/? A/DEBUG: Build fingerprint: 'google/bullhead/bullhead:6.0/MDB08L/2343525:user/release-keys'
11-17 18:07:51.810 3249-3249/? A/DEBUG: Revision: 'rev_1.0'
11-17 18:07:51.810 3249-3249/? A/DEBUG: ABI: 'arm'
11-17 18:07:51.810 3249-3249/? A/DEBUG: pid: 32137, tid: 32137, name: ny.myfirstglapp  >>> com.mycompany.myfirstglapp <<<
11-17 18:07:51.810 3249-3249/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
11-17 18:07:51.826 3249-3249/? A/DEBUG:     r0 00000000  r1 00007d89  r2 00000006  r3 f753ab7c
11-17 18:07:51.826 3249-3249/? A/DEBUG:     r4 f753ab84  r5 f753ab34  r6 00000002  r7 0000010c
11-17 18:07:51.826 3249-3249/? A/DEBUG:     r8 f53bd120  r9 ff883f14  sl f40de800  fp ff883a08
11-17 18:07:51.827 3249-3249/? A/DEBUG:     ip 00000006  sp ff8839a8  lr f72acf15  pc f72aec00  cpsr 400e0010
11-17 18:07:51.835 3249-3249/? A/DEBUG:     #00 pc 00041c00  /system/lib/libc.so (tgkill+12)
11-17 18:07:51.836 3249-3249/? A/DEBUG:     #01 pc 0003ff11  /system/lib/libc.so (pthread_kill+32)
11-17 18:07:51.836 3249-3249/? A/DEBUG:     #02 pc 0001c73f  /system/lib/libc.so (raise+10)
11-17 18:07:51.836 3249-3249/? A/DEBUG:     #03 pc 000198f1  /system/lib/libc.so (__libc_android_abort+34)
11-17 18:07:51.836 3249-3249/? A/DEBUG:     #04 pc 000174b0  /system/lib/libc.so (abort+4)
11-17 18:07:51.836 3249-3249/? A/DEBUG:     #05 pc 00476480  /data/app/com.mycompany.myfirstglapp-1/lib/arm/libmapbox-gl.so
11-17 18:07:51.837 3249-3249/? A/DEBUG:     #06 pc 004765b0  /data/app/com.mycompany.myfirstglapp-1/lib/arm/libmapbox-gl.so
11-17 18:07:51.837 3249-3249/? A/DEBUG:     #07 pc 00466c08  /data/app/com.mycompany.myfirstglapp-1/lib/arm/libmapbox-gl.so
11-17 18:07:51.837 3249-3249/? A/DEBUG:     #08 pc 00465e44  /data/app/com.mycompany.myfirstglapp-1/lib/arm/libmapbox-gl.so (__cxa_throw+240)
11-17 18:07:51.837 3249-3249/? A/DEBUG:     #09 pc 0017cd18  /data/app/com.mycompany.myfirstglapp-1/lib/arm/libmapbox-gl.so (mbgl::SpriteImage::SpriteImage(unsigned short, unsigned short, float, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, bool)+300)
11-17 18:07:51.837 3249-3249/? A/DEBUG:     #10 pc 0013a8f8  /data/app/com.mycompany.myfirstglapp-1/lib/arm/libmapbox-gl.so
11-17 18:07:51.837 3249-3249/? A/DEBUG:     #11 pc 0065b77b  /data/app/com.mycompany.myfirstglapp-1/oat/arm/base.odex (offset 0x463000) (void com.mapbox.mapboxsdk.views.NativeMapView.nativeSetSprite(long, java.lang.String, int, int, float, byte[])+174)
11-17 18:07:51.837 3249-3249/? A/DEBUG:     #12 pc 0065f177  /data/app/com.mycompany.myfirstglapp-1/oat/arm/base.odex (offset 0x463000) (void com.mapbox.mapboxsdk.views.NativeMapView.setSprite(java.lang.String, int, int, float, byte[])+170)
11-17 18:07:51.838 3249-3249/? A/DEBUG:     #13 pc 0064ea37  /data/app/com.mycompany.myfirstglapp-1/oat/arm/base.odex (offset 0x463000) (void com.mapbox.mapboxsdk.views.MapView.loadSprite(com.mapbox.mapboxsdk.annotations.Sprite)+810)
11-17 18:07:51.838 3249-3249/? A/DEBUG:     #14 pc 0064ec8f  /data/app/com.mycompany.myfirstglapp-1/oat/arm/base.odex (offset 0x463000) (com.mapbox.mapboxsdk.annotations.Marker com.mapbox.mapboxsdk.views.MapView.prepareMarker(com.mapbox.mapboxsdk.annotations.MarkerOptions)+354)
11-17 18:07:51.839 3249-3249/? A/DEBUG:     #15 pc 0064fcad  /data/app/com.mycompany.myfirstglapp-1/oat/arm/base.odex (offset 0x463000) (com.mapbox.mapboxsdk.annotations.Marker com.mapbox.mapboxsdk.views.MapView.addMarker(com.mapbox.mapboxsdk.annotations.MarkerOptions)+168)
11-17 18:07:51.839 3249-3249/? A/DEBUG:     #16 pc 008d3527  /data/app/com.mycompany.myfirstglapp-1/oat/arm/base.odex (offset 0x463000) (void com.mycompany.myfirstglapp.MainActivity.onCreate(android.os.Bundle)+1018)
11-17 18:07:51.839 3249-3249/? A/DEBUG:     #17 pc 72dfdc1d  /data/dalvik-cache/arm/system@framework@boot.oat (offset 0x1ec4000)
11-17 18:07:52.066 4468-32163/? W/ActivityManager:   Force finishing activity com.mycompany.myfirstglapp/.MainActivity
11-17 18:07:52.067 3249-3249/? E/DEBUG: AM write failed: Broken pipe
11-17 18:07:52.085 3264-3264/? I/Zygote: Process 32137 exited due to signal (6)
11-17 18:07:52.372 4468-32163/? I/WindowManager: Screenshot max retries 4 of Token{2506267 ActivityRecord{ef20626 u0 com.mycompany.myfirstglapp/.MainActivity t1076 f}} appWin=Window{b1d375f u0 Starting com.mycompany.myfirstglapp} drawState=4
11-17 18:07:52.374 4468-32163/? W/ActivityManager: Exception thrown during pause
11-17 18:07:52.374 4468-32163/? W/ActivityManager: android.os.DeadObjectException
11-17 18:07:52.374 4468-32163/? W/ActivityManager:     at android.os.BinderProxy.transactNative(Native Method)
11-17 18:07:52.374 4468-32163/? W/ActivityManager:     at android.os.BinderProxy.transact(Binder.java:503)
11-17 18:07:52.374 4468-32163/? W/ActivityManager:     at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:727)
11-17 18:07:52.374 4468-32163/? W/ActivityManager:     at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:867)
11-17 18:07:52.374 4468-32163/? W/ActivityManager:     at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:2907)
11-17 18:07:52.374 4468-32163/? W/ActivityManager:     at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:2763)
11-17 18:07:52.374 4468-32163/? W/ActivityManager:     at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:2755)
11-17 18:07:52.374 4468-32163/? W/ActivityManager:     at com.android.server.am.ActivityManagerService.handleAppCrashLocked(ActivityManagerService.java:12033)
11-17 18:07:52.374 4468-32163/? W/ActivityManager:     at com.android.server.am.ActivityManagerService.makeAppCrashingLocked(ActivityManagerService.java:11929)
11-17 18:07:52.374 4468-32163/? W/ActivityManager:     at com.android.server.am.ActivityManagerService.crashApplication(ActivityManagerService.java:12618)
11-17 18:07:52.374 4468-32163/? W/ActivityManager:     at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:12125)
11-17 18:07:52.374 4468-32163/? W/ActivityManager:     at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)
11-17 18:07:52.375 367-367/? E/lowmemorykiller: Error opening /proc/32137/oom_score_adj; errno=2
11-17 18:07:52.379 4468-6525/? I/ActivityManager: Process com.mycompany.myfirstglapp (pid 32137) has died
11-17 18:07:52.406 4468-6361/? W/InputMethodManagerService: Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4932df3 attribute=null, token = android.os.BinderProxy@45688ce
11-17 18:07:52.425 4468-28272/? I/OpenGLRenderer: Initialized EGL, version 1.4
11-17 18:07:52.559 27990-27990/? I/clatd: Detecting NAT64 prefix from DNS...
11-17 18:07:52.827 4468-5585/? D/ConnectivityService: notifyType CAP_CHANGED for NetworkAgentInfo [WIFI () - 308]
11-17 18:07:52.957 6526-6777/? W/OpenGLRenderer: Incorrectly called buildLayer on View: aep, destroying layer...
11-17 18:07:52.957 6526-6777/? W/OpenGLRenderer: Incorrectly called buildLayer on View: aep, destroying layer...
11-17 18:07:59.040 4468-5585/? D/ConnectivityService: notifyType CAP_CHANGED for NetworkAgentInfo [WIFI () - 308]
11-17 18:08:00.031 4468-6467/? I/AccountManagerService: getTypesVisibleToCaller: isPermitted? true
11-17 18:08:17.433 4468-5585/? D/ConnectivityService: notifyType CAP_CHANGED for NetworkAgentInfo [WIFI () - 308]
11-17 18:08:22.270 3330-3330/? E/QCALOG: [MessageQ] ProcessNewMessage: [LOWI-SERVER] unknown deliver target [OS-Agent]
11-17 18:08:23.640 4468-5585/? D/ConnectivityService: notifyType CAP_CHANGED for NetworkAgentInfo [WIFI () - 308]
11-17 18:08:32.613 27990-27990/? E/clatd: plat_prefix/dns(ipv4only.arpa) status = 7/No address associated with hostname
11-17 18:08:32.614 27990-27990/? W/clatd: dns64_detection -- error, sleeping for 120 seconds
11-17 18:08:51.446 4468-4506/? I/PowerManagerService: Going to sleep due to screen timeout (uid 1000)...

For good measure, I just tested on my 2013 Moto X running 5.1 and didn't get any errors.

@vfaSonnt
Copy link

I got the same issue on Nexus7 OS 5.0.2. with mapbox-android-sdk:2.2.0@aar

11-19 18:13:07.756 13747-13089/? A/google-breakpad: -----BEGIN BREAKPAD MICRODUMP-----
11-19 18:13:07.756 13747-13089/? A/google-breakpad: V WebView:46.0.2490.76
11-19 18:13:07.756 13747-13089/? A/google-breakpad: O A arm 04 armv7l google/nakasi/grouper:5.0.2/LRX22G/1649326:user/release-keys
11-19 18:13:07.757 13747-13089/? A/google-breakpad: S 0 BEEF1A78 BEEF1000 00002000
11-19 18:13:07.794 13747-13089/? A/google-breakpad: S BEEF1000 7C01000058BD67417C15EFBE00002A3F0000000000000
…….
11-19 18:13:11.960 13747-13089/? A/google-breakpad: -----END BREAKPAD MICRODUMP-----
11-19 18:13:11.982 13089-13089/? W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
11-19 18:13:11.982 13089-13089/? W/google-breakpad: Chrome build fingerprint:
11-19 18:13:11.982 13089-13089/? W/google-breakpad: 2.10.6
11-19 18:13:11.982 13089-13089/? W/google-breakpad: 30
11-19 18:13:11.982 13089-13089/? W/google-breakpad: 45012863-7d3b-4c30-8ccf-e65394c57d85
11-19 18:13:11.982 13089-13089/? W/google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
11-19 18:13:11.982 13089-13089/? A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 13089 (myapp.com)
11-19 18:13:12.542 133-133/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-19 18:13:12.542 133-133/? I/DEBUG: Build fingerprint: 'google/nakasi/grouper:5.0.2/LRX22G/1649326:user/release-keys'
11-19 18:13:12.542 133-133/? I/DEBUG: Revision: '0'
11-19 18:13:12.543 133-133/? I/DEBUG: ABI: 'arm'
11-19 18:13:12.543 133-133/? I/DEBUG: pid: 13089, tid: 13089, name: myapp.com  >>> ? <<<
11-19 18:13:12.543 133-133/? I/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
11-19 18:13:12.607 133-133/? I/DEBUG:     r0 00000000  r1 00003321  r2 00000006  r3 00000000
11-19 18:13:12.607 133-133/? I/DEBUG:     r4 40134114  r5 00000006  r6 00000016  r7 0000010c
11-19 18:13:12.607 133-133/? I/DEBUG:     r8 5f30e590  r9 beef1fe4  sl 5f6e500c  fp beef1ad8
11-19 18:13:12.607 133-133/? I/DEBUG:     ip 00003321  sp beef1a78  lr 4014b3c5  pc 40171648  cpsr 60070010
11-19 18:13:12.608 133-133/? I/DEBUG:     #00 pc 0003c648  /system/lib/libc.so (tgkill+12)
11-19 18:13:12.608 133-133/? I/DEBUG:     #01 pc 000163c1  /system/lib/libc.so (pthread_kill+52)
11-19 18:13:12.608 133-133/? I/DEBUG:     #02 pc 00016fdf  /system/lib/libc.so (raise+10)
11-19 18:13:12.608 133-133/? I/DEBUG:     #03 pc 00013819  /system/lib/libc.so
11-19 18:13:12.608 133-133/? I/DEBUG:     #04 pc 00011fe8  /system/lib/libc.so (abort+4)
11-19 18:13:12.608 133-133/? I/DEBUG:     #05 pc 00476480  /data/app/?-1/lib/arm/libmapbox-gl.so
11-19 18:13:12.608 133-133/? I/DEBUG:     #06 pc 004765b0  /data/app/?-1/lib/arm/libmapbox-gl.so
11-19 18:13:12.608 133-133/? I/DEBUG:     #07 pc 00466c08  /data/app/?-1/lib/arm/libmapbox-gl.so
11-19 18:13:12.608 133-133/? I/DEBUG:     #08 pc 00465e44  /data/app/?-1/lib/arm/libmapbox-gl.so (__cxa_throw+240)
11-19 18:13:12.608 133-133/? I/DEBUG:     #09 pc 0017cd18  /data/app/?-1/lib/arm/libmapbox-gl.so (mbgl::SpriteImage::SpriteImage(unsigned short, unsigned short, float, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, bool)+300)
11-19 18:13:12.608 133-133/? I/DEBUG:     #10 pc 0013a8f8  /data/app/?-1/lib/arm/libmapbox-gl.so
11-19 18:13:12.608 133-133/? I/DEBUG:     #11 pc 006ace4b  /data/dalvik-cache/arm/data@app@?-1@base.apk@classes.dex

This is source code I used to make marker.

SpriteFactory spriteFactory = new SpriteFactory(mapView);
                    Drawable drawable = ContextCompat.getDrawable(this, R.drawable.marker_red);
                    Sprite icon = spriteFactory.fromDrawable(drawable);
                    mapView.addMarker(new MarkerOptions()
                            .position(new LatLng(41.885, -87.679))
                            .title("Hello World!")
                            .snippet("Welcome to my marker.")
                            .icon(icon));

@incanus incanus added the crash label Nov 19, 2015
@zugaldia
Copy link
Member

@vfaSonnt thanks for the feedback. It doesn't seem like you were using the assets in the sample page, may I ask which assets resolutions are you using in your sample code?

@bleege bleege added this to the android-v2.3.0 milestone Nov 19, 2015
@vfaSonnt
Copy link

@zugaldia thank for the reply. I think I found the problem.
It crash in this method .

    public void setSprite(String symbol, int width, int height, float scale, byte[] pixels) {
        nativeSetSprite(mNativeMapViewPtr, symbol, width, height, scale, pixels);
    }

But it can run on android os JELLY_BEAN

public SpriteFactory(MapView mapView) {
        mMapView = mapView;
        DisplayMetrics realMetrics = null;
        DisplayMetrics metrics = new DisplayMetrics();
        WindowManager wm = (WindowManager) mMapView.getContext().getSystemService(Context.WINDOW_SERVICE);

        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            realMetrics = new DisplayMetrics();
            wm.getDefaultDisplay().getRealMetrics(realMetrics);
        }
        wm.getDefaultDisplay().getMetrics(metrics);

        mOptions = new BitmapFactory.Options();
        mOptions.inScaled = true;
        mOptions.inDensity = DisplayMetrics.DENSITY_DEFAULT;
        mOptions.inTargetDensity = metrics.densityDpi;
        if (realMetrics != null) {
            mOptions.inScreenDensity = realMetrics.densityDpi;
        }

    }

This is bitmap info.
screen shot 2015-11-19 at 7 15 03 pm

@afathman
Copy link

In my tests:
It crashes with the signal 6 (SIGABRT) error on Samsung Galaxy S6 running 5.1.1.
On the Nexus 5 running 6.0 same thing.
On the GT-I9I90 running 4.4.2, the maps will display the markers, but every marker will use the first resource I loaded (any attempt at using another picture for a marker will ignore the new resource I gave it).

@MrChaz
Copy link

MrChaz commented Nov 23, 2015

I'm seeing the same issue on 2.2.0
As best as I can tell it's a issue with truncating the width and height to an int.
MapView.java loadSprite() line 1664 does width / scale and truncates to int
SpriteImage.cpp line 17 then does width * scale

with a 590x290 image on a device with scale of 3.5 3 pixels are lost in the height causing an exception on line 25.

@tobrun
Copy link
Member

tobrun commented Nov 24, 2015

I have noticed this issue also, I created #3108, will close that one down in favor of this one:

Referencing symbolicated stacktrace from that issue:

********** Crash dump: **********
Build fingerprint: 'Android/vbox86p/vbox86p:6.0/MRA58K/buildbot10191552:userdebug/test-keys'
pid: 5560, tid: 5560, name: m.mapbox.sirius  >>> com.mapbox.sirius <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xdeadcab1
Stack frame #00 pc 0041c716  /data/app/com.mapbox.sirius-2/lib/x86/libmapbox-gl.so
Stack frame #01 pc 0041c755  /data/app/com.mapbox.sirius-2/lib/x86/libmapbox-gl.so
Stack frame #02 pc 0041c6f6  /data/app/com.mapbox.sirius-2/lib/x86/libmapbox-gl.so (std::terminate()+38)
Stack frame #03 pc 0041b325  /data/app/com.mapbox.sirius-2/lib/x86/libmapbox-gl.so
Stack frame #04 pc 0041ab36  /data/app/com.mapbox.sirius-2/lib/x86/libmapbox-gl.so
Stack frame #05 pc 0041aab3  /data/app/com.mapbox.sirius-2/lib/x86/libmapbox-gl.so
Stack frame #06 pc 0017e045  /data/app/com.mapbox.sirius-2/lib/x86/libmapbox-gl.so (mbgl::SpriteImage::SpriteImage(unsigned short, unsigned short, float, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&&, bool)+357)
Stack frame #07 pc 00134e14  /data/app/com.mapbox.sirius-2/lib/x86/libmapbox-gl.so
Stack frame #08 pc 0087d3f2  /data/app/com.mapbox.sirius-2/oat/x86/base.odex (offset 0x58b000) (void com.mapbox.mapboxsdk.views.NativeMapView.nativeSetSprite(long, java.lang.String, int, int, float, byte[])+214)
Stack frame #09 pc 008817a8  /data/app/com.mapbox.sirius-2/oat/x86/base.odex (offset 0x58b000) (void com.mapbox.mapboxsdk.views.NativeMapView.setSprite(java.lang.String, int, int, float, byte[])+188)
Stack frame #10 pc 0086d164  /data/app/com.mapbox.sirius-2/oat/x86/base.odex (offset 0x58b000) (void com.mapbox.mapboxsdk.views.MapView.loadSprite(com.mapbox.mapboxsdk.annotations.Sprite)+968)
Stack frame #11 pc 0086d3f3  /data/app/com.mapbox.sirius-2/oat/x86/base.odex (offset 0x58b000) (com.mapbox.mapboxsdk.annotations.Marker com.mapbox.mapboxsdk.views.MapView.prepareMarker(com.mapbox.mapboxsdk.annotations.MarkerOptions)+375)
Stack frame #12 pc 0086e754  /data/app/com.mapbox.sirius-2/oat/x86/base.odex (offset 0x58b000) (com.mapbox.mapboxsdk.annotations.Marker com.mapbox.mapboxsdk.views.MapView.addMarker(com.mapbox.mapboxsdk.annotations.MarkerOptions)+216)
Stack frame #13 pc 008927fd  /data/app/com.mapbox.sirius-2/oat/x86/base.odex (offset 0x58b000) (void com.mapbox.sirius.util.MapViewUtils.createMarkerAndMoveViewport(com.mapbox.mapboxsdk.views.MapView, com.mapbox.mapboxsdk.geometry.LatLng, com.mapbox.mapboxsdk.geometry.LatLng, java.lang.String)+1249)
Stack frame #14 pc 0088995a  /data/app/com.mapbox.sirius-2/oat/x86/base.odex (offset 0x58b000) (void com.mapbox.sirius.activity.DirectionsActivity$4.run()+254)
Stack frame #15 pc 73669c3b  /data/dalvik-cache/x86/system@framework@boot.oat (offset 0x1eb6000)

@zugaldia: here are the details to reproduce this issue:

  • screen shot 2015-11-24 at 11 30 38
  • Using this icon with size 12dp

LMK if you need extra 👀 on this

@bleege
Copy link
Contributor

bleege commented Nov 30, 2015

It crash in this method when bitmap's width and height are differrent.

Thanks for reporting this @vfaSonnt!

@afathman @MrChaz can you confirm this too with your apps?

If we can settle on this we can then move forward with a either a fix to ensure that width and height are always the same size and/or build out support for different sizes.

@bleege
Copy link
Contributor

bleege commented Nov 30, 2015

Discussed with @1ec5 @friedbunny @jfirebaugh and this appears to be an issue with the common Core GL as it's impacting iOS too. Work is being done at that level to address an issue with integer / float conversions.

@afathman
Copy link

afathman commented Dec 1, 2015

Yea, it crashes whether or not the dimensions are the same or different. Can confirm the issue is with the integer/float conversion.

@dino368
Copy link

dino368 commented Dec 2, 2015

I had the same issue! I found out that the image has to be 72x72! Try it out and replay.

EDIT: I think you can use all parts of 72. 216x216 also works.

@cesards
Copy link

cesards commented Dec 3, 2015

+1 here

@bleege bleege modified the milestones: android-v2.3.0, android-v2.4.0 Dec 4, 2015
@bleege
Copy link
Contributor

bleege commented Dec 7, 2015

The underlying issue is being addressed in #3164.

@bleege bleege modified the milestones: android-v3.0.0, android-v3.1.0 Dec 21, 2015
@mttpl
Copy link

mttpl commented Dec 29, 2015

+1
It's a serious issue, making Mapbox >=2.0 useless.

Notice this code in loadSprite function in MapView.java:

        float density = bitmap.getDensity();
        if (density == Bitmap.DENSITY_NONE) {
            density = DisplayMetrics.DENSITY_DEFAULT;
        }
        float scale = density / DisplayMetrics.DENSITY_DEFAULT;

        mNativeMapView.addAnnotationIcon(
                id,
                (int) (bitmap.getWidth() / scale),
                (int) (bitmap.getHeight() / scale),
                scale, buffer.array());

For certain devices sprite sizes such as 72x72 or 216x216 may work, but if some device has another DPI, this scaling may cause error described by @MrChaz. I've tested custom markers on 4 different devices and for every size work good on some devices and crash on another. To be honest, I doubt if the original markers work on all devices.

Thanks!

@spung
Copy link

spung commented Jan 5, 2016

Hi @bleege , any idea when this fix will be released? Thanks.

@danswick
Copy link
Contributor Author

danswick commented Jan 5, 2016

After some conversation with @zugaldia, I thought it would be helpful to mention that I'm seeing this issue pop up in roughly 1/3 of Android support requests over the last month or so.

cc: @tobrun

@jfirebaugh
Copy link
Contributor

I was working on changes that would have fixed this (#3164 / branch here) but got pulled onto offline priorities. Someone else will need to take over.

@bleege
Copy link
Contributor

bleege commented Jan 5, 2016

As @jfirebaugh reiterated this is an issue in Core GL (meaning it affects both iOS and Android) and is being addressed in #3164. In the interim, the recommended solution (on Android) is to use the square image assets (width x height) across the drawable density folders (drawable-hdpi, drawable--xhdpi, drawable-xxhdpi, drawable-xxxhdpi) or use vector image assets.

Also, please remember that Pull Requests are always welcomed. 😃

@jfirebaugh
Copy link
Contributor

I meant to mention in my previous comment: it's probable that there's an alternate / quicker fix than #3164 / this branch here, which is a deeper code cleanup that would fix this almost as a side effect.

@danswick
Copy link
Contributor Author

danswick commented Jan 6, 2016

Until this is sorted out in Core GL, it is recommended to follow Google's advice for scaling drawables:

To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8:12:16 scaling ratio between the six generalized densities. For example, if you have a bitmap drawable that's 48x48 pixels for medium-density screens, all the different sizes should be:

  • 36x36 (0.75x) for low-density
  • 48x48 (1.0x baseline) for medium-density
  • 72x72 (1.5x) for high-density
  • 96x96 (2.0x) for extra-high-density
  • 180x180 (3.0x) for extra-extra-high-density
  • 192x192 (4.0x) for extra-extra-extra-high-density

@ansis
Copy link
Contributor

ansis commented Jan 13, 2016

#3530 which implements #3164 should fix this. @bleege could you confirm that it's fixed?

@tobrun
Copy link
Member

tobrun commented Jan 14, 2016

@ansis I will take that up, I have locally a setup ready that used to crash

@ansis
Copy link
Contributor

ansis commented Jan 14, 2016

@tobrun thanks, based on @1ec5's test it'll probably crash #2198 (comment)

tobrun added a commit that referenced this issue Jan 14, 2016
@tobrun tobrun removed their assignment Jan 14, 2016
@tobrun
Copy link
Member

tobrun commented Jan 14, 2016

@ansis
Yes, validated that it's generating the same crashlog:

screen shot 2016-01-14 at 10 40 02

I just pushed my branch if you want to test your changes or ping me if I need to perform a test.

@jfirebaugh
Copy link
Contributor

That crashlog suggests that one of these validations is failing. That would indicate that this is a problem in the bindings:

ansis added a commit that referenced this issue Jan 15, 2016
ref #3031
ref #2198

For example, an icon that has:
- a pixel width of 10
- a pixel ratio of 3
- a scaled with of 3.333
is now supported.
ansis added a commit that referenced this issue Jan 16, 2016
ref #3031
ref #2198

For example, an icon that has:
- a pixel width of 10
- a pixel ratio of 3
- a scaled with of 3.333
is now supported.
ansis added a commit that referenced this issue Jan 20, 2016
ref #3031
ref #2198

For example, an icon that has:
- a pixel width of 10
- a pixel ratio of 3
- a scaled with of 3.333
is now supported.
@ansis
Copy link
Contributor

ansis commented Jan 20, 2016

this is fixed by #3561

@ansis ansis closed this as completed Jan 20, 2016
@ansis ansis removed the in progress label Jan 20, 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 crash
Projects
None yet
Development

No branches or pull requests