-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
Comments
Hi, I can reproduce this issue with provided sample code on latest Patch fixes location:
git:
url: https://github.com/Yczar/flutterlocation.git
path: packages/location 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!
|
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. |
Any update on this? |
@felix-mittermeier We changed how platform views are rendered by default in Flutter 3.0.0. Since the native view @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. |
@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. |
I'm not very sure whether this change will affect the performance who use Flutter SDK < 3.0 or not, should we keep the |
@blasten What will be the consequences of this for old Flutter versions? |
One of the packages is 100ms https://pub.dev/packages/hmssdk_flutter. |
@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. |
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:
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 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. |
Just to confirm - if the issue occurs on beta Once I have the repro issue, I'll try to link it here. |
@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. |
Thanks, just posted it in #109692 |
3.3.0 just hit the stable. |
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?) |
What fix are you referring to? |
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? |
These docs are outdated; they will be updated soon.
That's correct for Flutter 3.0+, when the behavior of
Yes, that continues to be true. |
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 |
I'm facing the issue of wrong placement of platform view in |
@usamawork61 Please file a new issue with a detailed description and repo steps. |
This comment was marked as off-topic.
This comment was marked as off-topic.
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 |
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
The text was updated successfully, but these errors were encountered: