Skip to content

iOS: Represent platform view frames as FlutterPlatformViewFrames - #196955

Merged
cbracken merged 1 commit into
flutter:masterfrom
cbracken:pv-refactor-5
Nov 20, 2026
Merged

cbracken merged 1 commit into
flutter:masterfrom
cbracken:pv-refactor-5

Conversation

@cbracken

Copy link
Copy Markdown
Member

Under the embedder API, the engine passes each frame to the embedder as a list of FlutterLayers via the FlutterCompositor present callback. The platform view management code that runs on the platform thread uses internal engine types such as EmbeddedViewParams and OverlayLayer, which the embedder will no longer have access to after migration to the embedder API. This converts frame-specific platform view details into a pure Obj-C FlutterPlatformViewFrame type that the embedder can deal with in its platform thread logic.

The engine hands each frame to the embedder's submitFrame: on the raster thread with internal C++ types. We now map those to the new Obj-C frame type there, and hand it to presentFrame: on the platform thread. Once we're on the embedder API, the engine will instead call the embedder's FlutterCompositor present callback with an array of FlutterLayers, and we'll do the translation there.

Since we won't have access to EmbeddedViewParams after migration to the embedder API, we won't be able to compare them with previousCompositionParams to decide whether a given platform view needs recompositing. Instead, we now compare FlutterPlatformViewLayers in presentFrame:, since they have everything we need.

Platform view clips are computed against the Flutter view's bounds, so we now recomposite all platform views when the Flutter view changes.

Issue: #112232

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@cbracken
cbracken requested a review from a team as a code owner November 19, 2026 08:31
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Nov 19, 2026
@github-actions github-actions Bot added platform-ios iOS applications specifically engine flutter/engine related. See also e: labels. team-ios Owned by iOS platform team labels Nov 19, 2026

@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 refactors the iOS platform views controller by introducing FlutterPlatformViewFrame and FlutterPlatformViewOverlay to encapsulate frame data and presentation logic, replacing the previous performSubmit: flow with presentFrame:. Feedback on these changes includes adding defensive nil checks to prevent runtime crashes when adding elements to NSMutableArray, avoiding division-by-zero errors if frame is nil, and preventing redundant compositing when FlutterPlatformViewInfo is missing. Additionally, several property declarations should be updated to explicitly specify their ownership attributes to comply with the Google Objective-C Style Guide.

Under the embedder API, the engine passes each frame to the embedder as
a list of `FlutterLayer`s via the `FlutterCompositor` present callback.
The platform view management code that runs on the platform thread uses
internal engine types such as `EmbeddedViewParams` and `OverlayLayer`,
which the embedder will no longer have access to after migration to the
embedder API. This converts frame-specific platform view details into a
pure Obj-C `FlutterPlatformViewFrame` type that the embedder can deal
with in its platform thread logic.

The engine hands each frame to the embedder's `submitFrame:` on the
raster thread with internal C++ types. We now map those to the new Obj-C
frame type there, and hand it to `presentFrame:` on the platform thread.
Once we're on the embedder API, the engine will instead call the
embedder's `FlutterCompositor` present callback with an array of
`FlutterLayer`s, and we'll do the translation there.

Since we won't have access to `EmbeddedViewParams` after migration to
the embedder API, we won't be able to compare them with
`previousCompositionParams` to decide whether a given platform view
needs recompositing. Instead, we now compare `FlutterPlatformViewLayer`s
in `presentFrame:`, since they have everything we need.

Platform view clips are computed against the Flutter view's bounds, so
we now recomposite all platform views when the Flutter view changes.

Issue: flutter#112232

@LouiseHsu LouiseHsu 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!!!

(const std::vector<std::unique_ptr<flutter::SurfaceFrame>>&)surfaceFrames
devicePixelRatio:(CGFloat)devicePixelRatio {
- (void)presentFrame:(FlutterPlatformViewFrame*)frame {
TRACE_EVENT0("flutter", "PlatformViewsController::PerformSubmit");

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.

should this TRACE_EVENT be presentFrame now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good question! I was tempted to but in a sense, trace event names are public "API" in that our/customer benchmarks might rely on them, so I'd like to change this, but I want to do it in its own commit, just in case someone complains. That way if we have to revert, we just revert the trace name.

@cbracken
cbracken added this pull request to the merge queue Nov 19, 2026
Merged via the queue into flutter:master with commit 2309416 Nov 20, 2026
19 checks passed
@cbracken
cbracken deleted the pv-refactor-5 branch November 20, 2026 01:06
cbracken added a commit to cbracken/flutter that referenced this pull request Nov 20, 2026
Previously, tests composited their platform views by prerolling their
`EmbeddedViewParams`, reading them back with
`compositionParamsForView:`, and passing them to
`compositeView:withParams:`. In
flutter#196955, we updated
`presentFrame:` to composite views from a `FlutterPlatformViewLayer`.

This deletes both methods. Tests now generate a layer in a
`CompositeView` helper function and and call
`compositeLayer:devicePixelRatio:`.

Most of the changes are just boilerplate migration but four tests
depended on more than just compositing:
* `testBackdropFilterCorrectlyPushedAndReset` pushes its filter through
  the controller, so we now preroll and submit a frame.
* `testFlutterPlatformViewControllerBeginFrameShouldResetCompisitionOrder`
  checks the composition order, so we now just preroll.
* `testFlutterPlatformViewControllerSubmitFrameWithoutFlutterViewNotCrashing`
  submits a frame that includes the view, so we still need the preroll.
* `testClipMaskViewIsReused` no longer begins a frame, since it no
  longer prerolls.

Issue: flutter#112232
cbracken added a commit to cbracken/flutter that referenced this pull request Nov 20, 2026
Previously, tests composited their platform views by prerolling their
`EmbeddedViewParams`, reading them back with
`compositionParamsForView:`, and passing them to
`compositeView:withParams:`. In
flutter#196955, we updated
`presentFrame:` to composite views from a `FlutterPlatformViewLayer`.

This deletes both methods. Tests now generate a layer in a
`CompositeView` helper function and and call
`compositeLayer:devicePixelRatio:`.

Most of the changes are just boilerplate migration but four tests
depended on more than just compositing:
* `testBackdropFilterCorrectlyPushedAndReset` pushes its filter through
  the controller, so we now preroll and submit a frame.
* `testFlutterPlatformViewControllerBeginFrameShouldResetCompisitionOrder`
  checks the composition order, so we now just preroll.
* `testFlutterPlatformViewControllerSubmitFrameWithoutFlutterViewNotCrashing`
  submits a frame that includes the view, so we still need the preroll.
* `testClipMaskViewIsReused` no longer begins a frame, since it no
  longer prerolls.

Issue: flutter#112232
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 20, 2026
Roll Flutter from e8cc6f3451b7 to b34b017b48ad (36 revisions)

flutter/flutter@e8cc6f3...b34b017

2026-11-20 [email protected] Fix OverflowBox dry layout when deferToChild overrides the constraints (flutter/flutter#196839)
2026-11-20 [email protected] Roll Dart SDK from f118f476ebce to 3b5f45d812f8 (1 revision) (flutter/flutter#197048)
2026-11-20 [email protected] [macOS] Register plugins in multiple_windows example (flutter/flutter#196068)
2026-11-20 [email protected] Roll Skia from 87027a9d4659 to a1edf5c2ea5c (1 revision) (flutter/flutter#197045)
2026-11-20 [email protected] Add highp directives to UberSDF to prevent overflow (flutter/flutter#196997)
2026-11-20 [email protected] [Impeller] Cap the Vulkan command pool recycler cache (flutter/flutter#194793)
2026-11-20 [email protected] Roll Skia from 12610b69511d to 87027a9d4659 (4 revisions) (flutter/flutter#197037)
2026-11-20 [email protected] [macOS] Unregister nil binary message handlers (flutter/flutter#193672)
2026-11-20 [email protected] Roll Dart SDK from b803c3ec01de to f118f476ebce (2 revisions) (flutter/flutter#197034)
2026-11-20 [email protected] Roll Skia from 2f1436ba8e64 to 12610b69511d (3 revisions) (flutter/flutter#197030)
2026-11-20 [email protected] [Android] Do not use the HCPP external view embedder from its platform tasks (flutter/flutter#196490)
2026-11-20 [email protected] Roll Dart SDK from 849e17ad3ae6 to b803c3ec01de (1 revision) (flutter/flutter#197012)
2026-11-20 [email protected] [iOS a11y] Synchronize hit-test children when replacing semantics objects (flutter/flutter#196439)
2026-11-20 [email protected] Sync CHANGELOG.md from stable (flutter/flutter#197019)
2026-11-19 [email protected] [flutter_tools] Reland "Extract Windows archives using native tar" (flutter/flutter#193515)
2026-11-19 [email protected] [Reland][flutter_tools] Migrate lib/runner.dart off runInContext and overrides (flutter/flutter#196931)
2026-11-19 [email protected] Include assigned issues in Android incoming triage link (flutter/flutter#197008)
2026-11-19 [email protected] [Flutter GPU] Record on the UI thread, encode and submit on the raster thread (flutter/flutter#194882)
2026-11-19 [email protected] Add Pixel 7 Pro Impeller benchmarks without fixed-performance mode (flutter/flutter#197010)
2026-11-19 [email protected] Reduce time of uiscene_plugin_lifecycle_test_ios (flutter/flutter#196363)
2026-11-19 [email protected] [native assets] Respect Apple deployment targets (flutter/flutter#194146)
2026-11-19 [email protected] iOS: Represent platform view frames as FlutterPlatformViewFrames (flutter/flutter#196955)
2026-11-19 [email protected] Roll Skia from 0bf961e4ff05 to 2f1436ba8e64 (3 revisions) (flutter/flutter#196999)
2026-11-19 [email protected] [ios] Record OCMReject expectations before the stimulus in FlutterPluginAppLifeCycleDelegateTest (flutter/flutter#193011)
2026-11-19 [email protected] Fix post-monorepo doc rot in docs/infra and dev/bots/README.md (flutter/flutter#193010)
2026-11-19 [email protected] Roll Skia from c3567e170362 to 0bf961e4ff05 (4 revisions) (flutter/flutter#196994)
2026-11-19 [email protected] Close Linux popups when their parent loses focuses (flutter/flutter#196825)
2026-11-19 [email protected] Roll Packages from dca2e58 to 81b7c44 (6 revisions) (flutter/flutter#196992)
2026-11-19 [email protected] Roll Dart SDK from d8d40cf9c21b to 849e17ad3ae6 (1 revision) (flutter/flutter#196986)
2026-11-19 [email protected] Fix RouteObserver didPushNext not firing when routes are pushed synchronously (flutter/flutter#189057)
2026-11-19 [email protected] [Impeller] Reuse render targets on text shadow cache misses (flutter/flutter#194769)
2026-11-19 [email protected] Roll Skia from 81de64af9806 to c3567e170362 (3 revisions) (flutter/flutter#196982)
2026-11-19 [email protected] Reland: "Move macOS desktop builds to ThinLTO" (flutter/flutter#196928)
2026-11-19 [email protected] [Linux] Desynchronize the Wayland subsurface so frames don't redraw the GTK window (flutter/flutter#195287)
2026-11-19 [email protected] Roll Skia from 3dfb69d709c7 to 81de64af9806 (1 revision) (flutter/flutter#196975)
2026-11-19 [email protected] Update `ProxyAnimation.didStartListening` and `ProxyAnimation. didStopListening` to use dart's `Conditional member access` (flutter/flutter#195762)

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:
...
harryterkelsen pushed a commit to harryterkelsen/flutter that referenced this pull request Nov 23, 2026
Previously, tests composited their platform views by prerolling their
`EmbeddedViewParams`, reading them back with
`compositionParamsForView:`, and passing them to
`compositeView:withParams:`. In
flutter#196955, we updated
`presentFrame:` to composite views from a `FlutterPlatformViewLayer`.

This deletes both methods. Tests now generate a layer in a
`CompositeView` helper function and and call
`compositeLayer:devicePixelRatio:`.

Most of the changes are just boilerplate migration but four tests
depended on more than just compositing:
* `testBackdropFilterCorrectlyPushedAndReset` pushes its filter through
the controller, so we now preroll and submit a frame.
*
`testFlutterPlatformViewControllerBeginFrameShouldResetCompisitionOrder`
checks the composition order, so we now just preroll.
*
`testFlutterPlatformViewControllerSubmitFrameWithoutFlutterViewNotCrashing`
submits a frame that includes the view, so we still need the preroll.
* `testClipMaskViewIsReused` no longer begins a frame, since it no
longer prerolls.

Issue: flutter#112232

<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

## 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.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

If this change needs to override an active code freeze, provide a
comment explaining why. The code freeze workflow can be overridden by
code reviewers. See pinned issues for any active code freezes with
guidance.

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- 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
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[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 engine flutter/engine related. See also e: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants