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

(Android) Crash when try to close map when it is displayed in black and no tiles #4181

Merged
merged 1 commit into from
Mar 7, 2016

Conversation

tmpsantos
Copy link
Contributor

Map is being displayed in a dialog. MapBox crashes when map is displayed in black and no tiles.

03-03 13:03:56.492 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb9c49b90
03-03 13:03:56.521 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb9776348
03-03 13:03:56.522 D/OpenGLRenderer: endAllActiveAnimators on 0xb9c2d428 (RippleDrawable) with handle 0xb958b570
03-03 13:03:56.593 I/mbgl: {Map}[Android]: Not activating as we are not ready
03-03 13:03:56.596 E/libEGL: call to OpenGL ES API with no current context (logged once per thread)
03-03 13:03:56.607 I/mbgl: {Map}[Android]: Not deactivating as we are not ready
03-03 13:03:56.658 W/com.mapbox.mapboxsdk.http.HTTPContext$HTTPRequest: [HTTP] Request could not be executed: Socket closed
03-03 13:03:56.666 A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 17548 (HTTPAndroidCont)

Another variation of error message displayed.

03-03 13:09:09.419 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb930d810
03-03 13:09:09.479 E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb930dc28
03-03 13:09:09.573 I/mbgl: {Map}[Android]: Not activating as we are not ready
03-03 13:09:09.593 E/libEGL: call to OpenGL ES API with no current context (logged once per thread)
03-03 13:09:09.603 I/mbgl: {Map}[Android]: Not deactivating as we are not ready
03-03 13:09:09.672 A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 23140 (HTTPAndroidCont)

This does not get displayed that often:

03-03 13:03:56.658 W/com.mapbox.mapboxsdk.http.HTTPContext$HTTPRequest: [HTTP] Request could not be executed: Socket closed

@tobrun tobrun added Android Mapbox Maps SDK for Android crash labels Mar 3, 2016
@tobrun
Copy link
Member

tobrun commented Mar 3, 2016

@ThinkingMonkey
Thank you for reaching out and reporting this problem. I was able to reproduce this by opening a screen with a map and closing the screen quickly by clicking the back button. I believe this source of the problem will be a destroyed context on the callback of an asynchronous method, probably related to callback from a webservice.

@tobrun tobrun added this to the android-v4.0.0 milestone Mar 3, 2016
@tobrun
Copy link
Member

tobrun commented Mar 3, 2016

Stacktrace:

03-03 14:14:29.853 14225-14264/com.mapbox.mapboxsdk.testapp V/com.mapbox.mapboxsdk.http.HTTPContext$HTTPRequest: [HTTP] Request was successful (code = 200).
03-03 14:14:29.875 14225-14283/com.mapbox.mapboxsdk.testapp V/com.mapbox.mapboxsdk.http.HTTPContext$HTTPRequest: [HTTP] Request was successful (code = 200).
03-03 14:14:29.919 14225-14405/com.mapbox.mapboxsdk.testapp E/libEGL: call to OpenGL ES API with no current context (logged once per thread)
03-03 14:14:29.919 14225-14405/com.mapbox.mapboxsdk.testapp I/mbgl: {Map}[Android]: Not deactivating as we are not ready
03-03 14:14:29.952 14225-14403/com.mapbox.mapboxsdk.testapp A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 14403 (HTTPAndroidCont)
03-03 14:14:29.958 14225-14273/com.mapbox.mapboxsdk.testapp W/com.mapbox.mapboxsdk.http.HTTPContext$HTTPRequest: [HTTP] Request could not be executed: Canceled
03-03 14:14:29.958 14225-14262/com.mapbox.mapboxsdk.testapp W/com.mapbox.mapboxsdk.http.HTTPContext$HTTPRequest: [HTTP] Request could not be executed: Canceled
03-03 14:14:30.062 200-200/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-03 14:14:30.063 200-200/? A/DEBUG: Build fingerprint: 'google/hammerhead/hammerhead:6.0/MPA44I/2172151:user/release-keys'
03-03 14:14:30.063 200-200/? A/DEBUG: Revision: '0'
03-03 14:14:30.063 200-200/? A/DEBUG: ABI: 'arm'
03-03 14:14:30.063 200-200/? A/DEBUG: pid: 14225, tid: 14403, name: HTTPAndroidCont  >>> com.mapbox.mapboxsdk.testapp <<<
03-03 14:14:30.063 200-200/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
03-03 14:14:30.090 200-200/? A/DEBUG:     r0 00000000  r1 00003843  r2 00000006  r3 9db31978
03-03 14:14:30.090 200-200/? A/DEBUG:     r4 9db31980  r5 9db31930  r6 00000000  r7 0000010c
03-03 14:14:30.090 200-200/? A/DEBUG:     r8 91b50ca8  r9 9adc5180  sl fffff4dc  fp 9db313c8
03-03 14:14:30.090 200-200/? A/DEBUG:     ip 00000006  sp 9db31368  lr b6cdeaf1  pc b6ce0e54  cpsr 400d0010
03-03 14:14:30.105 200-200/? A/DEBUG:     #00 pc 00041e54  /system/lib/libc.so (tgkill+12)
03-03 14:14:30.105 200-200/? A/DEBUG:     #01 pc 0003faed  /system/lib/libc.so (pthread_kill+32)
03-03 14:14:30.106 200-200/? A/DEBUG:     #02 pc 0001c30f  /system/lib/libc.so (raise+10)
03-03 14:14:30.106 200-200/? A/DEBUG:     #03 pc 000194c1  /system/lib/libc.so (__libc_android_abort+34)
03-03 14:14:30.106 200-200/? A/DEBUG:     #04 pc 000174ac  /system/lib/libc.so (abort+4)
03-03 14:14:30.106 200-200/? A/DEBUG:     #05 pc 003e9180  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
03-03 14:14:30.106 200-200/? A/DEBUG:     #06 pc 003e92b0  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
03-03 14:14:30.106 200-200/? A/DEBUG:     #07 pc 003d9908  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
03-03 14:14:30.106 200-200/? A/DEBUG:     #08 pc 003d99f4  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so (std::terminate()+136)
03-03 14:14:30.106 200-200/? A/DEBUG:     #09 pc 000e146c  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so

@tmpsantos
Copy link
Contributor

--------- beginning of crash
03-03 17:44:05.828  2516  2560 F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0xdeadcab1 in tid 2560 (HTTPAndroidCont)
03-03 17:44:05.828  1953  1969 W EGL_emulation: eglSurfaceAttrib not implemented
03-03 17:44:05.828  1953  1969 W OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xa429ea20, error=EGL_SUCCESS
03-03 17:44:05.951   949   949 I SELinux : SELinux: Loaded file_contexts contexts from /file_contexts.
03-03 17:44:05.952   949   949 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-03 17:44:05.952   949   949 F DEBUG   : Build fingerprint: 'Android/sdk_phone_x86/generic_x86:6.0/MASTER/2524533:userdebug/test-keys'
03-03 17:44:05.952   949   949 F DEBUG   : Revision: '0'
03-03 17:44:05.952   949   949 F DEBUG   : ABI: 'x86'
03-03 17:44:05.952   949   949 F DEBUG   : pid: 2516, tid: 2560, name: HTTPAndroidCont  >>> com.mapbox.mapboxsdk.testapp <<<
03-03 17:44:05.952   949   949 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xdeadcab1
03-03 17:44:05.954   949   949 F DEBUG   :     eax a38c3a10  ebx a39f0c68  ecx a38c3a10  edx 9feb53c0
03-03 17:44:05.954   949   949 F DEBUG   :     esi 00000000  edi 00000000
03-03 17:44:05.954   949   949 F DEBUG   :     xcs 00000073  xds 0000007b  xes 0000007b  xfs 00000000  xss 0000007b
03-03 17:44:05.954   949   949 F DEBUG   :     eip a38c3a26  ebp a32bf6f8  esp a32bf6e0  flags 00210292
03-03 17:44:05.956   949   949 F DEBUG   : 
03-03 17:44:05.956   949   949 F DEBUG   : backtrace:
03-03 17:44:05.956   949   949 F DEBUG   :     #00 pc 003afa26  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/x86/libmapbox-gl.so
03-03 17:44:05.956   949   949 F DEBUG   :     #01 pc 003afa65  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/x86/libmapbox-gl.so
03-03 17:44:05.956   949   949 F DEBUG   :     #02 pc 003afa06  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/x86/libmapbox-gl.so (std::terminate()+38)
03-03 17:44:05.956   949   949 F DEBUG   :     #03 pc 000e58e5  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/x86/libmapbox-gl.so
03-03 17:44:05.956   949   949 F DEBUG   :     #04 pc 0020dadc  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/x86/libmapbox-gl.so (mbgl::util::RunLoop::~RunLoop()+348)
03-03 17:44:05.956   949   949 F DEBUG   :     #05 pc 00224692  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/x86/libmapbox-gl.so (void mbgl::util::Thread<mbgl::OnlineFileSource::Impl>::run<std::__1::tuple<int>, 0u>(mbgl::util::ThreadContext, std::__1::tuple<int>&&, std::__1::integer_sequence<unsigned int, 0u>)+210)
03-03 17:44:05.956   949   949 F DEBUG   :     #06 pc 0022456b  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/x86/libmapbox-gl.so (mbgl::util::Thread<mbgl::OnlineFileSource::Impl>::Thread<int>(mbgl::util::ThreadContext const&, int&&)::'lambda'()::operator()() const+283)
03-03 17:44:05.956   949   949 F DEBUG   :     #07 pc 002243fb  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/x86/libmapbox-gl.so (std::__1::__thread_proxy<std::__1::tuple<mbgl::util::Thread<mbgl::OnlineFileSource::Impl>::Thread<int>(mbgl::util::ThreadContext const&, int&&)::'lambda'()> >(void*, void*)+123)
03-03 17:44:05.956   949   949 F DEBUG   :     #08 pc 00080a93  /system/lib/libc.so (__pthread_start(void*)+56)
03-03 17:44:05.956   949   949 F DEBUG   :     #09 pc 00021952  /system/lib/libc.so (__start_thread+25)
03-03 17:44:05.956   949   949 F DEBUG   :     #10 pc 000170b6  /system/lib/libc.so (__bionic_clone+70)
03-03 17:44:06.087   949   949 F DEBUG   : 
03-03 17:44:06.087   949   949 F DEBUG   : Tombstone written to: /data/tombstones/tombstone_00
03-03 17:44:06.087   949   949 E DEBUG   : AM write failed: Broken pipe

@tmpsantos tmpsantos self-assigned this Mar 3, 2016
@tmpsantos
Copy link
Contributor

This issue seems to be HTTPContext being a static at HTTPContext.java, outliving the OnlineFileSource. When the native object gets destroyed, we still get replies from the Java side.

@tobrun
Copy link
Member

tobrun commented Mar 3, 2016

Their is cancel method on HTTPContext.java that can be called from the nativeside or we need to find a way to check if the native object is being destroyed in onResponse or onFaillure and don't pass those down to native side.

@tmpsantos
Copy link
Contributor

👀 @tobrun @bleege

@tobrun
Copy link
Member

tobrun commented Mar 4, 2016

@tmpsantos great stuff, as promised -> 🙇

@jfirebaugh
Copy link
Contributor

@tmpsantos Can you rebase this on master post-#4193, using jni.hpp stuff? Thanks!

@tobrun
Copy link
Member

tobrun commented Mar 7, 2016

@tmpsantos requested extra 👀 on this. Going to test on a real device (he only tested with emulator)

@tobrun
Copy link
Member

tobrun commented Mar 7, 2016

@tmpsantos

I did a test with master and that produced:

3-07 17:59:40.367 2770-3163/? A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 3163 (Thread-7546)
03-07 17:59:40.469 201-201/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-07 17:59:40.469 201-201/? A/DEBUG: Build fingerprint: 'google/hammerhead/hammerhead:6.0/MPA44I/2172151:user/release-keys'
03-07 17:59:40.469 201-201/? A/DEBUG: Revision: '0'
03-07 17:59:40.469 201-201/? A/DEBUG: ABI: 'arm'
03-07 17:59:40.469 201-201/? A/DEBUG: pid: 2770, tid: 3163, name: Thread-7546  >>> com.mapbox.mapboxsdk.testapp <<<
03-07 17:59:40.469 201-201/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
03-07 17:59:40.504 201-201/? A/DEBUG:     r0 00000000  r1 00000c5b  r2 00000006  r3 9becd978
03-07 17:59:40.504 201-201/? A/DEBUG:     r4 9becd980  r5 9becd930  r6 00000000  r7 0000010c
03-07 17:59:40.504 201-201/? A/DEBUG:     r8 9a82b668  r9 914261c0  sl fffff484  fp 9becd3c0
03-07 17:59:40.504 201-201/? A/DEBUG:     ip 00000006  sp 9becd360  lr b6cbbaf1  pc b6cbde54  cpsr 400d0010
03-07 17:59:40.519 201-201/? A/DEBUG: backtrace:
03-07 17:59:40.519 201-201/? A/DEBUG:     #00 pc 00041e54  /system/lib/libc.so (tgkill+12)
03-07 17:59:40.519 201-201/? A/DEBUG:     #01 pc 0003faed  /system/lib/libc.so (pthread_kill+32)
03-07 17:59:40.520 201-201/? A/DEBUG:     #02 pc 0001c30f  /system/lib/libc.so (raise+10)
03-07 17:59:40.520 201-201/? A/DEBUG:     #03 pc 000194c1  /system/lib/libc.so (__libc_android_abort+34)
03-07 17:59:40.520 201-201/? A/DEBUG:     #04 pc 000174ac  /system/lib/libc.so (abort+4)
03-07 17:59:40.520 201-201/? A/DEBUG:     #05 pc 003f8970  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-07 17:59:40.520 201-201/? A/DEBUG:     #06 pc 003f8aa0  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-07 17:59:40.520 201-201/? A/DEBUG:     #07 pc 003e90f8  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-07 17:59:40.520 201-201/? A/DEBUG:     #08 pc 003e91e4  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so (std::terminate()+136)
03-07 17:59:40.520 201-201/? A/DEBUG:     #09 pc 000e48e8  /data/app/com.mapbox.mapboxsdk.testapp-2/lib/arm/libmapbox-gl.so
03-07 17:59:40.620 3197-3197/? E/STIB mobile - UALib: In-App Purchase is enabled, but missing com.android.vending.billing.IMarketBillingService. Disabling...
03-07 17:59:40.620 3197-3197/? E/STIB mobile - UALib: If using Proguard, add the following lines to your proguard.cfg:
03-07 17:59:40.620 3197-3197/? E/STIB mobile - UALib:    -keep class com.android.vending.billing.**

I did a test with this branch and was able to produce:

03-07 18:06:14.406 4569-4611/? D/com.mapbox.mapboxsdk.http.HTTPRequest: [HTTP] Request with response code = 304: Not Modified
03-07 18:06:14.506 201-201/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-07 18:06:14.506 201-201/? A/DEBUG: Build fingerprint: 'google/hammerhead/hammerhead:6.0/MPA44I/2172151:user/release-keys'
03-07 18:06:14.506 201-201/? A/DEBUG: Revision: '0'
03-07 18:06:14.506 201-201/? A/DEBUG: ABI: 'arm'
03-07 18:06:14.507 201-201/? A/DEBUG: pid: 4569, tid: 4676, name: Thread-7572  >>> com.mapbox.mapboxsdk.testapp <<<
03-07 18:06:14.507 201-201/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
03-07 18:06:14.521 201-201/? A/DEBUG:     r0 00000000  r1 00001244  r2 00000006  r3 99ac3978
03-07 18:06:14.521 201-201/? A/DEBUG:     r4 99ac3980  r5 99ac3930  r6 00000000  r7 0000010c
03-07 18:06:14.521 201-201/? A/DEBUG:     r8 980def28  r9 9a9e5aa0  sl fffff484  fp 99ac33c8
03-07 18:06:14.521 201-201/? A/DEBUG:     ip 00000006  sp 99ac3368  lr b6cbbaf1  pc b6cbde54  cpsr 400b0010
03-07 18:06:14.532 201-201/? A/DEBUG: backtrace:
03-07 18:06:14.532 201-201/? A/DEBUG:     #00 pc 00041e54  /system/lib/libc.so (tgkill+12)
03-07 18:06:14.532 201-201/? A/DEBUG:     #01 pc 0003faed  /system/lib/libc.so (pthread_kill+32)
03-07 18:06:14.532 201-201/? A/DEBUG:     #02 pc 0001c30f  /system/lib/libc.so (raise+10)
03-07 18:06:14.533 201-201/? A/DEBUG:     #03 pc 000194c1  /system/lib/libc.so (__libc_android_abort+34)
03-07 18:06:14.533 201-201/? A/DEBUG:     #04 pc 000174ac  /system/lib/libc.so (abort+4)
03-07 18:06:14.533 201-201/? A/DEBUG:     #05 pc 003f1740  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
03-07 18:06:14.533 201-201/? A/DEBUG:     #06 pc 003f1870  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
03-07 18:06:14.533 201-201/? A/DEBUG:     #07 pc 003e1ec8  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
03-07 18:06:14.533 201-201/? A/DEBUG:     #08 pc 003e1fb4  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so (std::terminate()+136)
03-07 18:06:14.533 201-201/? A/DEBUG:     #09 pc 000e448c  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so
03-07 18:06:15.326 201-201/? A/DEBUG: Tombstone written to: /data/tombstones/tombstone_09
03-07 18:06:15.326 201-201/? E/DEBUG: AM write failed: Broken pipe

Looking a the crash itself, it seems it's different than before.. for example it doesn't contain HttpContext.

@tmpsantos tmpsantos force-pushed the 4181-crash_on_close branch 2 times, most recently from 7953dcd to 5f6cd2f Compare March 7, 2016 20:35
@tmpsantos
Copy link
Contributor

Thanks for testing, found a race condition. Patch updated.

@tobrun
Copy link
Member

tobrun commented Mar 7, 2016

Until now unable to produce a crash with the typical open activity and quickly closing it 👍

Native will get destroyed before the Java HTTPRequest and asynchronous
requests might still get answered.

If the request gets canceled, we now clear the reference to the native
code and it will never reach it.

Lock is needed because OkHTTP replies on its own thread, so we need to
guard the access to the variable we use for checking if the Request was
canceled. In the future we could remove the lock and use Runnable when
we move Android main loop to Looper instead of libuv.

Like the other implementations of HTTPRequest on Mapbox GL Native, the
request is destroyed synchronously on ::cancel().
@tmpsantos tmpsantos force-pushed the 4181-crash_on_close branch from 5f6cd2f to fe811bd Compare March 7, 2016 22:14
@tmpsantos tmpsantos merged commit fe811bd into master Mar 7, 2016
@tmpsantos tmpsantos deleted the 4181-crash_on_close branch March 7, 2016 22:15
@bleege
Copy link
Contributor

bleege commented Mar 7, 2016

👍 @tobrun @tmpsantos

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

Successfully merging this pull request may close these issues.

5 participants