After the update to Android MapBox SDK 4.1.0/4.1.1 my app crashes on Android emulator with:
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);
}
07-23 00:07:06.818 8965-8965/? A/libc: Fatal signal 11 (SIGSEGV) at 0xdeadcab1 (code=1), thread 8965 (pboxandroiddemo)
The app runs without crash on Android physical devices and when compiled with MapBox SDK 4.0.0.
MapBox example on https://github.com/mapbox/mapbox-android-demo crashes with the same error when compiled locally.
Tested on Linux Mint with following images:
Intel x86 Atom_System Image API 19 Revision 22
Intel x86 Atom_System Image API 23 Revision 15
Intel x86 Atom_64 System Image API 24 Revision 5
Is this known problem? Can this crash affect production build on physical devices? Is there any workaround?
For those using the emulator:
This can be fixed by changing your emulated graphics to Software - GLES 2.0
in your AVD settings. This is not ideal, but it will work (and is still much faster than emulating an ARM device).
I suspect this is emulator specific.
I'll assume you mean Android Mapbox SDK 4.1.0/4.1.1 and not DropBox ;)
First, make sure you are always using the latest version of the SDK, 4.1.1 fixes an important bug that can potentially break your app. This sounds like an issue with the emulator possibly not having OpenGL setup properly. I'm not familiar with Linux Mint but you will need to make sure your graphics driver is installed and up to date. It will also need to be able to support OpenGL 2.0 or higher.
We don't guarantee Mapbox will be able to work on an emulator but we do strive to ensure Mapbox works on as many physical devices as possible. If an emulator must be used, we recommend either the built in Android Studio one or Genymotion.
Is this known problem? Can this crash affect production build on
physical devices? Is there any workaround?
Answer —
- If you crash on a x86 emulator, then there is a really good chance it will crash on a x86 device.
- If you pass testing on a ARM device, there is a really good chance your app will work fine on ARM devices
- If that doesn't answer your initial question, then there is Mapbox issue #5456 that has some discussion.
I also saw the same crash on an x86 emulator in OS X with Android Studio. The same app passed on an ARM device.
As you mentioned, the emulators are Intel x86 Atom_System
images.
The Mapbox Android SDK compiled in with gradle as an AAR
file includes several shared objects for different device processors including for ARM, x86 and MIPS.
That is, when you use this
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.1.0@aar')
You get several libmapbox-gl.so shared objects in your Android APK
I have verified that this issue does in fact crash Android x86 physical devices. RemixOS has the exact same crash as can be seen from catlog - if anyone wants the full log - let me know, but its mostly the same as above except that I also have the reg dump and backtrace showing that it was the mapbox SDK that originated the issue.
My guess is that the issue is because most Android x86 devices aren't supporting the ES variant of OpenGL (for embedded devices), but rather the full desktop spec. This is normally not a concern, but the #ifdef specifically tests for the ES variant and then #define's away a few types that I think need to be defined. The ES variant sets highp to a float while the non-ES code leaves it blank! This would cause the compilation problem (basically JIT via LLVM) and then the lack of code and the crash-n-burn.