Cleaning up the Hosting native Android views page#13356
Cleaning up the Hosting native Android views page#13356
Conversation
There was a problem hiding this comment.
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.
|
Visit the preview URL for this PR (updated for commit 87267f8): https://flutter-docs-prod--pr13356-modernize-android-platform-9reff6dv.web.app |
| allowing superior performance without the heavy costs of original hybrid | ||
| composition. | ||
|
|
||
| **Virtual display** (used by the texture layer mode), on the other hand, |
There was a problem hiding this comment.
VD and TLHC are distinct modes, I don't think we should conflate them here.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
This seems to be changing the information that was presented before. Was the prior info (that there was a change around android 10) wrong?
There was a problem hiding this comment.
I hope I've fixed this. Please review.
|
@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` | |
There was a problem hiding this comment.
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` | |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
comment about best performance also applies here
Fixes #13355
Affected page staged here: https://flutter-docs-prod--pr13356-modernize-android-platform-9reff6dv.web.app/platform-integration/android/platform-views