Repository navigation
Description
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Every time the mouse moved over the edge-light frame, ApplyHolePunchEffect allocated two new heap objects:
var hole = new EllipseGeometry(localCenter, holeRadius, holeRadius);
borderPath.Data = new CombinedGeometry(GeometryCombineMode.Exclude, baseGeometry, hole);At 100+ mouse-move events/second this creates ~200 short-lived objects/second per monitor, causing sustained GC pressure and potentially contributing to micro-stutters in the animation.
Fix
Cache one EllipseGeometry and one CombinedGeometry per monitor context (main window + each additional monitor). On mouse-move, instead of allocating new objects, just update holeGeometry.Center in-place — WPF automatically propagates geometry mutations through the dependency-property system to re-render the path without any allocations.
// Before (allocates 2 objects per mouse event)
var hole = new EllipseGeometry(localCenter, holeRadius, holeRadius);
borderPath.Data = new CombinedGeometry(GeometryCombineMode.Exclude, baseGeometry, hole);
// After (zero allocations per mouse event)
holeGeometry.Center = localCenter;
if (borderPath.Data != combinedGeometry)
borderPath.Data = combinedGeometry;The caches are initialized in CreateFrameGeometry / CreateMonitorWindow and recreated in UpdateMonitorGeometry when the frame size changes.
Trade-offs
None. WPF EllipseGeometry is a Freezable — mutating its Center raises Changed notifications that CombinedGeometry listens to, so rendering behaviour is identical.
Test Status
✅ Built successfully (dotnet build -p:EnableWindowsTargeting=true) — 0 warnings, 0 errors.
i️ No automated tests exist in this repository.
Note
🔒 Integrity filter blocked 1 item
The following item were blocked because they don't meet the GitHub integrity level.
- #144
list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
To allow these resources, lower min-integrity in your GitHub frontmatter:
tools:
github:
min-integrity: approved # merged | approved | unapproved | noneGenerated by Repo Assist · ● 4.2M · ◷
To install this agentic workflow, run
gh aw add githubnext/agentics/workflows/repo-assist.md@cbb46ab386962aa371045839fc9998ee4e97ca64
Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch repo-assist/perf-cache-hole-geometry-2026-07-30-4bd4085ad4c5f251.
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ
Show patch preview (153 of 153 lines)
From fde32ce9d7fedee7b5af1715056a85dd100d0e4e Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Thu, 30 Jul 2026 13:22:52 +0000
Subject: [PATCH] perf: cache hole geometries to eliminate per-mouse-event
allocations
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In ApplyHolePunchEffect, every mouse-move event over the frame was
allocating a new EllipseGeometry and CombinedGeometry (2 heap objects
per event). At 100+ events/second this creates significant GC pressure.
Instead, cache one EllipseGeometry and CombinedGeometry per monitor
context (main window + each additional monitor). On mouse-move, just
update holeGeometry.Center in-place — WPF automatically propagates
the geometry change to the visual tree without any new allocations.
Caches are initialized in CreateFrameGeometry / CreateMonitorWindow
and recreated in UpdateMonitorGeometry when the frame size changes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
WindowsEdgeLight/MainWindow.xaml.cs | 41 ++++++++++++++++++++++-------
1 file changed, 32 insertions(+), 9 deletions(-)
diff --git a/WindowsEdgeLight/MainWindow.xaml.cs b/WindowsEdgeLight/MainWindow.xaml.cs
index 3644301..6bb8dfd 100644
--- a/WindowsEdgeLight/MainWindow.xaml.cs
+++ b/WindowsEdgeLight/MainWindow.xaml.cs
@@ -55,6 +55,9 @@ public partial class MainWindow : Window
public double PathOffsetY { get; set; }
public double DpiScaleX { get; set; } = 1.0;
public double DpiScaleY { get; set; } = 1.0;
+ // Cached geometries reused on every mouse-move to avoid heap allocations
+ public EllipseGeometry HoleGeometry { get; set; } = null!;
+ public CombinedGeometry HoleCombinedGeometry { get; set; } = null!;
}
// Monitor management
@@ -139,6 +142,9 @@ public partial class MainWindow : Window
private readonly Ellipse? hoverCursorRing;
// Added fields for hole ef
... (truncated)
Activity
shanselman commentedon Aug 8, 2026
Superseded by the focused implementation in #158.