-
-
Notifications
You must be signed in to change notification settings - Fork 207
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(MAUI): Automatically captured breadcrumbs #2900
Conversation
Co-authored-by: Bruno Garcia <[email protected]>
Delete fest! 🎉 |
Really good start to helping performance. I'd like to suggest also looking at either removing, or making opt-in, everything in Could these be options in the extension configuration to opt-out (or opt-in if they are default opt-out) to wiring up Element events? Or, perhaps another delegate similar to the BeforeBreadcrumb one to help decide if a particular element should be wired up or not? |
{ | ||
if (visualElement is Element element) | ||
{ | ||
element.HandlerChanged += (sender, _) => |
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.
We're subscribing to events here but not unsubscribing anywhere. This is often a memory leak source.
Here's some tips on looking for leaks: https://github.com/dotnet/maui/wiki/Memory-Leaks
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.
#2919 (comment) this
var type = element.Handler?.GetType(); | ||
var handlerName = type is not null ? type.Name : string.Empty; | ||
|
||
SentrySdk.AddBreadcrumb($"'{elementName}' handler changed to '{handlerName}'", "system", "ui.handlers"); |
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 we're accessing SentrySdk
(static method) so not really testable (usually we'd take IHub
?)
Definitely! Thanks for the feedback. I was just looking for even more reasons to trim them down! |
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.
Thanks for incorporating my feedback :)
public static void OnWindowOnBackgrounding(object? sender, BackgroundingEventArgs e) => | ||
Hub.AddBreadcrumbForEvent(Options, sender, nameof(Window.Backgrounding), SystemType, LifecycleCategory, data => | ||
{ | ||
if (!Options?.IncludeBackgroundingStateInBreadcrumbs ?? true) |
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.
default is null
so we're actually defaulting to true
here? that'd be nice
} | ||
|
||
public void BindApplicationEvents(Application application) | ||
public void HandleApplicationEvents(Application application, bool bind = true) |
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 do we call this with bind=false
? Looking at when do we unregister events. I imagine when the object we subscribed from is done with we need to do that?
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.
There are two places:
- We hook in the lifecycle events in
src/Sentry.Maui/SentryMauiAppBuilderExtensions.cs
and remove ourselves on shutdown/terminate - The
application
hasapplication.DescendantRemoved += OnApplicationOnDescendantRemoved;
and we crawl through all the events we bound to and remove ourselves.
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.
Nice! With a feature of no leaks! :)
This seems ready to go but CI stuck on some xharness error? |
@vaind is this something you've seen before? |
nothing wrong with xharness, it's a test failure, says so in the log:
Specifically |
Yes. I'm crawling through the logs and fixing the tests. |
Oh sorry Ivan! Thanks |
Fixes #2804
Resolves #2827
This PR does a couple of things:
94
breadcrumbs. I trimmed them down to the most essential ones - Navigation, Buttons, Lifecycle - and opted to stick with the finalizing ones for the "duplicates. (i.e.Pushing
vsPushed
).New:
Old: