diff --git a/include/mbgl/platform/event.hpp b/include/mbgl/platform/event.hpp index 77c45fb0f..cf8210181 100644 --- a/include/mbgl/platform/event.hpp +++ b/include/mbgl/platform/event.hpp @@ -35,7 +35,8 @@ enum class Event : uint8_t { Image, OpenGL, JNI, - Android + Android, + Crash }; MBGL_DEFINE_ENUM_CLASS(EventClass, Event, { @@ -52,6 +53,7 @@ MBGL_DEFINE_ENUM_CLASS(EventClass, Event, { { Event::OpenGL, "OpenGL" }, { Event::JNI, "JNI" }, { Event::Android, "Android" }, + { Event::Android, "Crash" }, { Event(-1), "Unknown" }, }); diff --git a/src/map/map.cpp b/src/map/map.cpp index f11fa9194..3746fb4b6 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -31,6 +31,10 @@ #include +#ifdef __ANDROID__ + #include +#endif + // Check libuv library version. const static bool uv_version_check = []() { const unsigned int version = uv_version(); @@ -251,6 +255,10 @@ void Map::resume() { } void Map::run() { +#ifdef __ANDROID__ + COFFEE_TRY() { +#endif + #ifndef NDEBUG if (!async) { map_thread = main_thread; @@ -280,6 +288,12 @@ void Map::run() { map_thread = -1; #endif } +#ifdef __ANDROID__ + } COFFEE_CATCH() { + Log::Error(Event::Crash, "Map::run() crash:\n%s", coffeecatch_get_message()); + abort(); + } +#endif } void Map::check_for_pause() {