From ea68ebe52764b0d3ed843a49e7cff4bfb169f62b Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 22 Jan 2022 22:35:02 +0100 Subject: [PATCH 1/2] Fix logging of exception titles --- .../ComputeSharp.SwapChain.Core.Shared.projitems | 1 + .../Constants/Error.cs | 10 ++++++++++ .../Constants/Event.cs | 2 -- .../Services/DebugAnalyticsService.cs | 5 ++--- .../Services/IAnalyticsService.cs | 5 ++--- .../Services/AppCenterService.cs | 2 +- .../ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs | 4 ++-- 7 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 samples/ComputeSharp.SwapChain.Core.Shared/Constants/Error.cs diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/ComputeSharp.SwapChain.Core.Shared.projitems b/samples/ComputeSharp.SwapChain.Core.Shared/ComputeSharp.SwapChain.Core.Shared.projitems index 80039491..a9b21972 100644 --- a/samples/ComputeSharp.SwapChain.Core.Shared/ComputeSharp.SwapChain.Core.Shared.projitems +++ b/samples/ComputeSharp.SwapChain.Core.Shared/ComputeSharp.SwapChain.Core.Shared.projitems @@ -9,6 +9,7 @@ ComputeSharp.SwapChain.Core.Shared + diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Error.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Error.cs new file mode 100644 index 00000000..fa6f2fce --- /dev/null +++ b/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Error.cs @@ -0,0 +1,10 @@ +namespace ComputeSharp.SwapChain.Core.Constants; + +/// +/// A with the collection of tracked errors for analytics. +/// +public static class Error +{ + public const string RenderingFailedOnMainPanel = "[SHELL] RenderingFailed (main panel)"; + public const string RenderingFailedOnSelectionPanel = "[SHELL] RenderingFailed (selection panel)"; +} diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Event.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Event.cs index 9d2fe8ad..171865b4 100644 --- a/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Event.cs +++ b/samples/ComputeSharp.SwapChain.Core.Shared/Constants/Event.cs @@ -12,6 +12,4 @@ public static class Event public const string IsRenderingPausedChanged = "[SETTINGS] IsRenderingPaused"; public const string OpenShaderSelectionPanel = "[SHELL] Open ShaderSelectionPanel"; public const string CloseShaderSelectionPanel = "[SHELL] Close ShaderSelectionPanel"; - public const string RenderingFailedOnMainPanel = "[SHELL] RenderingFailed (main panel)"; - public const string RenderingFailedOnSelectionPanel = "[SHELL] RenderingFailed (selection panel)"; } diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs index fdd0b425..c3945e56 100644 --- a/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs +++ b/samples/ComputeSharp.SwapChain.Core.Shared/Services/DebugAnalyticsService.cs @@ -30,12 +30,11 @@ public sealed class DebugAnalyticsService : IAnalyticsService } /// - public void Log(string title, Exception exception, params (string Property, object? Value)[]? data) + public void Log(Exception exception, params (string Property, object? Value)[]? data) { StringBuilder builder = new(); - builder.AppendLine($"[EXCEPTION]: \"{title}\""); - builder.AppendLine($">> Type: \"{exception.GetType()}\""); + builder.AppendLine($"[EXCEPTION]: \"{exception.GetType()}\""); builder.AppendLine(">> Stack trace"); builder.AppendLine(exception.StackTrace); diff --git a/samples/ComputeSharp.SwapChain.Core.Shared/Services/IAnalyticsService.cs b/samples/ComputeSharp.SwapChain.Core.Shared/Services/IAnalyticsService.cs index 53081e62..d5c0a92e 100644 --- a/samples/ComputeSharp.SwapChain.Core.Shared/Services/IAnalyticsService.cs +++ b/samples/ComputeSharp.SwapChain.Core.Shared/Services/IAnalyticsService.cs @@ -17,10 +17,9 @@ public interface IAnalyticsService void Log(string title, params (string Property, object? Value)[]? data); /// - /// Logs an exception with a specified title and optional properties. + /// Logs an exception with optional properties. /// - /// The title of the event to track. /// The exception that has been thrown. /// The optional event properties. - void Log(string title, Exception exception, params (string Property, object? Value)[]? data); + void Log(Exception exception, params (string Property, object? Value)[]? data); } diff --git a/samples/ComputeSharp.SwapChain.Uwp/Services/AppCenterService.cs b/samples/ComputeSharp.SwapChain.Uwp/Services/AppCenterService.cs index ba7f26b2..13f204c7 100644 --- a/samples/ComputeSharp.SwapChain.Uwp/Services/AppCenterService.cs +++ b/samples/ComputeSharp.SwapChain.Uwp/Services/AppCenterService.cs @@ -34,7 +34,7 @@ public sealed class AppCenterService : IAnalyticsService } /// - public void Log(string title, Exception exception, params (string Property, object? Value)[]? data) + public void Log(Exception exception, params (string Property, object? Value)[]? data) { Crashes.TrackError(exception, GetProperties(data)); } diff --git a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs index d038b3f0..c02b4ab1 100644 --- a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs +++ b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs @@ -52,12 +52,12 @@ public sealed partial class MainView : UserControl // Logs rendering failed in the main panel private void MainShaderPanel_RenderingFailed(AnimatedComputeShaderPanel sender, Exception args) { - Ioc.Default.GetRequiredService().Log(Event.RenderingFailedOnMainPanel, args); + Ioc.Default.GetRequiredService().Log(args, (nameof(Error), Error.RenderingFailedOnMainPanel)); } // Logs rendering failed in a secondary panel private void SelectionShaderPanel_RenderingFailed(AnimatedComputeShaderPanel sender, Exception args) { - Ioc.Default.GetRequiredService().Log(Event.RenderingFailedOnSelectionPanel, args); + Ioc.Default.GetRequiredService().Log(args, (nameof(Error), Error.RenderingFailedOnSelectionPanel)); } } From facfdb8feb617fa1c0ec9a9b2e2caacbfc8c2216 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 22 Jan 2022 22:50:21 +0100 Subject: [PATCH 2/2] Add info bar when a rendering issue occurs --- .../Views/MainView.xaml | 34 +++++++++++++++---- .../Views/MainView.xaml.cs | 4 +++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml index a751b6ec..0b64a60a 100644 --- a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml +++ b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml @@ -6,15 +6,11 @@ xmlns:computesharp="using:ComputeSharp.Uwp" xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls" xmlns:converters="using:ComputeSharp.SwapChain.Core.Converters" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:media="using:Microsoft.Toolkit.Uwp.UI.Media" xmlns:models="using:ComputeSharp.SwapChain.Core.Models" + xmlns:muxc="using:Microsoft.UI.Xaml.Controls" xmlns:ui="using:Microsoft.Toolkit.Uwp.UI" - d:DesignHeight="300" - d:DesignWidth="400" - SizeChanged="UserControl_SizeChanged" - mc:Ignorable="d"> + SizeChanged="UserControl_SizeChanged"> @@ -228,5 +224,31 @@ HorizontalAlignment="Stretch" VerticalAlignment="Top" Fill="Transparent" /> + + + + + + + + + + + + + + + diff --git a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs index c02b4ab1..1ed45642 100644 --- a/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs +++ b/samples/ComputeSharp.SwapChain.Uwp/Views/MainView.xaml.cs @@ -53,11 +53,15 @@ public sealed partial class MainView : UserControl private void MainShaderPanel_RenderingFailed(AnimatedComputeShaderPanel sender, Exception args) { Ioc.Default.GetRequiredService().Log(args, (nameof(Error), Error.RenderingFailedOnMainPanel)); + + RenderingErrorInfoBar.IsOpen = true; } // Logs rendering failed in a secondary panel private void SelectionShaderPanel_RenderingFailed(AnimatedComputeShaderPanel sender, Exception args) { Ioc.Default.GetRequiredService().Log(args, (nameof(Error), Error.RenderingFailedOnSelectionPanel)); + + RenderingErrorInfoBar.IsOpen = true; } }