-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Catch C++ exceptions before returning to JNI #2825
Comments
As discussed in slack a wrinkle with Instead we can take advantage of how Java checking JNI thrown Java exceptions. If we convert exception to Java exception in the map thread instead of killing the thread. Then when we next call into Java land ( We also need to log the C++ exception stack trace to logcat first so that in the log we have both the original stack trace, and the new Java one which will point to |
@1ec5 Should we also open a iOS ticket for iOS exception handling? Will help in #2775 (comment)
|
The joys of living in an all C++ world. 😃 |
Per #2804, the Android SDK suffers from a native crash any time there’s an uncaught C++ exception at the mbgl level. An uncaught exception there usually indicates developer error, so the Android SDK needs to present that error in a way that’s actionable without spelunking into mbgl code. The Android bindings cannot rely on an assumption that the C++ code won’t throw exceptions.
platform/android/jni.cpp needs to have C-style exception handling. For example,
nativeSetStyleURL()
should be wrapped in a try-catch statement. When an exception is caught, this function should return some kind of error code. For functions that already need to return a value, this would imply some kind of out parameter or a tuple-typed return value.Though this could be a fair amount of work, it pays off in the form of Android bindings that can actually be debugged.
/cc @ljbade @bleege @jfirebaugh
The text was updated successfully, but these errors were encountered: