-
-
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
[QA] Offload System.loadLibrary call to background thread #3670
Conversation
|
Performance metrics 🚀
|
Comparing the performance metrics with other PRs, we can see a nice 35-45% improvement of the startup time 🚀 |
@markushi sounds very promising 👍 any creative ways to test this end-to-end? basically (how) can we guarantee this doesn't break any part of startup/initialization? |
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.
Looks good!
Not sure how/if we can test it, but "logically" it works
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 think we wanted to make it part of the next major (8.x.x) - do we still wanna do that?
Aside, this looks good, and I think eventually we could offload the native init to the background thread as well, because we wanted to move setTag
, setBreadcrumbs
to background anyway.
6fceb9c
to
35c0235
Compare
35c0235
to
d0defbb
Compare
📜 Description
Perform
System.loadLibrary()
on a background thread.💡 Motivation and Context
Calling
System.loadLibrary()
causes StrictMode violations, as it performs disk reads, but any JNI calls likeinitSentryNative
needs the libraries to be loaded beforehand.Initializing the whole NDK off the main thread would be an option, but it has two main disadvantages:
SentryAndroid.init()
, thus we could miss early startup crashesSo the trick is to perform
System.loadLibrary()
as early as possible on a background thread, but still perform NDK init synchronous on the main thread. In my testing this works well, as the SDK init in-between takes longer than the.loadLibrary()
calls, making theloadLibraryLatch.await(2000, TimeUnit.MILLISECONDS)
return immediatelly.💚 How did you test it?
Just manually, haven't found a better way yet.
📝 Checklist
sendDefaultPII
is enabled.🔮 Next steps