-
-
Notifications
You must be signed in to change notification settings - Fork 42
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 threading issues capturing log messages as breadcrumbs #559
Conversation
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!
SentryScopeDesktop::SentryScopeDesktop(const SentryScopeDesktop& Scope) | ||
{ | ||
Dist = Scope.Dist; | ||
Environment = Scope.Environment; | ||
FingerprintDesktop = Scope.FingerprintDesktop; | ||
TagsDesktop = Scope.TagsDesktop; | ||
ExtraDesktop = Scope.ExtraDesktop; | ||
ContextsDesktop = Scope.ContextsDesktop; | ||
BreadcrumbsDesktop = Scope.BreadcrumbsDesktop; | ||
LevelDesktop = Scope.LevelDesktop; | ||
} | ||
|
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.
Where is this coming from?
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's essential to implement a custom copy constructor for the scope class after we've introduced a critical section member.
Since FCriticalSection
disables its default copy constructor using the default mechanism for scope isn't possible and results into compilation errors.
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.
TIL. Thanks!
SentryScopeDesktop::~SentryScopeDesktop() | ||
{ | ||
} | ||
|
||
void SentryScopeDesktop::AddBreadcrumb(USentryBreadcrumb* breadcrumb) | ||
{ | ||
FScopeLock Lock(&CriticalSection); |
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.
That's neat, that it works like that.
@@ -12,6 +12,7 @@ class SentrySubsystemAndroid : public ISentrySubsystem | |||
virtual bool IsEnabled() override; | |||
virtual ESentryCrashedLastRun IsCrashedLastRun() override; | |||
virtual void AddBreadcrumb(USentryBreadcrumb* breadcrumb) override; |
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 we're no longer using the "plain" AddBreadcrumb
, do we need 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.
It's still a part of the public API so I think we should leave it even though we're not using it internally anymore.
This PR addresses an issue which was discovered during the discussion around #514
Since log messages, asserts, ensures, etc. can come from different threads adding breadcrumbs automatically on such events can lead to undefined results due to the following reasons:
UObject
instance is created during garbage collectionSentryScopeDesktop
breadcrumbs storageIn order to resolve this breadcrumbs can now be captured without instancing any extra objects and some threading considerations were added.