-
-
Notifications
You must be signed in to change notification settings - Fork 202
feat(android): allow NDK preload for .NET/CoreCLR #1613
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
Open
jpnurmi
wants to merge
12
commits into
master
Choose a base branch
from
jpnurmi/feat/android-ndk-preload
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
648b794
feat(android): preload NDK integration
jpnurmi a7e942e
test(android): parameterize signal tests for Mono/CoreCLR and preload
jpnurmi 6208a37
fix(android): preserve signal handler chain across close/reinit with …
jpnurmi 132bea8
fix(android): gate handler thread check on g_preloaded
jpnurmi ce86798
Update CHANGELOG.md
jpnurmi bc7eebd
Revert SENTRY_SIGNAL_SAFE_LOG changes that slipped in
jpnurmi 750c178
Update sentry-native-ndk.api
jpnurmi 8765273
fix(android): guard g_preloaded with SENTRY_PLATFORM_UNIX
jpnurmi 6c1fcf5
fix(android): reset signal handlers before fallthrough in preload path
jpnurmi 996de1c
fix(inproc): propagate signal handler install failure to sentry_init
jpnurmi 34eb38c
fix(android): clear g_preloaded after reset in preload fallthrough
jpnurmi 0aa6a80
Merge remote-tracking branch 'upstream/master' into jpnurmi/feat/andr…
jpnurmi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <application> | ||
| <!-- initOrder must be higher than AppInitOrder-1 (1999999999) used by the .NET runtime: | ||
| https://github.com/dotnet/android/blob/3c50ff4573b5/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs#L724 --> | ||
| <provider | ||
| android:name="io.sentry.ndk.SentryNdkPreloadProvider" | ||
| android:authorities="${applicationId}.SentryNdkPreloadProvider" | ||
| android:initOrder="2000000000" | ||
| android:exported="false" /> | ||
| </application> | ||
| </manifest> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
ndk/lib/src/main/java/io/sentry/ndk/SentryNdkPreloadProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| package io.sentry.ndk; | ||
|
|
||
| import android.content.ContentProvider; | ||
| import android.content.ContentValues; | ||
| import android.content.Context; | ||
| import android.content.pm.ApplicationInfo; | ||
| import android.content.pm.PackageManager; | ||
| import android.database.Cursor; | ||
| import android.net.Uri; | ||
| import android.os.Bundle; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| /** | ||
| * Preloads the NDK integration before the Mono runtime. This installs and | ||
| * chains the Native SDK's signal handlers before Mono, allowing Mono to | ||
| * correctly handle managed exceptions while chaining native crashes to the | ||
| * Native SDK. | ||
| * | ||
| * <p>Enabled by setting {@code io.sentry.ndk.preload} to {@code true} in | ||
| * AndroidManifest.xml metadata. The high {@code initOrder} ensures this runs | ||
| * before {@code mono.MonoRuntimeProvider}. | ||
| */ | ||
| public final class SentryNdkPreloadProvider extends ContentProvider { | ||
|
|
||
| @Override | ||
| public boolean onCreate() { | ||
| final Context context = getContext(); | ||
| if (context == null) { | ||
| return false; | ||
| } | ||
| try { | ||
| final ApplicationInfo info = | ||
| context | ||
| .getPackageManager() | ||
| .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); | ||
| final Bundle metadata = info.metaData; | ||
| if (metadata != null && metadata.getBoolean("io.sentry.ndk.preload", false)) { | ||
| android.util.Log.d("sentry", "io.sentry.ndk.preload read: true"); | ||
| SentryNdk.preload(); | ||
| android.util.Log.d("sentry", "SentryNdk.preload() completed"); | ||
| } | ||
| } catch (Throwable e) { | ||
| android.util.Log.e("sentry", "SentryNdk.preload() failed", e); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public @Nullable Cursor query( | ||
| @NotNull Uri uri, | ||
| @Nullable String[] projection, | ||
| @Nullable String selection, | ||
| @Nullable String[] selectionArgs, | ||
| @Nullable String sortOrder) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public @Nullable String getType(@NotNull Uri uri) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public @Nullable Uri insert(@NotNull Uri uri, @Nullable ContentValues values) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public int delete(@NotNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) { | ||
| return 0; | ||
| } | ||
|
|
||
| @Override | ||
| public int update( | ||
| @NotNull Uri uri, | ||
| @Nullable ContentValues values, | ||
| @Nullable String selection, | ||
| @Nullable String[] selectionArgs) { | ||
| return 0; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.