Skip to content

fix(framebuffer): Pace software rendering when vsync is unavailable - #25382

Merged
ramezgerges merged 2 commits into
masterfrom
dev/mazi/framebuffer-software-pacing
Nov 3, 2026
Merged

ramezgerges merged 2 commits into
masterfrom
dev/mazi/framebuffer-software-pacing

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #25327

PR Type:

🐞 Bugfix

What changed? 🚀

SoftwareRenderer waited for FBIO_WAITFORVSYNC between frames but ignored the ioctl's result. Virtual and many driverless framebuffers don't support it, so the call returns at once and an animation renders frames back to back as fast as the CPU allows.

This is what's happening on the Linux Framebuffer CI lane. Its log shows the DRM path failing (drmModeAddFB2 failed -22) and the app falling back to Software renderer initialized: 1024x768 on /dev/fb0. The InteractionTracker moves once per frame, so a 10 ms scroll animation gets 3-5 frames, and ScrollPresenterTests.OffsetsChangeWithCustomDuration sees 3-5 ViewChanged events where it allows 2. It also means a real app on such a device spins a CPU core during every animation.

FrameBufferDevice.VSync() now reports whether the ioctl worked. When it doesn't, the software renderer paces frames to 60 fps (the interval other Skia hosts use) with a Stopwatch-based wait. Devices with working vsync and the DRM renderer (paced by page flips) are unchanged.

Testing

  • New runtime test Given_CompositionTarget.When_FrameBuffer_Renders_Continuously_Then_Frames_Are_Paced (Framebuffer only): with a frame driver subscribed for one second, the tick count must stay at or below 75.
  • ScrollPresenterTests.OffsetsChangeWithCustomDuration on the Linux Framebuffer lane covers the visible effect.
  • I can't run the Framebuffer head on macOS, so this is verified by the build only. The Linux Framebuffer lane of this PR is the real check.

PR Checklist ✅

🤖 Generated with Claude Code

MartinZikmund and others added 2 commits October 13, 2026 08:19
The software renderer waited for FBIO_WAITFORVSYNC between frames but
ignored its result. Virtual and many driverless framebuffers don't
support it, so the ioctl returns at once and animations render frames
back to back as fast as the CPU allows. Besides burning CPU, a 10 ms
scroll animation then ticks 3-5 times instead of 1-2, which is why
ScrollPresenterTests.OffsetsChangeWithCustomDuration fails on the Linux
Framebuffer CI lane (it renders through /dev/fb0 after the DRM path
falls back).

When the ioctl fails, frames are now paced to 60 fps instead.

Fixes #25327

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Continuous rendering on the Framebuffer head must stay around 60 fps.
ScrollPresenterTests.OffsetsChangeWithCustomDuration also covers the
visible effect (ViewChanged count of a 10 ms animation).

Related to #25327

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 13, 2026 06:22

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 was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 20s —— View job


Review of #25382

Verdict: ship. I found 0 blocking, 0 major and 0 minor issues, so I posted no inline comments.

  • Root cause: The fix targets it. FBIO_WAITFORVSYNC failed silently, so the render loop had no pacing. VSync() now reports the result. Pacing falls back to 60 fps only when the ioctl fails, so devices with working vsync and the DRM path behave as before.
  • Pacing logic: WaitForFallbackFrameInterval is correct. The first frame doesn't wait because the timestamp starts at 0. The timestamp is taken after the sleep, so frames are at least ~16.7 ms apart. It also doesn't throttle idle periods, because the loop blocks on the invalidation event.
  • Style: It follows the repo conventions: braces, tabs, no new warnings, and the #pragma warning disable CA1806 is gone.
  • Test: The new runtime test is limited to SkiaFrameBuffer and checks the 75-tick upper bound with some timer-jitter slack. It would have failed before the fix. The Linux Framebuffer CI lane has to confirm it, since the PR notes the head wasn't run locally. Please check that lane, including ScrollPresenterTests.OffsetsChangeWithCustomDuration, before merging.

Not blocking:

  • If the ioctl fails transiently, for example with EINTR, that one frame is paced by the fallback. This is harmless.
  • Stopwatch plus Thread.Sleep has ~1 ms granularity on Linux. That is fine at a 16.7 ms interval.

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 239113 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • DisplayInformation.png-dark
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • Focus_FocusVisual_Properties.png-dark
    • Focus_FocusVisual_Properties.png
    • DropDownButtonPage.png-dark
    • Examples.png
    • ImageBrushInList.png-dark
    • ImageBrushInList.png
  • skia-windows-screenshots: 2458 changed over 2488

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png-dark
    • Accessibility_ScreenReader.png-dark
    • AndroidWindowInsets.png
    • AnimatedIconPage.png-dark
    • AnimatedIconPage.png
    • Accessibility_ScreenReader.png
    • AppBarButtonWithIconTest.png
    • ApplicationViewMode.png
    • AnimatedVisualsTestbedPage.png-dark
    • AppBarButtonTest.png-dark
    • AnimatedVisualsTestbedPage.png
    • Application_DispatcherShutdownMode.png
    • AppBar_KeyBoard.png-dark
    • AppWindowClosing.png
    • ApplicationViewSizing.png
    • AppBarButtonTest.png
    • AppBar_KeyBoard.png
    • AppWindowTitleBar Properties.png
    • ApplicationViewSpanningRectsPage.png-dark
    • AppWindowPresenters.png

@MartinZikmund MartinZikmund added the 7.1 PRs only. For issues, use the Release field. label Oct 14, 2026
@ramezgerges
ramezgerges merged commit 0f3e406 into master Nov 3, 2026
51 checks passed
@ramezgerges
ramezgerges deleted the dev/mazi/framebuffer-software-pacing branch November 3, 2026 19:03
@mergify

mergify Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@agneszitte

Copy link
Copy Markdown
Member

/unobot prepare-release --commit-message-pattern "ci: Set version to '{0}'"

@unodevops

Copy link
Copy Markdown
Contributor

The release branch release/stable/7.0 has been created from 42b8d73 and the PR #25994 has been created for the version bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.1 PRs only. For issues, use the Release field. area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ScrollPresenterTests.OffsetsChangeWithCustomDuration fails on the Linux Framebuffer CI leg (3-5 ViewChanged events for a 10 ms animation)

6 participants