Avoid unlimited-loop spin when rendering is skipped#6
Merged
Conversation
There was a problem hiding this comment.
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.Unlimitedperforms zero render callbacks/frames. - Change
OverlayWindow.RenderOneFrameto returnboolindicating whether a render was actually performed. - Extend the Win32 owner-thread frame-loop API to accept
Func<bool>and use a shortMsgWaitForMultipleObjectsExwait 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.