Sitelet https://github.com/flutter/flutter/pull/179874
Skip to content

Only render views that need to be rendered (with external texture & platform view support) - #179874

Merged
knopp merged 45 commits into
flutter:masterfrom
9AZX:fix_multiview_repaint
Aug 18, 2026
Merged

knopp merged 45 commits into
flutter:masterfrom
9AZX:fix_multiview_repaint

Conversation

@9AZX

@9AZX 9AZX commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

Fixes #164320
Based on @knopp work in #164322

This PR adds a dirty-view compositing optimization that skips compositing for views that don't have any dirty render objects, so it should improves performance in multi-view scenarios by avoiding unnessacery work.

When a texture has new content, the framework now gets notified via a new onTextureFrameAvailable callback from the engine. This marks the texture's render object as needing paint, so its view is included in compositing even when nothing else changed.

On Android, texture callbacks now use markTextureFrameAvailable instead of scheduleEngineFrame. This is actually more efficient since it reuses the existing layer tree rather than regenerating it. Other platforms already used the correct path.

It also forces all views to composite when returning from background, ensuring the display is properly refreshed after the app was paused.

On MacOS:

Screen.Recording.2025-12-15.at.11.54.17.mov

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@9AZX
9AZX requested a review from a team as a code owner December 15, 2025 10:59
@github-actions github-actions Bot added platform-android Android applications specifically framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine related. See also e: labels. team-android Owned by Android platform team labels Dec 15, 2025
gemini-code-assist[bot]

This comment was marked as outdated.

@9AZX
9AZX force-pushed the fix_multiview_repaint branch from 19da943 to 71bab07 Compare December 15, 2025 12:03
@9AZX

9AZX commented Dec 15, 2025

Copy link
Copy Markdown
Contributor Author

cc @Saviq @mattkae @robert-ancell

@knopp

knopp commented Dec 16, 2025

Copy link
Copy Markdown
Member

@9AZX, it seems that onTextureFrameAvailable has not been added to the platform_dispatcher.dart inside web_ui causing the CI failures.

@9AZX
9AZX force-pushed the fix_multiview_repaint branch from 71bab07 to 5a3ac8c Compare December 16, 2025 16:47
@github-actions github-actions Bot added the platform-web Web applications specifically label Dec 16, 2025
@9AZX
9AZX force-pushed the fix_multiview_repaint branch 4 times, most recently from eaab6aa to 0059b33 Compare December 17, 2025 16:16
@9AZX

9AZX commented Dec 17, 2025 •

Copy link
Copy Markdown
Contributor Author

@9AZX, it seems that onTextureFrameAvailable has not been added to the platform_dispatcher.dart inside web_ui causing the CI failures.

My bad! I didn't know that web_ui has his own platform_dispatcher and I was asking myself why it don't take my changes from ui 😓

@justinmc

Copy link
Copy Markdown
Contributor

@9AZX FYI there are failures

@9AZX
9AZX force-pushed the fix_multiview_repaint branch 2 times, most recently from 08205c4 to cfbdf5b Compare December 31, 2025 18:37
@9AZX
9AZX marked this pull request as draft December 31, 2025 18:37
@9AZX
9AZX force-pushed the fix_multiview_repaint branch 7 times, most recently from bdb2a9f to faadca6 Compare January 17, 2026 12:37
@9AZX
9AZX force-pushed the fix_multiview_repaint branch from dddcf84 to 8b00990 Compare February 9, 2026 17:45
@9AZX
9AZX marked this pull request as ready for review February 9, 2026 22:10
@9AZX
9AZX force-pushed the fix_multiview_repaint branch from d4624c5 to e7f9828 Compare February 9, 2026 22:12

@chunhtai chunhtai 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.

LGTM

@loic-sharma loic-sharma 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.

Re-LGTM

@auto-submit

auto-submit Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/179874, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@flutteractionsbot

Copy link
Copy Markdown
Contributor

A reason for requesting a revert of flutter/flutter/179874 could not be found or the reason was not properly formatted. Begin a comment with 'Reason for revert:' to tell the bot why this issue is being reverted.

@flar

flar commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Reason for revert: #191251

@knopp

knopp commented Aug 18, 2026

Copy link
Copy Markdown
Member

welp. that didn't take long.

@flutteractionsbot

Copy link
Copy Markdown
Contributor

Successfully created revert PR: #191252

@flar

flar commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

welp. that didn't take long.

Is there a sad emoji? The closest I found in the list was "confused" which didn't sound right. Anyway... 😢

@knopp

knopp commented Aug 18, 2026

Copy link
Copy Markdown
Member

welp. that didn't take long.

Is there a sad emoji? The closest I found in the list was "confused" which didn't sound right. Anyway... 😢

I am wondering a bit if something like this should have been caught in presubmit checks...

@flar

flar commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

I am wondering a bit if something like this should have been caught in presubmit checks...

Benchmarks only run after submit because we record them in a dashboard by their true final commit. During pre-submit they don't have a commit key to report against. We could potentially run them in "don't submit/dry run" mode maybe in pre-submit, though. I'm not sure how the web benchmarks are configured or whether they have such a mode.

We also briefly looked at some other benchmark dashboards at least one of which had a nice feature that you could run your benchmarks in pre-submit and get a report on any potential regression. It would take some effort to upgrade all of our benchmarks to a new system, though. :(

@jtmcdole

Copy link
Copy Markdown
Member

We can't run benchmarks on every PR since that requires running on a phone. If we had an analogue that was just running benchmarks on a machine, I'd entertain a test in presubmit.

The only other option is using led to run the benchmark on a machine in the try pool.

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

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. framework flutter/packages/flutter repository. See also f: labels. platform-android Android applications specifically platform-web Web applications specifically team-android Owned by Android platform team team-web Owned by Web platform team triaged-android Triaged by Android platform team triaged-web Triaged by Web platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Multiview] Flutter re-renders all views during each update