From 81da58ab9c142c2c0cd70e848175ffbca6509a77 Mon Sep 17 00:00:00 2001 From: gramps Date: Mon, 5 Oct 2026 13:27:07 -0700 Subject: [PATCH] Log: alert resolver uses state-change logging instead of 1/s Logs on transition between has-frame and null, and re-logs at most every 10s to avoid spam while idle. No behavior change to the resolve path. --- ViewModels/MainViewModel.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ViewModels/MainViewModel.cs b/ViewModels/MainViewModel.cs index 6c70a47..a7796ac 100644 --- a/ViewModels/MainViewModel.cs +++ b/ViewModels/MainViewModel.cs @@ -501,18 +501,22 @@ public partial class MainViewModel : ViewModelBase if (element is Source { Type: SourceType.AlertBox } alert) { var now = DateTime.UtcNow; - if (now - _lastAlertResolveLog >= TimeSpan.FromSeconds(1)) + bool hasFrame = frame != null; + bool wasLoggedThisState = hasFrame == _lastAlertHadFrame; + if (!wasLoggedThisState || now - _lastAlertResolveLog >= TimeSpan.FromSeconds(10)) { + _lastAlertHadFrame = hasFrame; _lastAlertResolveLog = now; - AppLog.Write(frame == null - ? $"Output resolver: alert box '{alert.Id}' frame is null (visible={alert.IsVisible} playing={_alertLayer.IsPlaying}) — skipped in composite" - : $"Output resolver: alert box '{alert.Id}' frame {frame!.Width}x{frame!.Height} (visible={alert.IsVisible} playing={_alertLayer.IsPlaying})"); + AppLog.Write(hasFrame + ? $"Output resolver: alert box '{alert.Id}' frame {frame!.Width}x{frame!.Height} (visible={alert.IsVisible} playing={_alertLayer.IsPlaying})" + : $"Output resolver: alert box '{alert.Id}' frame is null (visible={alert.IsVisible} playing={_alertLayer.IsPlaying}) — skipped in composite"); } } return frame; } private DateTime _lastAlertResolveLog = DateTime.MinValue; + private bool _lastAlertHadFrame = false; private DateTime _lastWebcamNullLog = DateTime.MinValue;