Skip to content
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

Fix ensure ndk libs are loaded before calling close #3797

Merged
merged 3 commits into from
Oct 17, 2024
Merged

Conversation

markushi
Copy link
Member

@markushi markushi commented Oct 16, 2024

📜 Description

Ensures the NDK libs are loaded, just like within .init(). The NDK integration itself already swallows any thrown exception, so there should be no change in that regard.

💡 Motivation and Context

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

#skip-changelog

Copy link
Contributor

github-actions bot commented Oct 16, 2024

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 398.46 ms 420.10 ms 21.64 ms
Size 1.70 MiB 2.35 MiB 667.96 KiB

Previous results on branch: fix/ndk-shutdown

Startup times

Revision Plain With Sentry Diff
0af72d4 444.49 ms 466.86 ms 22.37 ms

App size

Revision Plain With Sentry Diff
0af72d4 1.70 MiB 2.35 MiB 668.12 KiB

@@ -69,6 +69,15 @@ public static void init(@NotNull final SentryAndroidOptions options) {

/** Closes the NDK integration */
public static void close() {
shutdown();
try {
if (loadLibraryLatch.await(2000, TimeUnit.MILLISECONDS)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could slow down on SDK restart/double init
i'd rather submit the shutdown() to the same thread we use to load the libraries
wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thinks it's fine this way because .init() already waits for the latch to finish, so whenever .close() is called the latch is already counted down. So even a double init wouldn't cause this to be blocking, unless you call SentryAndroid.init() from different threads in parallel 😅
So the .await() will only be blocking in case SentryNdk.close() is called before SentryNdk.init() - in theory this should never happen.

@markushi markushi enabled auto-merge (squash) October 17, 2024 08:33
@markushi markushi merged commit a8c72dd into main Oct 17, 2024
26 of 27 checks passed
@markushi markushi deleted the fix/ndk-shutdown branch October 17, 2024 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants