-
-
Notifications
You must be signed in to change notification settings - Fork 52
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: Managed layer initializes native SDK on Android #1924
Conversation
…sentry/sentry-unity into chore/sample-no-thumb-update
0deb527
to
ffd8221
Compare
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.
CI seems not to be running
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 see 5 new tests for quite a significant change. I'm concerned there are lot of untested use cases. Isn't that the case?
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 issue left which is the thread.Join
on Dispose which can throw.
Other than that, lgtm
_shutdownSource.Cancel(); | ||
_workerThread?.Join(100); |
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 can throw for:
Exceptions
ThreadStateException
The caller attempted to join a thread that is in the Unstarted state.
ThreadInterruptedException
The thread is interrupted while waiting.
We should catch this here and suppress 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.
Also worth reading the remarks of these APIs.
Curious why we use Thread directly instead of the Task abstraction. It's by default a background thread and it's much better to deal with cancellation, error handling etc (something for a potential future task, to change this)
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.
Curious why we use Thread directly instead of the Task abstraction.
The executor needs to run all the calls on a single thread. If we converted this to a task, we'd still need to ensure that so no async/await, etc. In that case, I only see risks that we do something wrong here now or in the future version of the code which would lead to the task being rescheduled to a different thread in the pool.
Android: Android SDK Initialization
Overview
Implements the late initialization of the Android SDK. This allows users to apply code changes to the options and for those options to apply to the native layer. Related issue: sentry-unity#1907
Implementation Details
The SDK now always includes the Android SDK in the generated Gradle project with the following changes:
AndroidNativeInitializationType
to the SentryOptions. This allows users to switch betweenRuntime
andBuildTime
initialization and defaults toRuntime
.AndroidNativeSupportEnabled
controls whether the SDK should add native support. This helps i.e. in the case of UaaL where users want to completely disabled the SDK from modifying the Gradle project.AndroidNativeInitializationType
enumRuntime
the SDK will addauto-init = false
.BuildTime
it will add the options and let the Android SDK autoinitialize.SentryNativeAndroid.Configure
checks whether the native SDK was already initializedPending Tasks
RuntimeInitialization
is default. This means we're missing testingBuildTime
in CI right now.