diff --git a/shell/windows/LayersShell/App.xaml.cs b/shell/windows/LayersShell/App.xaml.cs index ccec462..109b776 100644 --- a/shell/windows/LayersShell/App.xaml.cs +++ b/shell/windows/LayersShell/App.xaml.cs @@ -1,3 +1,5 @@ +using System; +using System.IO; using Microsoft.UI.Xaml; namespace LayersShell; @@ -8,12 +10,47 @@ public partial class App : Application public App() { - InitializeComponent(); + Log("App ctor enter"); + try + { + InitializeComponent(); + AppDomain.CurrentDomain.UnhandledException += (_, e) => + Log($"UnhandledException: {e.ExceptionObject}"); + UnhandledException += (_, e) => + Log($"XAML UnhandledException: {e.Exception}"); + Log("App ctor ok"); + } + catch (Exception ex) + { + Log($"App ctor FAILED: {ex}"); + throw; + } } protected override void OnLaunched(LaunchActivatedEventArgs args) { - _window = new MainWindow(); - _window.Activate(); + Log("OnLaunched enter"); + try + { + _window = new MainWindow(); + Log("MainWindow constructed"); + _window.Activate(); + Log("MainWindow activated"); + } + catch (Exception ex) + { + Log($"OnLaunched FAILED: {ex}"); + throw; + } + } + + internal static void Log(string line) + { + try + { + var path = Path.Combine(Path.GetTempPath(), "layers-shell.log"); + File.AppendAllText(path, DateTime.Now.ToString("HH:mm:ss.fff ") + line + Environment.NewLine); + } + catch { } } } diff --git a/shell/windows/LayersShell/MainWindow.xaml.cs b/shell/windows/LayersShell/MainWindow.xaml.cs index 06b41ea..6c85723 100644 --- a/shell/windows/LayersShell/MainWindow.xaml.cs +++ b/shell/windows/LayersShell/MainWindow.xaml.cs @@ -25,9 +25,15 @@ public sealed partial class MainWindow : Window public MainWindow() { - InitializeComponent(); + App.Log("MainWindow ctor enter"); + try + { + InitializeComponent(); + } + catch (Exception ex) { App.Log($"InitializeComponent FAILED: {ex}"); throw; } Title = "Layers"; _hwnd = WindowNative.GetWindowHandle(this); + App.Log($"hwnd = {_hwnd:X}"); var appWindow = AppWindow.GetFromWindowId(Win32Interop.GetWindowIdFromWindow(_hwnd)); if (appWindow is not null) @@ -51,10 +57,23 @@ public sealed partial class MainWindow : Window DispatcherQueue.TryEnqueue(() => { - PointToRust(); - LayersNative.StartupIfNeeded(); - CreateNativeHandle(); - StartRenderLoop(); + try + { + App.Log("deferred init: PointToRust"); + PointToRust(); + App.Log("deferred init: StartupIfNeeded"); + LayersNative.StartupIfNeeded(); + App.Log("deferred init: CreateNativeHandle"); + CreateNativeHandle(); + App.Log($"deferred init: _handle = {_handle:X}"); + StartRenderLoop(); + App.Log("deferred init: render loop started"); + } + catch (Exception ex) + { + App.Log($"deferred init FAILED: {ex}"); + throw; + } }); }