From 391bdaddf10c3b64487b54274ac1ae7633ea8953 Mon Sep 17 00:00:00 2001 From: thisisthekap Date: Wed, 8 Jan 2025 17:52:16 +0100 Subject: [PATCH 1/4] Add experimental EnableAppHangTrackingV2 configuration flag to the dotnet SDK --- .../Platforms/Cocoa/BindableSentryOptions.cs | 2 ++ src/Sentry/Platforms/Cocoa/SentryOptions.cs | 17 +++++++++++++++++ src/Sentry/Platforms/Cocoa/SentrySdk.cs | 1 + 3 files changed, 20 insertions(+) diff --git a/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs b/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs index af7b318302..eaea31963a 100644 --- a/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs +++ b/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs @@ -14,6 +14,7 @@ public class NativeOptions public TimeSpan? AppHangTimeoutInterval { get; set; } public TimeSpan? IdleTimeout { get; set; } public bool? EnableAppHangTracking { get; set; } + public bool? EnableAppHangTrackingV2{ get; set; } public bool? EnableAutoBreadcrumbTracking { get; set; } public bool? EnableAutoPerformanceTracing { get; set; } public bool? EnableCoreDataTracing { get; set; } @@ -32,6 +33,7 @@ public void ApplyTo(SentryOptions.NativeOptions options) options.AppHangTimeoutInterval = AppHangTimeoutInterval ?? options.AppHangTimeoutInterval; options.IdleTimeout = IdleTimeout ?? options.IdleTimeout; options.EnableAppHangTracking = EnableAppHangTracking ?? options.EnableAppHangTracking; + options.EnableAppHangTrackingV2 = EnableAppHangTrackingV2 ?? options.EnableAppHangTrackingV2; options.EnableAutoBreadcrumbTracking = EnableAutoBreadcrumbTracking ?? options.EnableAutoBreadcrumbTracking; options.EnableAutoPerformanceTracing = EnableAutoPerformanceTracing ?? options.EnableAutoPerformanceTracing; options.EnableCoreDataTracing = EnableCoreDataTracing ?? options.EnableCoreDataTracing; diff --git a/src/Sentry/Platforms/Cocoa/SentryOptions.cs b/src/Sentry/Platforms/Cocoa/SentryOptions.cs index f72f37e08b..149fed69b1 100644 --- a/src/Sentry/Platforms/Cocoa/SentryOptions.cs +++ b/src/Sentry/Platforms/Cocoa/SentryOptions.cs @@ -68,6 +68,23 @@ internal NativeOptions(SentryOptions options) /// public bool EnableAppHangTracking { get; set; } = true; + /// + /// IMPORTANT: This feature is experimental and may have bugs. + ///
+ /// As of version 8.39.0-beta.1, you can enable AppHangsV2, which is available on iOS and tvOS. + /// The main difference is that AppHangsV2 differentiates between fully-blocking and non-fully-blocking + /// app hangs, which you might choose to ignore. A fully-blocking app hang is when the main thread is stuck + /// completely, and the app can't render a single frame. + /// A non-fully-blocking app hang is when the app appears stuck to the user, but can still render a few frames. + /// Fully-blocking app hangs are more actionable because the stacktrace shows the exact blocking location on + /// the main thread. Non-fully-blocking app hangs can have a stacktrace that doesn't highlight the exact + /// blocking location, since the main thread isn't completely blocked. + ///
+ /// + /// See https://docs.sentry.io/platforms/apple/configuration/app-hangs/#app-hangs-v2 + /// + public bool EnableAppHangTrackingV2 { get; set; } = true; + /// /// When enabled, the SDK adds breadcrumbs for various system events. /// The default value is true (enabled). diff --git a/src/Sentry/Platforms/Cocoa/SentrySdk.cs b/src/Sentry/Platforms/Cocoa/SentrySdk.cs index c10e22938c..c7b438f12d 100644 --- a/src/Sentry/Platforms/Cocoa/SentrySdk.cs +++ b/src/Sentry/Platforms/Cocoa/SentrySdk.cs @@ -121,6 +121,7 @@ private static void InitSentryCocoaSdk(SentryOptions options) nativeOptions.IdleTimeout = options.Native.IdleTimeout.TotalSeconds; nativeOptions.Dist = options.Distribution; nativeOptions.EnableAppHangTracking = options.Native.EnableAppHangTracking; + nativeOptions.EnableAppHangTrackingV2 = options.Native.EnableAppHangTrackingV2; nativeOptions.EnableAutoBreadcrumbTracking = options.Native.EnableAutoBreadcrumbTracking; nativeOptions.EnableAutoPerformanceTracing = options.Native.EnableAutoPerformanceTracing; nativeOptions.EnableCoreDataTracing = options.Native.EnableCoreDataTracing; From 884069f131df9f756f791435ef694a247cecd96b Mon Sep 17 00:00:00 2001 From: thisisthekap Date: Thu, 9 Jan 2025 09:09:14 +0100 Subject: [PATCH 2/4] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc100bf5ee..1f99a045fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Features + +- Add experimental EnableAppHangTrackingV2 configuration flag to the dotnet SDK ([#3877](https://github.com/getsentry/sentry-dotnet/pull/3877)) + ### Fixes - .NET Mobile: Disable and made obsolete the iOS Watchdog termination feature which is based on heuristics that don't work in .NET ([#3867](https://github.com/getsentry/sentry-dotnet/pull/3867)) From 411372d9d2b4b008e2f09391c0743cc75d3c2cd7 Mon Sep 17 00:00:00 2001 From: thisisthekap Date: Thu, 9 Jan 2025 09:13:02 +0100 Subject: [PATCH 3/4] reformatted BindableSentryOptions --- src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs b/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs index eaea31963a..f8dae26213 100644 --- a/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs +++ b/src/Sentry/Platforms/Cocoa/BindableSentryOptions.cs @@ -14,7 +14,7 @@ public class NativeOptions public TimeSpan? AppHangTimeoutInterval { get; set; } public TimeSpan? IdleTimeout { get; set; } public bool? EnableAppHangTracking { get; set; } - public bool? EnableAppHangTrackingV2{ get; set; } + public bool? EnableAppHangTrackingV2 { get; set; } public bool? EnableAutoBreadcrumbTracking { get; set; } public bool? EnableAutoPerformanceTracing { get; set; } public bool? EnableCoreDataTracing { get; set; } From e6e3eefba8dea42ff5976da9c75fb8d35e7b83c3 Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Thu, 9 Jan 2025 09:06:20 -0500 Subject: [PATCH 4/4] Apply suggestions from code review --- CHANGELOG.md | 2 +- src/Sentry/Platforms/Cocoa/SentryOptions.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f99a045fb..a7ea90db1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Features -- Add experimental EnableAppHangTrackingV2 configuration flag to the dotnet SDK ([#3877](https://github.com/getsentry/sentry-dotnet/pull/3877)) +- .NET on iOS: Add experimental EnableAppHangTrackingV2 configuration flag to the options binding SDK ([#3877](https://github.com/getsentry/sentry-dotnet/pull/3877)) ### Fixes diff --git a/src/Sentry/Platforms/Cocoa/SentryOptions.cs b/src/Sentry/Platforms/Cocoa/SentryOptions.cs index 149fed69b1..6b0e9587e6 100644 --- a/src/Sentry/Platforms/Cocoa/SentryOptions.cs +++ b/src/Sentry/Platforms/Cocoa/SentryOptions.cs @@ -71,7 +71,7 @@ internal NativeOptions(SentryOptions options) /// /// IMPORTANT: This feature is experimental and may have bugs. ///
- /// As of version 8.39.0-beta.1, you can enable AppHangsV2, which is available on iOS and tvOS. + /// As of version 8.39.0-beta.1 of the sentry-cocoa SDK, you can enable AppHangsV2, which is available on iOS and tvOS. /// The main difference is that AppHangsV2 differentiates between fully-blocking and non-fully-blocking /// app hangs, which you might choose to ignore. A fully-blocking app hang is when the main thread is stuck /// completely, and the app can't render a single frame.