Skip to content

Avoid unlimited-loop spin when rendering is skipped#6

Merged
SteffenCarlsen merged 1 commit into
mainfrom
feature/unlimited-paused-yield
Jun 1, 2026
Merged

Avoid unlimited-loop spin when rendering is skipped#6
SteffenCarlsen merged 1 commit into
mainfrom
feature/unlimited-paused-yield

Conversation

@SteffenCarlsen

Copy link
Copy Markdown
Owner

Fixes FrameRateLimit.Unlimited so paused, hidden, or target-paused overlays report skipped work and the owner thread briefly waits instead of spinning hot. Active unlimited rendering still runs without the fixed frame delay. Validation: dotnet test tests\ModernOverlay.Tests\ModernOverlay.Tests.csproj --configuration Debug --filter HiddenUnlimitedOverlayPausesWithoutRendering.

Copilot AI review requested due to automatic review settings June 1, 2026 13:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a hot-spin behavior when FrameRateLimit.Unlimited is used but rendering is effectively skipped (e.g., overlay hidden with pause policy, paused overlay, or target-paused). It does this by having the render callback report whether any frame work was actually performed, allowing the Win32 owner thread’s unlimited loop to briefly wait instead of continuously spinning.

Changes:

  • Add a Windows integration test ensuring a hidden overlay with FrameRateLimit.Unlimited performs zero render callbacks/frames.
  • Change OverlayWindow.RenderOneFrame to return bool indicating whether a render was actually performed.
  • Extend the Win32 owner-thread frame-loop API to accept Func<bool> and use a short MsgWaitForMultipleObjectsEx wait in unlimited mode when no work was done.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tests/ModernOverlay.Tests/OverlayWindowThreadingTests.cs Adds a regression test for hidden + unlimited frame rate to ensure no rendering occurs.
src/ModernOverlay/OverlayWindow.cs Makes per-frame render attempt report “did work” via a boolean return.
src/ModernOverlay.Win32/Win32OwnerThread.cs Adds Func<bool> frame loop overload and introduces a brief wait when unlimited rendering is skipped.
src/ModernOverlay.Win32/Win32OverlayWindow.cs Plumbs the new Func<bool> frame loop overload through the Win32 window wrapper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SteffenCarlsen SteffenCarlsen merged commit fed4154 into main Jun 1, 2026
2 checks passed
@SteffenCarlsen SteffenCarlsen deleted the feature/unlimited-paused-yield branch June 1, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants