Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platform views are drawn at the wrong position and don't fill the parent #103630

Closed
felix-mittermeier opened this issue May 12, 2022 · 125 comments · Fixed by flutter/engine#33599
Closed
Assignees
Labels
a: platform-views Embedding Android/iOS views in Flutter apps c: regression It was better in the past than it is now customer: crowd Affects or could affect many people, though not necessarily a specific customer. found in release: 3.0 Found to occur in 3.0 found in release: 3.1 Found to occur in 3.1 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P0 Critical issues such as a build break or regression platform-android Android applications specifically

Comments

@felix-mittermeier
Copy link

felix-mittermeier commented May 12, 2022

Steps to Reproduce:

Build the example app from https://github.com/flutter-mapbox-gl/maps with Flutter 3.0.0, run it and open for example "Place symbol".
How you can see in the screenshot in flutter-mapbox-gl/maps#1041 the platform view (the map) is mispositioned and even drawn under the status bar.

Expected results:

The map gets drawn within its parent container and fills it. To see how it is supposed to look like you can run the app with any previous flutter version like 2.10.5.

Due to the fact that this issue only affect Android I assume this is related to some changes to the Android platform views which also were mentioned in the release notes on medium.com.

Logs
[✓] Flutter (Channel stable, 3.0.0, on macOS 12.3.1 21E258 darwin-arm, locale de-DE)
    • Flutter version 3.0.0 at /Users/f/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ee4e09cce0 (3 days ago), 2022-05-09 16:45:18 -0700
    • Engine revision d1b9a6938a
    • Dart version 2.17.0
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/f/Library/Android/sdk
    • Platform android-32, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.67.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.40.0

[✓] Connected device (3 available)
    • Pixel 3 XL (mobile) • 192.168.37.124:5555                      • android-arm64  • Android 12 (API 31)
    • iPhone (mobile)     • fb804538ab944b670e4061e2b3978d027625c70b • ios            • iOS 14.6 18F72
    • Chrome (web)        • chrome                                   • web-javascript • Google Chrome 101.0.4951.64

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
@huycozy huycozy added the in triage Presently being triaged by the triage team label May 13, 2022
@mkPytsNortal
Copy link

image

@huycozy
Copy link
Member

huycozy commented May 13, 2022

Hi, I can reproduce this issue with provided sample code on latest stable and master channel.
Actually, there is an un-merged patch fixes that need to be updated in the example code.

Patch fixes
  location:
    git:
      url: https://github.com/Yczar/flutterlocation.git
      path: packages/location
Demo

Screenshot_20220513-171459

flutter doctor -v
[✓] Flutter (Channel stable, 3.0.0, on macOS 12.2.1 21D62 darwin-x64, locale en-VN)
    • Flutter version 3.0.0 at /Users/huynq/Documents/GitHub/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ee4e09cce0 (2 days ago), 2022-05-09 16:45:18 -0700
    • Engine revision d1b9a6938a
    • Dart version 2.17.0
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] Android Studio (version 4.1)
    • Android Studio at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.7042882/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] Android Studio
    • Android Studio at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-1/203.7185775/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[✓] IntelliJ IDEA Community Edition (version 2020.3.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.67.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.40.0

[✓] Connected device (3 available)
    • iPhone 13 (mobile) • 5F5D609C-3B0B-4C48-872C-961928157361 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
    • macOS (desktop)    • macos                                • darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 101.0.4951.54

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
[✓] Flutter (Channel master, 3.1.0-0.0.pre.682, on macOS 12.2.1 21D62 darwin-x64, locale en-VN)
    • Flutter version 3.1.0-0.0.pre.682 at /Users/huynq/Documents/GitHub/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 6bba577bf2 (6 hours ago), 2022-05-12 21:29:07 -0400
    • Engine revision 7bde72ab75
    • Dart version 2.18.0 (build 2.18.0-109.0.dev)
    • DevTools version 2.13.1

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] Android Studio (version 4.1)
    • Android Studio at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.7042882/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[!] Android Studio
    • Android Studio at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-1/203.7185775/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] IntelliJ IDEA Community Edition (version 2020.3.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.67.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.40.0

[✓] Connected device (3 available)
    • iPhone 13 (mobile) • 5F5D609C-3B0B-4C48-872C-961928157361 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
    • macOS (desktop)    • macos                                • darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 101.0.4951.64

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.
[✓] Flutter (Channel beta, 2.13.0-0.4.pre, on macOS 12.2.1 21D62 darwin-x64, locale en-VN)
    • Flutter version 2.13.0-0.4.pre at /Users/huynq/Documents/GitHub/flutter_beta
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 25caf1461b (6 days ago), 2022-05-05 14:23:09 -0700
    • Engine revision c5caf749fe
    • Dart version 2.17.0 (build 2.17.0-266.8.beta)
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] Android Studio (version 4.1)
    • Android Studio at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.7042882/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] Android Studio
    • Android Studio at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-1/203.7185775/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[✓] IntelliJ IDEA Community Edition (version 2020.3.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.67.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.40.0

[✓] Connected device (3 available)
    • iPhone 13 (mobile) • 5F5D609C-3B0B-4C48-872C-961928157361 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
    • macOS (desktop)    • macos                                • darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 101.0.4951.54

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

@huycozy huycozy added platform-android Android applications specifically p: third party has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.0 Found to occur in 3.0 found in release: 3.1 Found to occur in 3.1 framework flutter/packages/flutter repository. See also f: labels. a: platform-views Embedding Android/iOS views in Flutter apps and removed in triage Presently being triaged by the triage team labels May 13, 2022
@deckerst
Copy link

I see the same issue with huawei_map (buggy on any Android API version), as well as google_maps_flutter (buggy on Android API <=22, but fine on API >=23).

When this happens, clipping the platform view and drawing widgets over it fails too. It's like the platform view is completely independent of the Flutter widget tree.

@littleGnAl
Copy link
Contributor

Any update on this?

@jason-simmons
Copy link
Member

@blasten

@blasten
Copy link

blasten commented May 17, 2022

@felix-mittermeier We changed how platform views are rendered by default in Flutter 3.0.0. Since the native view com.mapbox.mapboxsdk.maps.MapView uses GL directly, you would need to remove the check useHybridComposition, and replace initSurfaceAndroidView for initExpensiveAndroidView.

https://github.com/flutter-mapbox-gl/maps/blob/71c4de42ad5d8f76fa03537a305bf0498746eb15/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart#L139

  @override
  Widget buildView(
      Map<String, dynamic> creationParams,
      OnPlatformViewCreatedCallback onPlatformViewCreated,
      Set<Factory<OneSequenceGestureRecognizer>>? gestureRecognizers) {
    if (defaultTargetPlatform == TargetPlatform.android) {
-      if (useHybridComposition) {
        return PlatformViewLink(
          viewType: 'plugins.flutter.io/mapbox_gl',
          surfaceFactory: (
            BuildContext context,
            PlatformViewController controller,
          ) {
            return AndroidViewSurface(
              controller: controller as AndroidViewController,
              gestureRecognizers: gestureRecognizers ??
                  const <Factory<OneSequenceGestureRecognizer>>{},
              hitTestBehavior: PlatformViewHitTestBehavior.opaque,
            );
          },
          onCreatePlatformView: (PlatformViewCreationParams params) {
-            final SurfaceAndroidViewController controller =
+            final AndroidViewController controller =
-                PlatformViewsService.initSurfaceAndroidView(
+                PlatformViewsService.initExpensiveAndroidView(
              id: params.id,
              viewType: 'plugins.flutter.io/mapbox_gl',
              layoutDirection: TextDirection.ltr,
              creationParams: creationParams,
              creationParamsCodec: const StandardMessageCodec(),
              onFocus: () => params.onFocusChanged(true),
            );
            controller.addOnPlatformViewCreatedListener(
              params.onPlatformViewCreated,
            );
            controller.addOnPlatformViewCreatedListener(
              onPlatformViewCreated,
            );
-            controller.create();
            return controller;
          },
        );
-      } else {
-        return AndroidView(
-          viewType: 'plugins.flutter.io/mapbox_gl',
-          onPlatformViewCreated: onPlatformViewCreated,
-          gestureRecognizers: gestureRecognizers,
-          creationParams: creationParams,
-          creationParamsCodec: const StandardMessageCodec(),
-        );
-      }
    } else if (defaultTargetPlatform == TargetPlatform.iOS) {
      return UiKitView(
        viewType: 'plugins.flutter.io/mapbox_gl',
        onPlatformViewCreated: onPlatformViewCreated,
        gestureRecognizers: gestureRecognizers,
        creationParams: creationParams,
        creationParamsCodec: const StandardMessageCodec(),
      );
    }
    return Text(
        '$defaultTargetPlatform is not yet supported by the maps plugin');
  }

I also suggest to add a Flutter SDK constraint to pubspec.yaml, so the new version of the plugin requires Flutter 3.0.0 or higher.

@deckerst
Copy link

@blasten thank you for the explanation. Do you know if we can expect a fix for google_maps_flutter soon? As mentioned previously, it's buggy on API <= 22.

@littleGnAl
Copy link
Contributor

I'm not very sure whether this change will affect the performance who use Flutter SDK < 3.0 or not, should we keep the AndroidView implementation for capability?

@felix-ht
Copy link

felix-ht commented May 18, 2022

@felix-mittermeier We changed how platform views are rendered by default in Flutter 3.0.0. Since the native view com.mapbox.mapboxsdk.maps.MapView uses GL directly, you would need to remove the check useHybridComposition, and replace initSurfaceAndroidView for initExpensiveAndroidView.

@blasten What will be the consequences of this for old Flutter versions?

@rlee1990
Copy link

the packages we are using will not update until this is on stable

Can you provide links with more context on this? The fix for this issue involved disabling the new platform view path automatically for plugins that use SurfaceView, so no updates to the packages should be necessary.

One of the packages is 100ms https://pub.dev/packages/hmssdk_flutter.
I also tried with Dyte_client package https://pub.dev/packages/dyte_client.
I switched to the beta channel and ran the latest beta but the issue was still there. The video view was still showing overtop of buttons that on 2.10.5 stable does not happen.

@rlee1990
Copy link

@stuartmorgan if it helps a member from the Dyte team stated that when they tried to use the latest beta to see if the issue would be fixed they still had the issue occur.

@stuartmorgan
Copy link
Contributor

If a plugin doesn't work on beta, then a cherry-pick for this issue wouldn't help that plugin. As I said when closing the issue:

If anyone has a concrete example of this specific bug (the layering and/or positioning of a platform view being incorrect) still happening on the latest master, please provide clear repro steps, and I can re-open it.

Your last comments are the first reports we've had of any cases that weren't fixed; as far as we were aware this was fully resolved on master and beta.

Unfortunately neither of those plugins has an example that builds out of the box, which makes it hard to investigate why the fix didn't work for them. I'll file new issues, and hopefully the developers of those plugins can chime in there to help us get a reproducible test case, and we can see what changes to Flutter (for the medium term) and/or the plugins (in the short term) will ensure they aren't on the new path.

@rlee1990
Copy link

If a plugin doesn't work on beta, then a cherry-pick for this issue wouldn't help that plugin. As I said when closing the issue:

If anyone has a concrete example of this specific bug (the layering and/or positioning of a platform view being incorrect) still happening on the latest master, please provide clear repro steps, and I can re-open it.

Your last comments are the first reports we've had of any cases that weren't fixed; as far as we were aware this was fully resolved on master and beta.

Unfortunately neither of those plugins has an example that builds out of the box, which makes it hard to investigate why the fix didn't work for them. I'll file new issues, and hopefully the developers of those plugins can chime in there to help us get a reproducible test case, and we can see what changes to Flutter (for the medium term) and/or the plugins (in the short term) will ensure they aren't on the new path.

I did reach out to the developers of the Dyte plugin and they are working on getting a repo to present that shows the issue still occurring.

@stuartmorgan
Copy link
Contributor

Filed #109689 and #109690 for follow-up investigation.

@orestesgaolin
Copy link
Contributor

Your last comments are the first reports we've had of any cases that weren't fixed; as far as we were aware this was fully resolved on master and beta.

Just to confirm - if the issue occurs on beta 3.3.0-0.3.pre, but doesn't occur on master 3.1.0-0.0.pre.2296, should I just wait for the next beta version to resolve that? I'll try to showcase the issue as it's a little bit different than this exact one (it's more like Flutter view ghosting when displaying the platform view for the second time in the app lifecycle).

Once I have the repro issue, I'll try to link it here.

@stuartmorgan
Copy link
Contributor

@orestesgaolin That sounds very different; please file a new issue and CC me. It may be related to an issue that's already being cherry-picked to beta, but if not we can evaluate it for a potential cherry-pick.

@orestesgaolin
Copy link
Contributor

Thanks, just posted it in #109692

@irvine5k
Copy link

3.3.0 just hit the stable.

@000panther
Copy link

I am on 3.3.0 and it does not work for me without using the fix mentioned here, because we have written a custom integration for a clients native video player that uses Surfaces internally.

Could we please add this to the documentation? It took me 5 days of searching and trying to finally find this github issue with the awesome solution! But i think this would be awesome if it would be in the native view integration documentation. (or should i try to do it myself?)

@shilangyu
Copy link

does not work for me without using the fix mentioned here

What fix are you referring to?

@ppiatkowski-here
Copy link

I don't know what @000panther is referring to but it seems that official documentation on hosting native views in Android might be wrong. Or maybe I am doing something wrong.

https://docs.flutter.dev/development/platform-integration/android/platform-views tells us that with Hybrid Composition approach we should be using PlatformViewsService.initSurfaceAndroidView(). For me, when using Flutter 3.3 this appears to result in a crash from libEGL.so when I load the native view the second time.

Using PlatformViewsService.initExpensiveAndroidView() instead appears to be working fine.

First comment by @stuartmorgan here #107313 indicates that using initSurfaceAndroidView() actually selects what he called Texture Layer Hybrid Composition. And real Hybrid Composition is selected by using initExpensiveAndroidView which works for me but is contradicting the official documentation. That comment was written almost two months ago so things might have changed since then.

Also can someone confirm that we are indeed supposed to call create() manually when creating an android view?

@stuartmorgan
Copy link
Contributor

https://docs.flutter.dev/development/platform-integration/android/platform-views tells us that with Hybrid Composition approach we should be using PlatformViewsService.initSurfaceAndroidView().

These docs are outdated; they will be updated soon.

First comment by @stuartmorgan here #107313 indicates that using initSurfaceAndroidView() actually selects what he called Texture Layer Hybrid Composition. And real Hybrid Composition is selected by using initExpensiveAndroidView which works for me but is contradicting the official documentation.

That's correct for Flutter 3.0+, when the behavior of initSurfaceAndroidView changed from using HC to the new TLHC.

Also can someone confirm that we are indeed supposed to call create() manually when creating an android view?

Yes, that continues to be true.

@stuartmorgan
Copy link
Contributor

I am on 3.3.0 and it does not work for me without using the fix mentioned here, because we have written a custom integration for a clients native video player that uses Surfaces internally.

Please file a new issue describing the case that's not working in 3.3 so we can investigate that issue further. (Unless you are the SurfaceView dynamically post-create, in which case you can follow #109690 for updates.)

@usamawork61
Copy link

I'm facing the issue of wrong placement of platform view in v3.3.0
I'm using this library which uses a platform view.

@stuartmorgan
Copy link
Contributor

@usamawork61 Please file a new issue with a detailed description and repo steps.

@anon-000

This comment was marked as off-topic.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2022
@flutter-triage-bot flutter-triage-bot bot added P0 Critical issues such as a build break or regression and removed P2 labels Jun 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: platform-views Embedding Android/iOS views in Flutter apps c: regression It was better in the past than it is now customer: crowd Affects or could affect many people, though not necessarily a specific customer. found in release: 3.0 Found to occur in 3.0 found in release: 3.1 Found to occur in 3.1 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P0 Critical issues such as a build break or regression platform-android Android applications specifically
Projects
None yet
Development

Successfully merging a pull request may close this issue.