Mapbox-gl-native: Android crashes on startup

Created on 10 Nov 2015  路  54Comments  路  Source: mapbox/mapbox-gl-native

Hey guys,

Looks like mapbox crashes for some devices on start.

14620-14620/am.ggtaxi.main.ggdriver E/libEGL: validate_display:254 error 3008 (EGL_BAD_DISPLAY)
14620-14620/am.ggtaxi.main.ggdriver E/mbgl: {Main}[OpenGL]: eglCreateWindowSurface() returned error 12296
14620-14620/am.ggtaxi.main.ggdriver A/libc: Fatal signal 6 (SIGABRT) at 0x0000391c (code=-6), thread 14620 (i.main.ggdriver)

Device: Samsung Galaxy Tab Pro 8.4 3G/LTE
Android Version: 4.2.2

Android crash

Most helpful comment

@tobrun, my fault, you're right -- calling OnCreate() eliminated the EGL_BAD_DISPLAY error in my case. It would be nice if some code inside the Mapbox SDK checked the state initialized by OnCreate _before_ calling eglCreateWindowSurface, and throw a more helpful error if that state has not been initialized yet.

All 54 comments

Some more info:

11-10 19:21:00.328 25781-25781/am.ggtaxi.main.ggdriver I/mbgl: {Main}[OpenGL]: GL Vendor: Vivante Corporation
11-10 19:21:00.328 25781-25781/am.ggtaxi.main.ggdriver I/mbgl: {Main}[OpenGL]: GL Renderer: Vivante GC1000
11-10 19:21:00.328 25781-25781/am.ggtaxi.main.ggdriver I/mbgl: {Main}[OpenGL]: GL Version: OpenGL ES 2.0
11-10 19:21:00.328 25781-25781/am.ggtaxi.main.ggdriver I/mbgl: {Main}[OpenGL]: GL SL Version: OpenGL ES GLSL ES 1.00
11-10 19:21:00.328 25781-25781/am.ggtaxi.main.ggdriver I/mbgl: {Main}[OpenGL]: GL Extensions: GL_EXT_debug_marker GL_OES_compressed_ETC1_RGB8_texture GL_OES_compressed_paletted_texture GL_OES_EGL_image GL_OES_depth24 GL_OES_fbo_render_mipmap GL_OES_fragment_precision_high GL_OES_rgb8_rgba8 GL_OES_stencil1 GL_OES_stencil4 GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_depth_texture GL_OES_packed_depth_stencil GL_OES_standard_derivatives GL_OES_get_program_binary GL_EXT_texture_format_BGRA8888 GL_IMG_read_format GL_EXT_blend_minmax GL_EXT_read_format_bgra GL_EXT_multi_draw_arrays GL_APPLE_texture
11-10 19:21:00.328 25781-25781/am.ggtaxi.main.ggdriver I/mbgl: {Main}[OpenGL]: GL Extensions: _format_BGRA8888 GL_APPLE_texture_max_level GL_ARM_rgba8 GL_EXT_frag_depth GL_VIV_shader_binary GL_VIV_direct_texture GL_OES_EGL_image_external GL_EXT_discard_framebuffer GL_EXT_multisampled_render_to_texture GL_VIV_clamp_to_border GL_MRVL_texture_video GL_EXT_unpack_subimage GL_OES_element_index_uint GL_OES_mapbuffer GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_s3tc
11-10 19:21:01.329 25781-26261/am.ggtaxi.main.ggdriver E/libEGL: eglMakeCurrent:779 error 3002 (EGL_BAD_ACCESS)
11-10 19:21:01.329 25781-26261/am.ggtaxi.main.ggdriver E/mbgl: {Map}[OpenGL]: eglMakeCurrent() returned error 12290
11-10 19:21:01.329 25781-26261/am.ggtaxi.main.ggdriver A/libc: Fatal signal 6 (SIGABRT) at 0x000064b5 (code=-6), thread 26261 (i.main.ggdriver)

@iCyberon Can you see if you can find the native stack trace.

In logcat change the "Show only selected application" to "No filter"

In the search box put "DEBUG"
You should see a bunch of lines where the first line is a series of -------

The same on Samsung Galaxy Tab 3 7.0, Android 4.2.2. This seems to be the origin of the error https://github.com/mapbox/mapbox-gl-native/blob/43dde0f204ac770feae0ef22c7a4ea67585deb12/platform/android/native_map_view.cpp#L140

I'm getting the same error 3008 (EGL_BAD_DISPLAY) in eglCreateWindowSurface when creating a MapView on these devices:

  • Kindle Fire HD 3rd Gen running Fire OS 4.5.5 (based on Android 4.4)
  • Visual Studio Android Emulator 7" XHDPI Tablet running Android 4.4 (similar to Asus Google Nexus 7)
  • Visual Studio Android Emulator 7" XHDPI Tablet running Android 5.1.1 (similar to Asus Google Nexus 7)

Totally blocked right now... :(

I think this only happens on tablets.

Attaching some relevant debug log info from the Kindle Fire HD after enabling OpenGL traces (logcat) in Developer Options.

From Xamarin Studio debugger's Application Output window:
mapbox-opengl-error-log.txt

Logcat details from DDMS:
mapbox-opengl-error-stack-trace.txt

@iCyberon, possible -- all my previous tests above were tablets. However, I just tried it on VS Android Emulator 5.5" XXHPDI Phone running Android 5.1.1 (similar to LG G4) and got the same error.

@bmeyers43 It's related to DPI I guess. http://forum.xda-developers.com/showthread.php?t=2212632

Maybe...that bug was happening in eglSwapBuffers, but we're seeing it in eglCreateWindowSurface. Also, the Fire HD reports 216 dpi, while the VS Emulator images both claim to be 323 dpi, so I'm not sure what values/ranges would lead to this error.

on x86 architecture using Genymotion and latest SNAPSHOT, I was able to:

  • run it on + 5.0.0 devices
  • crash on pre 5.0.0 devices

Note: I was able to run on 4.2.2 wiht ARM without a problem

I am getting the same crash on a Sony Z2(5.1.1) and a Nexus 4(5.1.1).

Never mind, by bad :-)

@tobrun, since you are able to repro on at least some devices now, when do you think this will get assigned/fixed?

Looking into this:
Will use android 4.2.2 on x86 (nexus 7 genymotion):

Used following build command:

BUILDTYPE=Debug make android-lib-x86

I'm getting following recurring stacktraces:

http://pastebin.com/6eLwYTHX

Result after symbolicating:

http://pastebin.com/4fqVTXUG

The reference of NativeMapView InitializeDisplay in JNI refers to this

void JNICALL nativeInitializeDisplay(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
    mbgl::Log::Debug(mbgl::Event::JNI, "nativeInitializeDisplay");
    assert(nativeMapViewPtr != 0);
    NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);

    try
    {
        nativeMapView->initializeDisplay();
    } catch(const std::exception& e) {
        throw_jni_error(env, "Unable to initialize GL display.");
    }
}

That will call the underlying code in native_map_view.cpp:

void NativeMapView::initializeDisplay() {
    mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::initializeDisplay");

    assert(display == EGL_NO_DISPLAY);
    assert(config == nullptr);
    assert(format < 0);

    display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    if (display == EGL_NO_DISPLAY) {
        mbgl::Log::Error(mbgl::Event::OpenGL, "eglGetDisplay() returned error %d", eglGetError());
        throw new std::runtime_error("eglGetDisplay() failed");
    }

    EGLint major, minor;
    if (!eglInitialize(display, &major, &minor)) {
        mbgl::Log::Error(mbgl::Event::OpenGL, "eglInitialize() returned error %d", eglGetError());
        throw new std::runtime_error("eglInitialize() failed");
    }
    if ((major <= 1) && (minor < 3)) {
        mbgl::Log::Error(mbgl::Event::OpenGL, "EGL version is too low, need 1.3, got %d.%d", major,
                         minor);
        throw new std::runtime_error("EGL version is too low");
    }

    log_egl_string(display, EGL_VENDOR, "Vendor");
    log_egl_string(display, EGL_VERSION, "Version");
    log_egl_string(display, EGL_CLIENT_APIS, "Client APIs");
    log_egl_string(display, EGL_EXTENSIONS, "Client Extensions");

    // Detect if we are in emulator
    if (inEmulator()) {
        mbgl::Log::Warning(mbgl::Event::Android, "In emulator! Enabling hacks :-(");
    }

    // Get all configs at least RGB 565 with 16 depth and 8 stencil
    EGLint configAttribs[] = {
        EGL_CONFIG_CAVEAT,                               EGL_NONE,           EGL_RENDERABLE_TYPE,
        EGL_OPENGL_ES2_BIT,                              EGL_SURFACE_TYPE,   EGL_WINDOW_BIT,
        EGL_BUFFER_SIZE,                                 16,                 EGL_RED_SIZE,
        5,                                               EGL_GREEN_SIZE,     6,
        EGL_BLUE_SIZE,                                   5,                  EGL_DEPTH_SIZE,
        16,                                              EGL_STENCIL_SIZE,   8,
        (inEmulator() ? EGL_NONE : EGL_CONFORMANT),        EGL_OPENGL_ES2_BIT, // Ugly hack
        (inEmulator() ? EGL_NONE : EGL_COLOR_BUFFER_TYPE), EGL_RGB_BUFFER,     // Ugly hack
        EGL_NONE};
    EGLint numConfigs;
    if (!eglChooseConfig(display, configAttribs, nullptr, 0, &numConfigs)) {
        mbgl::Log::Error(mbgl::Event::OpenGL, "eglChooseConfig(NULL) returned error %d",
                         eglGetError());
        throw new std::runtime_error("eglChooseConfig() failed");
    }
    if (numConfigs < 1) {
        mbgl::Log::Error(mbgl::Event::OpenGL, "eglChooseConfig() returned no configs.");
        throw new std::runtime_error("eglChooseConfig() failed");
    }

    const auto configs = std::make_unique<EGLConfig[]>(numConfigs);
    if (!eglChooseConfig(display, configAttribs, configs.get(), numConfigs, &numConfigs)) {
        mbgl::Log::Error(mbgl::Event::OpenGL, "eglChooseConfig() returned error %d", eglGetError());
        throw new std::runtime_error("eglChooseConfig() failed");
    }

    config = chooseConfig(configs.get(), numConfigs);
    if (config == nullptr) {
        mbgl::Log::Error(mbgl::Event::OpenGL, "No config chosen");
        throw new std::runtime_error("No config chosen");
    }

    if (!eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format)) {
        mbgl::Log::Error(mbgl::Event::OpenGL, "eglGetConfigAttrib() returned error %d",
                         eglGetError());
        throw new std::runtime_error("eglGetConfigAttrib() failed");
    }
    mbgl::Log::Info(mbgl::Event::OpenGL, "Chosen window format is %d", format);
}

