Skip to content

[Impeller] Fix Vulkan GPU frame time metrics in benchmarks - #196339

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
andywolff:frame-time-metrics-fix
Nov 19, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:masterfrom
andywolff:frame-time-metrics-fix

Conversation

@andywolff

@andywolff andywolff commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Part of #196096

Vulkan GPU frame time metrics were reporting 0 ms because swapchain presentation closed the GPU tracer frame scope before the onscreen command buffer ended.

When #161140 moved onscreen command buffer submission into swapchain presentation, both the AHB and KHR swapchains called MarkFrameEnd before ending the onscreen command buffer. On top of that, the KHR swapchain ended the raw Vulkan command buffer directly instead of calling CommandBufferVK::EndCommandBuffer, which is responsible for recording the end timestamp. Because end timestamps for the onscreen pass were dropped, single-pass frames only had a start timestamp (0 ms duration) and multi-pass frames missed the onscreen pass.

Both swapchains now end the onscreen command buffer through CommandBufferVK::EndCommandBuffer before calling MarkFrameEnd, using a cleanup guard so early returns still close the frame.

Measured locally on a Pixel 7 (cubic_bezier_perf__timeline_summary with EnableVulkanGPUTracing enabled). Enabling EnableVulkanGPUTracing for default-Impeller Android devicelab benchmarks will follow in a separate PR:

Metric Before After
average_gpu_frame_time 0.0 ms 1.67 ms
90th_percentile_gpu_frame_time 0.0 ms 3.45 ms
99th_percentile_gpu_frame_time 0.0 ms 4.25 ms
worst_gpu_frame_time 0.0 ms 4.50 ms

Pre-launch Checklist

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Nov 10, 2026
@andywolff andywolff added the CICD Run CI/CD label Nov 10, 2026
@andywolff
andywolff force-pushed the frame-time-metrics-fix branch 4 times, most recently from b4ca3eb to f6906bb Compare November 13, 2026 22:58
@andywolff
andywolff force-pushed the frame-time-metrics-fix branch from f6906bb to 0a5ffbe Compare November 17, 2026 18:23
@andywolff

andywolff commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

I split out a change to the device lab config into a followup PR. For that reason, I chose to verify in CI against rrect_blur_perf__timeline_summary instead of cubic_bezier_perf__timeline_summary because it already opts into EnableVulkanGPUTracing on master

https://ci.chromium.org/b/8665129854012373585:

  • average_gpu_frame_time: 5.56 ms
  • 90th_percentile_gpu_frame_time: 6.12 ms
  • 99th_percentile_gpu_frame_time: 6.89 ms
  • worst_gpu_frame_time: 7.59 ms

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds GPU tracing support for onscreen command buffers in the Vulkan backend's AHB and KHR swapchains, utilizing fml::ScopedCleanupClosure to mark frame ends. It also updates the mock Vulkan test framework to support query pools and timestamps, adding corresponding unit tests. Feedback on the changes highlights a missing explicit include for fml/closure.h in ahb_swapchain_impl_vk.cc and an incorrect bounds check in the mock Vulkan's vkGetQueryPoolResults that could lead to out-of-bounds writes or skipped elements.

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, let's just do the plumbing to remove a static variable. That can cause cross test weirdness.

std::vector<uint64_t> timestamps IPLR_GUARDED_BY(mutex);
};

static std::atomic<uint64_t> g_next_mock_timestamp{1000000u};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of using a static variable can you store this on the mock device. That requires a bit of plumbing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done. Plumbing wasn't too bad

Mutex called_functions_mutex_;
std::shared_ptr<std::vector<std::string>> called_functions_
IPLR_GUARDED_BY(called_functions_mutex_);
std::vector<uint32_t> query_pool_result_counts_

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no action required: i wonder if this is getting to the point where we should migrate to gmock.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I see NiceMock used in the GLES tests, which looks like a clean pattern to follow if we migrate this to gmock

@flutter-dashboard

Copy link
Copy Markdown

CI had a failure that stopped further tests from running. We need to investigate to determine the root cause.

SHA at time of execution: d5e6a21.

Possible causes:

  • Configuration Changes: The .ci.yaml file might have been modified between the creation of this pull request and the start of this test run. This can lead to ci yaml validation errors.
  • Infrastructure Issues: Problems with the CI environment itself (e.g., quota) could have caused the failure.

A blank commit, or merging to head, will be required to resume running CI for this PR.

Error Details:

DetailedApiRequestError(status: 503, message: Authentication backend unavailable.)

Stack trace:

#0      validateResponse (package:_discoveryapis_commons/src/api_requester.dart:323:9)
<asynchronous suspension>
#1      ApiRequester.request (package:_discoveryapis_commons/src/api_requester.dart:82:16)
<asynchronous suspension>
#2      ProjectsTopicsResource.publish (package:googleapis/pubsub/v1.dart:2103:23)
<asynchronous suspension>
#3      PubSub.publish (package:cocoon_service/src/request_handling/pubsub.dart:39:22)
<asynchronous suspension>
#4      LuciBuildService._scheduleTryBuilds (package:cocoon_service/src/service/luci_build_service.dart:437:7)
<asynchronous suspension>
#5      Scheduler._runCiTestingStage (package:cocoon_service/src/service/scheduler.dart:1586:7)
<asynchronous suspension>
#6      Scheduler.proceedToCiTestingStage (package:cocoon_service/src/service/scheduler.dart:1636:7)
<asynchronous suspension>
#7      Scheduler._closeSuccessfulEngineBuildStage (package:cocoon_service/src/service/scheduler.dart:1421:5)
<asynchronous suspension>
#8      Scheduler.processBuildCompleted (package:cocoon_service/src/service/scheduler.dart:1362:11)
<asynchronous suspension>
#9      PresubmitSubscription._processBuild (package:cocoon_service/src/request_handlers/presubmit_subscription.dart:228:7)
<asynchronous suspension>
#10     PresubmitSubscription.post (package:cocoon_service/src/request_handlers/presubmit_subscription.dart:119:5)
<asynchronous suspension>
#11     RequestHandler.service (package:cocoon_service/src/request_handling/request_handler.dart:42:20)
<asynchronous suspension>
#12     SubscriptionHandler.service (package:cocoon_service/src/request_handling/subscription_handler.dart:134:5)
<asynchronous suspension>
#13     createServer.<anonymous closure> (package:cocoon_service/server.dart:462:7)
<asynchronous suspension>
#14     main.<anonymous closure>.<anonymous closure> (file:///app/app_dart/bin/gae_server.dart:192:9)
<asynchronous suspension>

@andywolff
andywolff requested a review from gaaclarke November 18, 2026 19:50

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm!

@andywolff andywolff added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 18, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 19, 2026
Merged via the queue into flutter:master with commit 6363fc7 Nov 19, 2026
21 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 19, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 19, 2026
flutter/flutter@06f32f8...e8cc6f3

2026-11-19 [email protected] Roll Skia from 280e0965687d to 3dfb69d709c7 (1 revision) (flutter/flutter#196970)
2026-11-19 [email protected] Update outdated `_formattedValues` documentation (flutter/flutter#195765)
2026-11-19 [email protected] [Impeller] Fix Vulkan GPU frame time metrics in benchmarks (flutter/flutter#196339)
2026-11-19 [email protected] Windows: Enable D3D11 multithread protection on ANGLE's device (flutter/flutter#196897)
2026-11-19 [email protected] Roll Skia from 7356c7627e87 to 280e0965687d (1 revision) (flutter/flutter#196957)
2026-11-19 [email protected] Roll Dart SDK from 091f346ad95c to d8d40cf9c21b (2 revisions) (flutter/flutter#196949)
2026-11-19 [email protected] Roll Skia from 73b9219fd1fa to 7356c7627e87 (4 revisions) (flutter/flutter#196951)
2026-11-19 [email protected] Roll Skia from 7bca23228537 to 73b9219fd1fa (1 revision) (flutter/flutter#196948)
2026-11-19 [email protected] [libimpeller] Fix swapped x and y glyph coordinates (flutter/flutter#196552)
2026-11-19 [email protected] [ios][spm]When using cocoapods plugin, give instruction that plugins may just need update (flutter/flutter#195853)
2026-11-19 [email protected] [web] Let the browser handle Control+wheel zoom outside of macOS (flutter/flutter#193362)
2026-11-19 [email protected] Fix focus violation when canRequestFocus set to false for all siblings in same build (flutter/flutter#191536)
2026-11-19 [email protected] Roll Skia from 9fc4f9e23d56 to 7bca23228537 (10 revisions) (flutter/flutter#196941)
2026-11-19 [email protected] Roll Dart SDK from 753488ede427 to 091f346ad95c (2 revisions) (flutter/flutter#196940)
2026-11-19 [email protected] iOS: Convert platform views to points with the frame's pixel ratio (flutter/flutter#196858)
2026-11-19 [email protected] [engine] Defer default font manager resolution to first use for platforms that have a prefetching API only (flutter/flutter#196377)
2026-11-18 [email protected] [flutter_tools] Add example app to package template and decouple platform configurations (flutter/flutter#192441)
2026-11-18 [email protected] [flutter_tools] Rebuild asset bundle when generated manifest content changes (flutter/flutter#191638)
2026-11-18 [email protected] Roll Skia from b11d69796f71 to 9fc4f9e23d56 (2 revisions) (flutter/flutter#196909)
2026-11-18 [email protected] [flutter_tools] Bump cupertino_icons to ^2.0.0 in app and module templates (flutter/flutter#196828)
2026-11-18 [email protected] Update iOS plugin language instructions (flutter/flutter#196614)
2026-11-18 [email protected] iOS: Add tests for rounded rect clips with per-corner/elliptical radii (flutter/flutter#196854)
2026-11-18 [email protected] Revert: [flutter_tools] Migrate lib/runner.dart off runInContext and overrides (flutter/flutter#196926)
2026-11-18 [email protected] Revert: Move macOS desktop builds to ThinLTO (flutter/flutter#196917)
2026-11-18 [email protected] [FGP] Offset split-APK versionCodes from a manifest-only versionCode (flutter/flutter#196561)
2026-11-18 [email protected] [flutter_tools] Migrate lib/runner.dart off runInContext and overrides (flutter/flutter#196387)
2026-11-18 [email protected] docs: remove broken image references from dev/snippets/README.md (flutter/flutter#195587)
2026-11-18 [email protected] Remove the FGP AGP-public-API migration coordination docs (flutter/flutter#196733)
2026-11-18 [email protected] [web] Skip stale safeBlur focus transfer when the element was refocused (flutter/flutter#196550)
2026-11-18 [email protected] Roll Skia from 81ee7327e81c to b11d69796f71 (4 revisions) (flutter/flutter#196900)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
mdebbar pushed a commit to mehmetbahadirgungor/flutter that referenced this pull request Nov 20, 2026
…PerfTests (flutter#196822)

Fixes flutter#196096

Depends on flutter#196339.

Android devicelab benchmarks that rely on Impeller being enabled by
default were not turning on Vulkan GPU tracing. The manifest setup in
`PerfTest` still treated `enableImpeller` as `false` when omitted, a
leftover from when Skia was the default on Android. Benchmarks like
`cubic_bezier_perf__timeline_summary` skipped injecting
`EnableVulkanGPUTracing` into `AndroidManifest.xml` as a result.

`PerfTest` now enables Vulkan GPU tracing on Android whenever Impeller
is not explicitly disabled, scoped to Android devices so iOS and desktop
runs do not touch `AndroidManifest.xml`. The other manifest flags stay
under the existing explicit-opt-in gate.

Vulkan GPU tracing and the GPU frame time score keys are disabled for
`PerfTest.e2e`, OpenGL ES runs, and the multi-surface platform-view
benchmarks. `PerfTest.e2e` does not report GPU frame times., and
multi-surface tracing doesn't work right yet
(flutter#196834).

I expect the performance dashboard will start showing the frame time
metrics after this PR merges.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants