-
-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: expose a module loader for Android thru sentry-native #1043
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1043 +/- ##
============================================
- Coverage 72.06% 72.03% -0.03%
Complexity 1338 1338
============================================
Files 138 138
Lines 4893 4895 +2
Branches 499 499
============================================
Hits 3526 3526
- Misses 1106 1108 +2
Partials 261 261
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
You should add the type
, debug_id
, code_id
and debug_file
props as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall PR looks great. I have added a few important comments about naming and in which package to put the classes. Can we maybe also add an integration test for this?
sentry-android-core/src/main/java/io/sentry/android/core/IDebugImagesLoader.java
Outdated
Show resolved
Hide resolved
sentry-android-ndk/src/main/java/io/sentry/android/ndk/DebugImagesLoader.java
Show resolved
Hide resolved
sentry-android-ndk/src/main/java/io/sentry/android/ndk/DebugImagesLoader.java
Outdated
Show resolved
Hide resolved
sentry-android-ndk/src/main/java/io/sentry/android/ndk/DebugImagesLoader.java
Outdated
Show resolved
Hide resolved
sentry-android-ndk/src/main/java/io/sentry/android/ndk/IModuleListLoader.java
Outdated
Show resolved
Hide resolved
sentry-android-ndk/src/test/java/io/sentry/android/ndk/DebugImagesLoaderTest.kt
Show resolved
Hide resolved
sentry-android-ndk/src/main/java/io/sentry/android/ndk/IModuleListLoader.java
Outdated
Show resolved
Hide resolved
sentry-android-ndk/src/main/java/io/sentry/android/ndk/DebugImagesLoader.java
Show resolved
Hide resolved
sentry-android-core/src/main/java/io/sentry/android/core/IDebugImagesLoader.java
Show resolved
Hide resolved
…agesLoaderTest.kt Co-authored-by: Philipp Hofmann <[email protected]>
… into feat/module_loader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One important comment and a few nitpicks.
sentry-android-core/src/main/java/io/sentry/android/core/NdkIntegration.java
Show resolved
Hide resolved
sentry-android-core/src/main/java/io/sentry/android/core/NdkIntegration.java
Show resolved
Hide resolved
sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java
Outdated
Show resolved
Hide resolved
sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java
Show resolved
Hide resolved
sentry-android-ndk/src/main/java/io/sentry/android/ndk/DebugImagesLoader.java
Show resolved
Hide resolved
sentry-android-ndk/src/main/java/io/sentry/android/ndk/IModuleListLoader.java
Outdated
Show resolved
Hide resolved
sentry-android-ndk/src/main/java/io/sentry/android/ndk/NativeModuleListLoader.java
Show resolved
Hide resolved
sentry-android-ndk/src/main/java/io/sentry/android/ndk/IModuleListLoader.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing stopping me to approve this is to add some integration tests to validate that the JNI calls are working properly. Can we add some?
all good then, we can't run Android native code on the JVM, so we can't really do it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said integration tests would make sense, but we had some trouble in the past adding them and we don't want this to block this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry that we do all this work to read a single entry (libapp.so) for Flutter only. Wouldn't it make sense to add a single: getByImageName
or by id or something?
|
||
JNIEXPORT jobjectArray JNICALL | ||
Java_io_sentry_android_ndk_NativeModuleListLoader_nativeLoadModuleList(JNIEnv *env, jclass cls) { | ||
sentry_value_t image_list_t = sentry_get_modules_list(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we drop the _t
? or is this really a type
sentry_value_t image_list_t = sentry_get_modules_list(); | |
sentry_value_t image_list = sentry_get_modules_list(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well unless we rename jobjectArray
but either of them needs a suffix or prefix, as they are the same thing but using a different data type
jobjectArray image_list = NULL; | ||
|
||
if (sentry_value_get_type(image_list_t) == SENTRY_VALUE_TYPE_LIST) { | ||
size_t len_t = sentry_value_get_length(image_list_t); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size_t len_t = sentry_value_get_length(image_list_t); | |
size_t len = sentry_value_get_length(image_list_t); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (sentry_value_get_type(image_list_t) == SENTRY_VALUE_TYPE_LIST) { | ||
size_t len_t = sentry_value_get_length(image_list_t); | ||
|
||
jclass image_class = (*env)->FindClass(env, "io/sentry/protocol/DebugImage"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we expect this method to be called multiple times? I wonder if would be worth caching these FindClass results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless somebody call clearDebugImages
its used only once
sentry_value_t image_t = sentry_value_get_by_index(image_list_t, i); | ||
|
||
if (!sentry_value_is_null(image_t)) { | ||
jobject image = (*env)->NewObject(env, image_class, image_addr_ctor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when/where is this freed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks fine from my side. TBH, I have no idea how the ownership transfer works for these JNI object, and if the GC will ever run concurrently with this call? If we would need to manually root these things on the C stack, or if we need to unref them rather.
doing a |
sentry_value_t image_t = sentry_value_get_by_index(image_list_t, i); | ||
|
||
if (!sentry_value_is_null(image_t)) { | ||
jobject image = (*env)->NewObject(env, image_class, image_addr_ctor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks fine from my side. TBH, I have no idea how the ownership transfer works for these JNI object, and if the GC will ever run concurrently with this call? If we would need to manually root these things on the C stack, or if we need to unref them rather.
📢 Type of change
📜 Description
feat: expose a module loader for Android thru sentry-native
💡 Motivation and Context
Flutter apps when has split symbols enabled need the debug images for proper server symbolization and the Dart/Flutter API doesn't offer it natively.
💚 How did you test it?
📝 Checklist
🔮 Next steps