A difference I'm noticing between the working genymotion images versus non-working are the GL version:

Not working logs:

OpenGL ES-CM 1.1 (2.1 INTEL-10.10.18)

Working logs:

OpenGL ES 2.0 (2.1 INTEL-10.10.18)

Also I found this #573 from @ljbade,
it indicates problems related to getting OpenGL ES 2.0 working on emulators.

I'm putting above as a works as designed, the SDK requires a minimum version of OpenGL ES 2.0, we can't enforce this ourselves while running from the IDE but Google Play will filter out devices not having this requirement. The reason why that virtual machine is not able to use the host machine GPU is very strange to me. Need to reach out to Genymotion to get more information.

After investigating my startup crash I'm back at square one.
I will try to approach each mentioned problem above individually:

@iCyberon, @vkurchatkin: Could you add the stack trace @ljbade requested?
Without that trace it will be difficult to investigate the issue.

@bmeyers43: I stumbled on your thread on the Xamarin forums. Since this is not working on any devices for you, I believe something else is going wrong. Is it possible that you are not hooking into the required lifecycle methods as shown here?

Thank you in advance,

@vkurchatkin

Thank you, this is the result after symbolicating the crash:

*** Crash dump: ***
Build fingerprint: 'samsung/goya3gxx/goya3g:4.2.2/JDQ39/T111XXUAOE1:user/release-keys'
pid: 5147, tid: 5186, name: Map >>> com.mapbox.mapboxgl.testapp <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
Stack frame #00 pc 0001ad02 /system/lib/libc.so
Stack frame #01 pc 000180a0 /system/lib/libc.so (abort+4)
Stack frame #02 pc 003e0440 /data/app-lib/com.mapbox.mapboxgl.testapp-7/libmapbox-gl.so
Stack frame #03 pc 003e05b4 /data/app-lib/com.mapbox.mapboxgl.testapp-7/libmapbox-gl.so
Stack frame #04 pc 003d0bc8 /data/app-lib/com.mapbox.mapboxgl.testapp-7/libmapbox-gl.so

fault addr deadbaad on libc.so indicates that there is a problem with a corrupt memory heap.

/cc @zugaldia

@tobrun but doesn't it happen AFTER eglMakeCurrent returns an error? this seems to be the root of the problem

@vkurchatkin I believe you are right,

eglMakeCurrent is currently returning EGL_BAD_ACCESS

From Romain Guy:
Two possible reasons for this failure:

  • If ctx is current to some other thread, or if either draw or read are bound to contexts in another thread, an EGL_BAD_ACCESS error is generated.
  • If binding ctx would exceed the number of current contexts of that client API type supported by the implementation, an EGL_BAD_ACCESS error is generated.

It could also be that the GPU you are using on tablets does not support shared context.

It could also be that the GPU you are using on tablets does not support shared context.

does this mean that nothing can be done about it?

@tobrun ping. (sorry for being annoying)

@vkurchatkin no issue! I really want to get to the bottom of this.
Would you be possible to share the code where you are setting up the MapView?

@tobrun I can reproduce the issue with MapboxGLAndroidSDKTestApp

@tobrun, my fault, you're right -- calling OnCreate() eliminated the EGL_BAD_DISPLAY error in my case. It would be nice if some code inside the Mapbox SDK checked the state initialized by OnCreate _before_ calling eglCreateWindowSurface, and throw a more helpful error if that state has not been initialized yet.

+1 here!

12-03 01:38:52.931 31950-31950/? A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 31950 (.gembas.android)
12-03 01:38:52.981 2965-2965/? I/DEBUG: pid: 31950, tid: 31950, name: .gembas.android  >>> com.gembas.android <<<
12-03 01:38:53.001 2965-2965/? I/DEBUG:     #05 pc 00476480  /data/app/com.gembas.android-2/lib/arm/libmapbox-gl.so
12-03 01:38:53.001 2965-2965/? I/DEBUG:     #06 pc 004765f4  /data/app/com.gembas.android-2/lib/arm/libmapbox-gl.so
12-03 01:38:53.001 2965-2965/? I/DEBUG:     #07 pc 00466c08  /data/app/com.gembas.android-2/lib/arm/libmapbox-gl.so
12-03 01:38:53.001 2965-2965/? I/DEBUG:     #08 pc 00465e44  /data/app/com.gembas.android-2/lib/arm/libmapbox-gl.so (__cxa_throw+240)
12-03 01:38:53.001 2965-2965/? I/DEBUG:     #09 pc 00130490  /data/app/com.gembas.android-2/lib/arm/libmapbox-gl.so (mbgl::android::NativeMapView::createSurface(ANativeWindow*)+776)
12-03 01:38:53.001 2965-2965/? I/DEBUG:     #10 pc 00136618  /data/app/com.gembas.android-2/lib/arm/libmapbox-gl.so

I have same error (nexus 5)

12-08 17:09:06.750 27089-27089/? E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
12-08 17:09:06.750 27089-27089/? E/mbgl: {Main}[OpenGL]: eglCreateWindowSurface() returned error 12296
12-08 17:09:06.751 27089-27089/? A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 27089 (com.CatTaxi)
12-08 17:09:06.852 201-201/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
12-08 17:09:06.852 201-201/? A/DEBUG: Build fingerprint: 'google/hammerhead/hammerhead:6.0/MRA58N/2289998:user/release-keys'
12-08 17:09:06.852 201-201/? A/DEBUG: Revision: '0'
12-08 17:09:06.852 201-201/? A/DEBUG: ABI: 'arm'
12-08 17:09:06.852 201-201/? A/DEBUG: pid: 27089, tid: 27089, name: com.CatTaxi  >>> com.CatTaxi <<<
12-08 17:09:06.852 201-201/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
12-08 17:09:06.864 201-201/? A/DEBUG:     r0 00000000  r1 000069d1  r2 00000006  r3 b6fb5b7c
12-08 17:09:06.864 201-201/? A/DEBUG:     r4 b6fb5b84  r5 b6fb5b34  r6 0000000b  r7 0000010c
12-08 17:09:06.864 201-201/? A/DEBUG:     r8 00000438  r9 b4db6500  sl 000006a8  fp be9c3308
12-08 17:09:06.864 201-201/? A/DEBUG:     ip 00000006  sp be9c32a8  lr b6d24ae9  pc b6d2578c  cpsr 400d0010
12-08 17:09:06.878 201-201/? A/DEBUG:     #00 pc 0004078c  /system/lib/libc.so (tgkill+12)
12-08 17:09:06.878 201-201/? A/DEBUG:     #01 pc 0003fae5  /system/lib/libc.so (pthread_kill+32)
12-08 17:09:06.878 201-201/? A/DEBUG:     #02 pc 0001c30f  /system/lib/libc.so (raise+10)
12-08 17:09:06.878 201-201/? A/DEBUG:     #03 pc 000194c1  /system/lib/libc.so (__libc_android_abort+34)
12-08 17:09:06.878 201-201/? A/DEBUG:     #04 pc 000174ac  /system/lib/libc.so (abort+4)
12-08 17:09:06.878 201-201/? A/DEBUG:     #05 pc 003bc240  /data/app/com.CatTaxi-2/lib/arm/libmapbox-gl.so
12-08 17:09:06.879 201-201/? A/DEBUG:     #06 pc 003bc3b4  /data/app/com.CatTaxi-2/lib/arm/libmapbox-gl.so
12-08 17:09:06.879 201-201/? A/DEBUG:     #07 pc 003ac9c8  /data/app/com.CatTaxi-2/lib/arm/libmapbox-gl.so
12-08 17:09:06.879 201-201/? A/DEBUG:     #08 pc 003abc04  /data/app/com.CatTaxi-2/lib/arm/libmapbox-gl.so (__cxa_throw+240)
12-08 17:09:06.879 201-201/? A/DEBUG:     #09 pc 000ce818  /data/app/com.CatTaxi-2/lib/arm/libmapbox-gl.so (mbgl::android::NativeMapView::createSurface(ANativeWindow*)+776)
12-08 17:09:06.879 201-201/? A/DEBUG:     #10 pc 000d45f4  /data/app/com.CatTaxi-2/lib/arm/libmapbox-gl.so
12-08 17:09:06.879 201-201/? A/DEBUG:     #11 pc 01ca4d25  /data/app/com.CatTaxi-2/oat/arm/base.odex (offset 0xeea000) (void com.mapbox.mapboxsdk.views.NativeMapView.nativeCreateSurface(long, android.view.Surface)+120)
12-08 17:09:06.879 201-201/? A/DEBUG:     #12 pc 01ca7ef5  /data/app/com.CatTaxi-2/oat/arm/base.odex (offset 0xeea000) (void com.mapbox.mapboxsdk.views.NativeMapView.createSurface(android.view.Surface)+88)
12-08 17:09:06.879 201-201/? A/DEBUG:     #13 pc 01c933db  /data/app/com.CatTaxi-2/oat/arm/base.odex (offset 0xeea000) (void com.mapbox.mapboxsdk.views.MapView$SurfaceTextureListener.onSurfaceTextureAvailable(android.graphics.SurfaceTexture, int, int)+190)
12-08 17:09:06.879 201-201/? A/DEBUG:     #14 pc 7448725b  /data/dalvik-cache/arm/system@[email protected] (offset 0x1eb1000)

Same here, tried in GenyMotion nexus 5, android emulator nexus 5, Samsung s5, and OnePlus One. All crash with the same error.

12-11 11:17:44.155 243-243/? I/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
12-11 11:17:44.169 243-243/? I/DEBUG:     r0 00000000  r1 00002a18  r2 00000006  r3 00000000
12-11 11:17:44.169 243-243/? I/DEBUG:     r4 b6f9de38  r5 00000006  r6 0000000b  r7 0000010c
12-11 11:17:44.169 243-243/? I/DEBUG:     r8 131df5c0  r9 b4827800  sl 7422d768  fp bef77e18
12-11 11:17:44.169 243-243/? I/DEBUG:     ip 00002a18  sp bef77db8  lr b6e1d961  pc b6e406bc  cpsr 60000010
12-11 11:17:44.169 243-243/? I/DEBUG:     #00 pc 000376bc  /system/lib/libc.so (tgkill+12)
12-11 11:17:44.170 243-243/? I/DEBUG:     #01 pc 0001495d  /system/lib/libc.so (pthread_kill+52)
12-11 11:17:44.170 243-243/? I/DEBUG:     #02 pc 000156bf  /system/lib/libc.so (raise+10)
12-11 11:17:44.170 243-243/? I/DEBUG:     #03 pc 00011d25  /system/lib/libc.so (__libc_android_abort+36)
12-11 11:17:44.170 243-243/? I/DEBUG:     #04 pc 000100bc  /system/lib/libc.so (abort+4)
12-11 11:17:44.170 243-243/? I/DEBUG:     #05 pc 003c37e8  /data/app/com.excointouch.mobilize.target-2/lib/arm/libmapbox-gl.so
12-11 11:17:44.171 243-243/? I/DEBUG:     #06 pc 003c395c  /data/app/com.excointouch.mobilize.target-2/lib/arm/libmapbox-gl.so
12-11 11:17:44.171 243-243/? I/DEBUG:     #07 pc 003b3f70  /data/app/com.excointouch.mobilize.target-2/lib/arm/libmapbox-gl.so
12-11 11:17:44.171 243-243/? I/DEBUG:     #08 pc 003b31ac  /data/app/com.excointouch.mobilize.target-2/lib/arm/libmapbox-gl.so (__cxa_throw+240)
12-11 11:17:44.171 243-243/? I/DEBUG:     #09 pc 000d19e8  /data/app/com.excointouch.mobilize.target-2/lib/arm/libmapbox-gl.so (mbgl::android::NativeMapView::createSurface(ANativeWindow*)+776)
12-11 11:17:44.171 243-243/? I/DEBUG:     #10 pc 000d77c4  /data/app/com.excointouch.mobilize.target-2/lib/arm/libmapbox-gl.so
12-11 11:17:44.172 243-243/? I/DEBUG:     #11 pc 0012551d  /data/dalvik-cache/arm/data@[email protected]@[email protected]

@cesards
Could you share some details about the device? are you able to run it on another emulator/device?

@ells1231 @yanaperhun
Could you share the code where you're setting up the MapView? I believe this issue is related a misconfiguration of the MapView, I have it running on a Nexus 5 here without an issue.

@tobrun I used two real devices: Moto G 3th generation and Galaxy S6. You should have a look because it looks like it's something that's not related to the device.

@tobrun
I've only added the MapView to the layout file as per the guide:

    <com.mapbox.mapboxsdk.views.MapView
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        mapbox:access_token="my token is here"/>

And I'm using gradle with this in the build.gradle:

repositories {
    mavenCentral()
}

dependencies {
    compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:2.3.0@aar'){
        transitive=true
    }
}

I've also tried with the snapshot version.

I did the same

@ells1231 @cesards
Are you hooking into the Activity Lifecycle methods as shown here?

@danswick @bleege
I'm noticing that the landing page do not shown these or indicate that these are required. Can we add a note to that page? and maybe link the example directly?
I believe most problems reported here originate from that problem. This seems like a quick win to lower developer friction and to have a more clear setup guide.

@bleege @zugaldia
I thinking about looking into the suggestion from @bmeyers43:

It would be nice if some code inside the Mapbox SDK checked the state initialized by OnCreate before calling eglCreateWindowSurface, and throw a more helpful error if that state has not been initialized yet.

This would be similar to what the Android SDK does for its Activity lifecycle methods where the android.app.SuperNotCalledException exception is thrown. This would greatly improve the experience for developers who are integrating our maps.

@tobrun
Cheers that's fixed it

It could also be that the GPU you are using on tablets does not support shared context.

@tobrun just to make things clear, if this is the reason for this crash, does this mean that mapbox-gl-native will never work on such devices?

@vkurchatkin +1

@tobrun Hi! I've managed to run Test App applying the following changes:

diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index d32f3c8..b15997b 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -429,6 +429,12 @@ void NativeMapView::createSurface(ANativeWindow *window_) {
             oldDisplay = display;
         }

+        if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
+            mbgl::Log::Error(mbgl::Event::OpenGL,
+                             "eglMakeCurrent(EGL_NO_CONTEXT) returned error %d", eglGetError());
+            throw new std::runtime_error("eglMakeCurrent() failed");
+        }
+
         if (!eglMakeCurrent(oldDisplay, oldDrawSurface, oldReadSurface, oldContext)) {
             mbgl::Log::Error(mbgl::Event::OpenGL,
                              "eglMakeCurrent(EGL_NO_CONTEXT) returned error %d", eglGetError());

I have literally 0 knowledge of OpenGL, so I can't fully explain what's going on, but it seems eglMakeCurrent(oldDisplay, oldDrawSurface, oldReadSurface, oldContext) wasn't actually releasing context, so subsequent eglMakeCurrent failed on devices that don't support sharing contexts.

I hope this is useful.

/cc @jfirebaugh @kkaefer

@vkurchatkin with that code in place you are able to run on a device that initially gave crashes?

@tobrun yep, it seems that all features work as expected

Getting the same issue with the plain Mapbox Android SDK

10-25 23:16:35.504 2444-2444/? E/mbgl: [Shader]: Shader failed to compile: ERROR: Valid GLSL but not GLSL ES
10-25 23:16:35.504 2444-2444/? E/mbgl: [Shader]: Vertex shader fill failed to compile: precision highp float;

ifdef GL_ES

precision highp float;

else

define lowp

define mediump

define highp

endif

attribute vec2 a_pos;
uniform mat4 u_matrix;
void main() {
gl_Position = u_matrix * vec4(a_pos, 0, 1);
}
--------- beginning of crash
10-25 23:16:35.506 2444-2444/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xdeadcab1 in tid 2444 (oid.untamedmaps)
10-25 23:16:35.607 1132-1132/? I/DEBUG: * ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
10-25 23:16:35.607 1132-1132/? I/DEBUG: Build fingerprint: 'Android/sdk_phone_x86_64/generic_x86_64:5.1.1/LMY48X/2780077:userdebug/test-keys'
10-25 23:16:35.608 1132-1132/? I/DEBUG: Revision: '0'
10-25 23:16:35.608 1132-1132/? I/DEBUG: ABI: 'x86_64'
10-25 23:16:35.608 1132-1132/? I/DEBUG: pid: 2444, tid: 2444, name: oid.untamedmaps >>> systems.eddon.android.untamedmaps <<<
10-25 23:16:35.608 1132-1132/? I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xdeadcab1
10-25 23:16:35.618 1132-1132/? I/DEBUG: rax 00000000deadcab1 rbx 00007fff34ed3170 rcx 0000000000000000 rdx 00007f9c04605700
10-25 23:16:35.618 1132-1132/? I/DEBUG: rsi 00007fff34ed31b8 rdi 00007f9c05fe4b60
10-25 23:16:35.618 1132-1132/? I/DEBUG: r8 00007fff34ed2f60 r9 00007f9c0621cb01 r10 00007f9c0623acd0 r11 00007f9c05d93000
10-25 23:16:35.618 1132-1132/? I/DEBUG: r12 00007f9c1ba997c0 r13 000000001308c220 r14 00007fff34ed31b8 r15 00007f9c180c7300
10-25 23:16:35.618 1132-1132/? I/DEBUG: cs 0000000000000033 ss 000000000000002b
10-25 23:16:35.618 1132-1132/? I/DEBUG: rip 00007f9c05fe4b6d rbp 00007fff34ed3130 rsp 00007fff34ed3130 eflags 0000000000010206
10-25 23:16:35.618 1132-1132/? I/DEBUG: backtrace:
10-25 23:16:35.618 1132-1132/? I/DEBUG: #00 pc 0000000000251b6d /data/app/systems.eddon.android.untamedmaps-1/lib/x86_64/libmapbox-gl.so
10-25 23:16:35.618 1132-1132/? I/DEBUG: #01 pc 0000000000251b97 /data/app/systems.eddon.android.untamedmaps-1/lib/x86_64/libmapbox-gl.so
10-25 23:16:35.618 1132-1132/? I/DEBUG: #02 pc 0000000000251b56 /data/app/systems.eddon.android.untamedmaps-1/lib/x86_64/libmapbox-gl.so (std::terminate()+22)
10-25 23:16:35.619 1132-1132/? I/DEBUG: #03 pc 00000000002524c4 /data/app/systems.eddon.android.untamedmaps-1/lib/x86_64/libmapbox-gl.so (std::rethrow_exception(std::exception_ptr)+20)
10-25 23:16:35.619 1132-1132/? I/DEBUG: #04 pc 0000000000105bc9 /data/app/systems.eddon.android.untamedmaps-1/lib/x86_64/libmapbox-gl.so (jni::ThrowJavaError(_JNIEnv&, std::exception_ptr)+57)
10-25 23:16:35.619 1132-1132/? I/DEBUG: #05 pc 000000000011483f /data/app/systems.eddon.android.untamedmaps-1/lib/x86_64/libmapbox-gl.so
10-25 23:16:35.619 1132-1132/? I/DEBUG: #06 pc 00000000000381f3 /data/data/systems.eddon.android.untamedmaps/cache/slice-com.mapbox.mapboxsdk-mapbox-android-sdk-4.1.1_1a31abfec8c174e9a709d81268f840582d8f19d6-classes.dex

note - happens on all RemixOS, likely all Android_x86

@uudruid74 Thanks for the report. What version of the Mapbox Android SDK, the Android OS, and which devices are you using? Thanks!

I'm also experiencing Valid GLSL but not GLSL ESwhile configuring my emulator to use Hardware - GLES 2.0 (also referenced in stack overflow: #1 and #2).

Additional information:

  • Mapbox Android SDK from master branch (edf40bb6d9f0ee3731f39de597ce9a167571ea5b)

    • Tested on both android-lib-x86 and android-lib-x86-64 targets

  • Android Studio 2.2.2 (from Homebrew cask)
  • Android SDK 7.1.1 (Nougat) - API level 25
  • Intel x86 Emulator Accelerator (HAXM installer) 6.0.3

@zugdalia: Latest RemixOS based on Marshmallow (6.0.1) - identicle OSs, different CPUs (both x86_64) and different graphics drivers. Two are laptops, one an Asus X200CA - Intel/Ivybridge graphics. The other an HP with an AMD A8-4555M (Radeon graphics using Gallium driver). These are both OpenGL 3.0 ES compliant (and below). Also have got the same exact error from the Android Studio emulator on the same HP/AMD system under Antergos/Linux. The SDK is actually spelled out in the dump above in the last line.

It seems to be an issue with the #define lines (compile on demand maybe? llvm?). Looks like there may have been a resolution in Issue #7044

I've not seen if a newer SDK has been released or what.

@uudruid74 the fix from #7044 will fix running on x86. This fix will be included in the following beta5 release of 4.2.0. We are aiming at releasing that today in https://github.com/mapbox/mapbox-gl-native/issues/7047.

mapboxsdk:mapbox-android-sdk Version 5.0.2@aar crashes at startup on Genymotion

04-22 12:26:56.430 2251-2251/com.enp E/mbgl: {com.enp}[OpenGL]: eglChooseConfig() returned no configs.
04-22 12:26:56.774 2251-2251/com.enp E/AndroidRuntime: FATAL EXCEPTION: main
                                                       java.lang.Error: eglChooseConfig() failed
                                                           at com.mapbox.mapboxsdk.maps.NativeMapView.nativeInitializeDisplay(Native Method)
                                                           at com.mapbox.mapboxsdk.maps.NativeMapView.initializeDisplay(NativeMapView.java:127)
                                                           at com.mapbox.mapboxsdk.maps.MapView.onCreate(MapView.java:213)
                                                           at com.google.firebase.codelab.friendlychat.mundo.onCreate(mundo.java:155)
                                                           at android.app.Activity.performCreate(Activity.java:5008)
                                                           at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
                                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
                                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
                                                           at android.app.ActivityThread.access$600(ActivityThread.java:130)
                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
                                                           at android.os.Handler.dispatchMessage(Handler.java:99)
                                                           at android.os.Looper.loop(Looper.java:137)
                                                           at android.app.ActivityThread.main(ActivityThread.java:4745)
                                                           at java.lang.reflect.Method.invokeNative(Native Method)
                                                           at java.lang.reflect.Method.invoke(Method.java:511)
                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                                                           at dalvik.system.NativeStart.main(Native Method)

@Max01010101010101 Do you have more details about the used image?
@Guardiola31337 was able to run on genymotion without an issue.

Hi @tobrun
I got same error as @Max01010101010101
But I am using com.mapbox.mapboxsdk:mapbox-android-sdk:4.2.2@aar
Gennymotion emulator - Samsung Galaxy S4 - 4.2.2 - API 17

Same error if anyone knows the solution than let me know .

@NancyAndroid Which version of the SDK are you using? Is this error only occurring within Genymotion?

I am getting this in logcat will tring to enter the data to Firebase database?

1-14 17:19:58.570 10301-10323/com.example.hp.billingapp D/EGL_emulation: eglMakeCurrent: 0xb4332940: ver 2 0
01-14 17:19:58.577 10301-10323/com.example.hp.billingapp V/RenderScript: 0xae976000 Launching thread(s), CPUs 2
01-14 17:19:58.589 10301-10323/com.example.hp.billingapp D/EGL_emulation: eglMakeCurrent: 0xb4332940: ver 2 0
01-14 17:20:01.915 10301-10323/com.example.hp.billingapp D/EGL_emulation: eglMakeCurrent: 0xb4332940: ver 2 0
01-14 17:20:01.987 10301-10323/com.example.hp.billingapp D/EGL_emulation: eglMakeCurrent: 0xb4332940: ver 2 0
01-14 17:20:02.162 10301-10323/com.example.hp.billingapp D/EGL_emulation: eglMakeCurrent: 0xb4332940: ver 2 0
01-14 17:20:05.426 10301-10323/com.example.hp.billingapp D/EGL_emulation: eglMakeCurrent: 0xb4332940: ver 2 0
01-14 17:20:05.537 10301-10323/com.example.hp.billingapp D/EGL_emulation: eglMakeCurrent: 0xb4332940: ver 2 0
01-14 17:20:17.498 10301-10323/com.example.hp.billingapp D/EGL_emulation: eglMakeCurrent: 0xb4332940: ver 2 0
01-14 17:20:17.504 10301-10323/com.example.hp.billingapp D/EGL_emulation: eglMakeCurrent: 0xb4332940: ver 2 0
01-14 17:20:17.547 10301-10323/com.example.hp.billingapp D/EGL_emulation: eglMakeCurrent: 0xb4332940: ver 2 0
01-14 17:20:17.569 10301-10323/com.example.hp.billingapp D/EGL_emulation: eglMakeCurrent: 0xb4332940: ver 2 0
01-14 17:20:20.910 10301-10323/com.example.hp.billingapp D/EGL_emulation: eglMakeCurrent: 0xb4332940: ver 2 0
01-14 17:20:20.987 10301-10323/com.example.hp.billingapp D/EGL_emulation: eglMakeCurrent: 0xb4332940: ver 2 0
01-14 17:20:21.251 10301-10323/com.example.hp.billingapp D/EGL_emulation: eglMakeCurrent: 0xb4332940: ver 2 0

@Bbunty Could you clarify which version of the SDK are you using and if this error is only occurring within Genymotion? is it making your app crash?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lamhuynh96 picture lamhuynh96  路  3Comments

JobGetabu picture JobGetabu  路  3Comments

melihcolpan picture melihcolpan  路  3Comments

Guardiola31337 picture Guardiola31337  路  4Comments

brunoabinader picture brunoabinader  路  4Comments