Skip to content

fix(skia): Stop FPS indicator from waking renderer when idle - #23205

Merged
MartinZikmund merged 1 commit into
masterfrom
dev/mazi/fpswakeup
May 6, 2026
Merged

MartinZikmund merged 1 commit into
masterfrom
dev/mazi/fpswakeup

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

Summary

Fixes #23204.

The FPS diagnostic panel is meant to do a single final redraw to "Idle" and then go quiet. In practice the numeric values kept updating every 2-3 seconds, indicating the panel itself was waking the renderer continuously.

Two compounding bugs in FpsHelper (src/Uno.UI/Helpers/SkiaRenderHelper.skia.cs):

  • Bug A — first-idle-tick RequestRedraw sabotaged idle detection. The noNewFrames branch of TimerTick called RequestRedraw on every first idle tick. The resulting render flowed through OnFrameRecorded, which bumped _currentFrameGeneration. The next tick observed the new generation, decided noNewFrames = false, and reset _consecutiveIdleTicks = 0. The counter could never reach 2 and idle was never entered. (Leftover from the original idle-indicator commit, where the redraw was needed before the >= 2 early-return path was introduced.)
  • Bug B — final idle redraw restarted the 1 Hz timer via BeginFrame. Even with Bug A fixed, the legitimate final idle redraw flowed through Draw() -> RenderPicture() -> BeginFrame(), which blindly restarted the timer because !_timerRunning. The immediate TimeSpan.Zero tick saw the just-recorded idle frame's bumped generation, cleared _isIdle, and the cycle restarted every 2-3 seconds.

Changes

  • Removed the spurious first-idle-tick RequestRedraw call in TimerTick.
  • Added an _idleRedrawPending flag set when triggering the final idle redraw and consumed by BeginFrame to skip the timer restart for that one render.
  • Cleared the flag in StopTimer so disable/re-enable cycles start fresh.

Test plan

No automated runtime test covers this — it's a timing/wakeup behaviour. Manual verification on Skia desktop:

  • Build Uno.UI-Skia-only.slnf.
  • Run SamplesApp on Skia desktop and enable the FPS counter.
  • Active rendering: numbers update once per second, dark background.
  • Idle entry: stop interacting; within ~2 seconds the panel switches to the tinted "Idle" background and the bottom-right cell reads "Idle".
  • Idle stability: leave idle for 30+ seconds; numbers stay frozen and the panel does not flicker. Confirm zero render wake-ups (a temporary log in Render() or watching CPU/GPU usage).
  • Resume: interact again; numbers update on the next render and the background returns to the dark variant.

🤖 Generated with Claude Code

Two compounding bugs in FpsHelper kept the renderer awake every 2-3 seconds
after rendering went idle:

A. The first-idle-tick branch of TimerTick called RequestRedraw, bumping
   _currentFrameGeneration via OnFrameRecorded. The next tick saw that as
   activity and reset the counter, so idle was never detected.

B. The final idle redraw flowed through BeginFrame, which blindly restarted
   the 1 Hz timer. The immediate tick saw the just-recorded idle frame and
   flipped _isIdle back to false.

Removed the spurious first-tick RequestRedraw and added an _idleRedrawPending
flag set when triggering the final idle redraw and consumed by BeginFrame to
skip the timer restart for that one render.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings May 5, 2026 12:43
@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label May 5, 2026
@MartinZikmund
MartinZikmund enabled auto-merge May 5, 2026 12:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 210864 found UI Test snapshots differences: skia-linux-screenshots: 0, skia-windows-screenshots: 100, wasm: 0

Details
  • skia-linux-screenshots: 0 changed over 2338

  • skia-windows-screenshots: 100 changed over 2338

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • EllipsemaskingEllipseGrid.png-dark
    • EllipsemaskingEllipseGrid.png
    • ContentPresenter_TextProperties.png-dark
    • ContentPresenter_TextProperties.png
    • Examples.png-dark
    • Examples.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • FluentStyle_NavigationViewSample.png-dark
    • FluentStyle_NavigationViewSample.png
    • ButtonClippingTestsControl.png-dark
    • Buttons.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • DisplayInformation.png-dark
  • wasm: 0 changed over 1073

@MartinZikmund
MartinZikmund merged commit e28c434 into master May 6, 2026
49 of 50 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/fpswakeup branch May 6, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FPS indicator wakes up the renderer continuously when idle

5 participants