Skip to content

Cleaning up the Hosting native Android views page#13356

Open
sfshaza2 wants to merge 4 commits intomainfrom
modernize-android-platform-views
Open

Cleaning up the Hosting native Android views page#13356
sfshaza2 wants to merge 4 commits intomainfrom
modernize-android-platform-views

Conversation

@sfshaza2
Copy link
Copy Markdown
Contributor

@sfshaza2 sfshaza2 commented May 5, 2026

@sfshaza2 sfshaza2 requested a review from a team as a code owner May 5, 2026 20:00
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

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 updates the Android platform views documentation to include the new Hybrid Composition++ (HCPP) mode and provides a comparison matrix for different implementation strategies. The review feedback focuses on improving the clarity and technical accuracy of the documentation, specifically regarding the enablers for HCPP, the use of 'accessibility' over 'a11y', and clarifying the limitations of the Texture Layer mode concerning SurfaceViews and text magnification.

Comment thread sites/docs/src/content/platform-integration/android/platform-views.md Outdated
Comment thread sites/docs/src/content/platform-integration/android/platform-views.md Outdated
@flutter-website-bot
Copy link
Copy Markdown
Collaborator

flutter-website-bot commented May 5, 2026

Visit the preview URL for this PR (updated for commit 87267f8):

https://flutter-docs-prod--pr13356-modernize-android-platform-9reff6dv.web.app

@sfshaza2 sfshaza2 requested review from jmagman and reidbaker May 5, 2026 20:16
@reidbaker reidbaker requested review from gmackall and removed request for reidbaker May 5, 2026 20:16
allowing superior performance without the heavy costs of original hybrid
composition.

**Virtual display** (used by the texture layer mode), on the other hand,
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.

VD and TLHC are distinct modes, I don't think we should conflate them here.

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.

I have updated this section, please check it. Also, I don't know why the Performance section was created as an include, because it wasn't included anywhere else in the site. I've fixed that, too.

while platform code runs on the UI/platform thread.
This separation keeps Flutter rendering fast and fluid.

However, when a platform view is rendered on Android using **Hybrid
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.

This seems to be changing the information that was presented before. Was the prior info (that there was a change around android 10) wrong?

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.

I hope I've fixed this. Please review.

Comment thread sites/docs/src/content/platform-integration/android/platform-views.md Outdated
@sfshaza2 sfshaza2 requested a review from gmackall May 6, 2026 04:00
@sfshaza2
Copy link
Copy Markdown
Contributor Author

sfshaza2 commented May 7, 2026

@gmackall, can you check if this is ok?


| Mode | Benefits | Considerations | Enabler |
| :--- | :--- | :--- | :--- |
| **Texture layer** | • Best Flutter performance<br>• Full widget transforms work | • Janky during quick scrolling<br>• SurfaceViews lose accessibility and text magnifier breaks | Default behavior or standard `AndroidView` |
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.

I think we should weaken this to "good" flutter performance. I don't have results from benchmarking here, but abstractly based on the architecture

TLHC: PV -> Renders to Texture -> Uploads to Impeller -> Impeller composites Flutter Content & PV Content

HCPP: PV -> Renders to native android Surface, Impeller renders to native Android Surface, SurfaceFlinger composites the two together

there should be more synchronization work for TLHC to do, so I imagine HCPP would have better flutter performance (though TLHC's flutter performance is still good).

| Mode | Benefits | Considerations | Enabler |
| :--- | :--- | :--- | :--- |
| **Texture layer** | • Best Flutter performance<br>• Full widget transforms work | • Janky during quick scrolling<br>• SurfaceViews lose accessibility and text magnifier breaks | Default behavior or standard `AndroidView` |
| **Hybrid composition** | • Full native fidelity<br>• Correct accessibility and SurfaceView support | • Causes thread merging, which degrades Flutter FPS | `PlatformViewLink` with `AndroidViewSurface` |
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.

Given that flutter's thread merge of (ui and platform) threads is probably what people will think of, we should clarify here that HC's thread merge is (raster and platform)

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.

Also, on the enabler:

I think what matters here is the AndroidViewController in use. See
https://github.com/flutter/flutter/blob/master/dev/integration_tests/hybrid_android_views/lib/android_platform_view.dart
which builds either a TLHC or a HC PV by swapping them out:

      onCreatePlatformView: (PlatformViewCreationParams params) {
        print('useHybridComposition=$useHybridComposition');
        late AndroidViewController controller;
        if (useHybridComposition) {
          controller = PlatformViewsService.initExpensiveAndroidView(
            id: params.id,
            viewType: params.viewType,
            layoutDirection: TextDirection.ltr,
          );
        } else {
          controller = PlatformViewsService.initSurfaceAndroidView(
            id: params.id,
            viewType: params.viewType,
            layoutDirection: TextDirection.ltr,
          );
        }

This approach provides:

* good performance for Android Views
* best performance for Flutter rendering
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.

comment about best performance also applies here

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Developers will be confused about which Android platform view mode to use

3 participants