flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.15k stars 27.23k forks source link

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

Closed felix-mittermeier closed 2 years ago

felix-mittermeier commented 2 years ago

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 https://github.com/flutter-mapbox-gl/maps/issues/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! ```
mkPytsNortal commented 2 years ago

image

huycozy commented 2 years ago

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 ```yaml location: git: url: https://github.com/Yczar/flutterlocation.git path: packages/location ```
Demo ![Screenshot_20220513-171459](https://user-images.githubusercontent.com/104349824/168264518-69aa59eb-99a0-4270-8c64-b9e4855f1475.png)
flutter doctor -v ```bash [✓] 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! ``` ```bash [✓] 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. ``` ```bash [✓] 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! ```
deckerst commented 2 years ago

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 commented 2 years ago

Any update on this?

jason-simmons commented 2 years ago

@blasten

blasten commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

@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?

felix-mittermeier commented 2 years ago

@blasten Thanks for your response but I am not sure your suggested changes are the solution to this issue. I tried it out and tested it but now the app crashes instantly as soon as the platform view is visible.

Click this to show crash log ``` Launching lib/main.dart on Pixel 3 XL in debug mode... W/TelemetryUtils( 3225): java.lang.SecurityException: getDataNetworkTypeForSubscriber V/Mbgl-ConnectivityReceiver( 3225): connected - true I/Mbgl-EGLConfigChooser( 3225): In emulator: false W/Mbgl ( 3225): {GLThread 4356}[Android]: MapRenderer::onSurfaceCreated GlyphsRasterizationMode was specified without providing LocalIdeographFontFamily. Switching glyphsRasterizationMode to NoGlyphsRasterizedLocally mode. I/Mbgl ( 3225): {GLThread 4356}[General]: GPU Identifier: Adreno (TM) 630 E/flutter ( 3225): [ERROR:flutter/fml/platform/android/jni_util.cc(204)] java.lang.IllegalStateException: Platform view hasn't been initialized from the platform view channel. E/flutter ( 3225): at io.flutter.plugin.platform.PlatformViewsController.initializePlatformViewIfNeeded(PlatformViewsController.java:732) E/flutter ( 3225): at io.flutter.plugin.platform.PlatformViewsController.onDisplayPlatformView(PlatformViewsController.java:791) E/flutter ( 3225): at io.flutter.embedding.engine.FlutterJNI.onDisplayPlatformView(FlutterJNI.java:1380) E/flutter ( 3225): at android.os.MessageQueue.nativePollOnce(Native Method) E/flutter ( 3225): at android.os.MessageQueue.next(MessageQueue.java:335) E/flutter ( 3225): at android.os.Looper.loopOnce(Looper.java:161) E/flutter ( 3225): at android.os.Looper.loop(Looper.java:288) E/flutter ( 3225): at android.app.ActivityThread.main(ActivityThread.java:7842) E/flutter ( 3225): at java.lang.reflect.Method.invoke(Native Method) E/flutter ( 3225): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) E/flutter ( 3225): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) E/flutter ( 3225): F/flutter ( 3225): [FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1469)] Check failed: fml::jni::CheckException(env). F/libc ( 3225): Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 3225 (.dynamic_forest), pid 3225 (.dynamic_forest) *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** Build fingerprint: 'google/crosshatch/crosshatch:12/SP1A.210812.016.C1/8029091:user/release-keys' Revision: 'MP1.0' ABI: 'arm64' Timestamp: 2022-05-18 11:21:51.450777354+0200 Process uptime: 0s Cmdline: io.ocell.dynamic_forest pid: 3225, tid: 3225, name: .dynamic_forest >>> io.ocell.dynamic_forest <<< uid: 11210 signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr -------- Abort message: '[FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1469)] Check failed: fml::jni::CheckException(env). ' x0 0000000000000000 x1 0000000000000c99 x2 0000000000000006 x3 0000007fd2d46b00 x4 6d602e6c716e6573 x5 6d602e6c716e6573 x6 6d602e6c716e6573 x7 7f7f7f7f7f7f7f7f x8 00000000000000f0 x9 9fc9e2991523aa9a x10 0000000000000000 x11 ffffff80fffffbdf x12 0000000000000001 x13 000000000000007e x14 0000007fd2d459b0 x15 00123e205a248c91 x16 00000077e38f5050 x17 00000077e38d1eb0 x18 00000077f98d6000 x19 0000000000000c99 x20 0000000000000c99 x21 00000000ffffffff x22 000000759d9687b8 x23 000000000000016f x24 00000075fd9521f0 x25 0000000000000000 x26 0000000000000001 x27 0000000000000081 x28 0000007fd2d46e08 x29 0000007fd2d46b80 lr 00000077e3884ba0 sp 0000007fd2d46ae0 pc 00000077e3884bcc pst 0000000000000000 backtrace: #00 pc 000000000004fbcc /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: ba489d4985c0cf173209da67405662f9) #01 pc 000000000156fbcc /data/app/~~m4ZHsB0JPtFepCvXDqUD3A==/io.ocell.dynamic_forest-bCjpySnabOAOsgSNibVTsA==/lib/arm64/libflutter.so (BuildId: ebe4d2530023f7fca8a3bc8baa9e8063ba160e75) #02 pc 00000000015947b4 /data/app/~~m4ZHsB0JPtFepCvXDqUD3A==/io.ocell.dynamic_forest-bCjpySnabOAOsgSNibVTsA==/lib/arm64/libflutter.so (BuildId: ebe4d2530023f7fca8a3bc8baa9e8063ba160e75) #03 pc 000000000157ba18 /data/app/~~m4ZHsB0JPtFepCvXDqUD3A==/io.ocell.dynamic_forest-bCjpySnabOAOsgSNibVTsA==/lib/arm64/libflutter.so (BuildId: ebe4d2530023f7fca8a3bc8baa9e8063ba160e75) #04 pc 0000000001c6c210 /data/app/~~m4ZHsB0JPtFepCvXDqUD3A==/io.ocell.dynamic_forest-bCjpySnabOAOsgSNibVTsA==/lib/arm64/libflutter.so (BuildId: ebe4d2530023f7fca8a3bc8baa9e8063ba160e75) #05 pc 00000000018bd894 /data/app/~~m4ZHsB0JPtFepCvXDqUD3A==/io.ocell.dynamic_forest-bCjpySnabOAOsgSNibVTsA==/lib/arm64/libflutter.so (BuildId: ebe4d2530023f7fca8a3bc8baa9e8063ba160e75) #06 pc 00000000018bc4c8 /data/app/~~m4ZHsB0JPtFepCvXDqUD3A==/io.ocell.dynamic_forest-bCjpySnabOAOsgSNibVTsA==/lib/arm64/libflutter.so (BuildId: ebe4d2530023f7fca8a3bc8baa9e8063ba160e75) #07 pc 00000000018bcfb8 /data/app/~~m4ZHsB0JPtFepCvXDqUD3A==/io.ocell.dynamic_forest-bCjpySnabOAOsgSNibVTsA==/lib/arm64/libflutter.so (BuildId: ebe4d2530023f7fca8a3bc8baa9e8063ba160e75) #08 pc 00000000018bdddc /data/app/~~m4ZHsB0JPtFepCvXDqUD3A==/io.ocell.dynamic_forest-bCjpySnabOAOsgSNibVTsA==/lib/arm64/libflutter.so (BuildId: ebe4d2530023f7fca8a3bc8baa9e8063ba160e75) #09 pc 00000000018bc90c /data/app/~~m4ZHsB0JPtFepCvXDqUD3A==/io.ocell.dynamic_forest-bCjpySnabOAOsgSNibVTsA==/lib/arm64/libflutter.so (BuildId: ebe4d2530023f7fca8a3bc8baa9e8063ba160e75) #10 pc 00000000018bc664 /data/app/~~m4ZHsB0JPtFepCvXDqUD3A==/io.ocell.dynamic_forest-bCjpySnabOAOsgSNibVTsA==/lib/arm64/libflutter.so (BuildId: ebe4d2530023f7fca8a3bc8baa9e8063ba160e75) #11 pc 00000000018c8cac /data/app/~~m4ZHsB0JPtFepCvXDqUD3A==/io.ocell.dynamic_forest-bCjpySnabOAOsgSNibVTsA==/lib/arm64/libflutter.so (BuildId: ebe4d2530023f7fca8a3bc8baa9e8063ba160e75) #12 pc 00000000015954b0 /data/app/~~m4ZHsB0JPtFepCvXDqUD3A==/io.ocell.dynamic_forest-bCjpySnabOAOsgSNibVTsA==/lib/arm64/libflutter.so (BuildId: ebe4d2530023f7fca8a3bc8baa9e8063ba160e75) #13 pc 000000000159ad58 /data/app/~~m4ZHsB0JPtFepCvXDqUD3A==/io.ocell.dynamic_forest-bCjpySnabOAOsgSNibVTsA==/lib/arm64/libflutter.so (BuildId: ebe4d2530023f7fca8a3bc8baa9e8063ba160e75) #14 pc 000000000001691c /system/lib64/libutils.so (android::Looper::pollInner(int)+912) (BuildId: a3acb0eba7fd91ea48db6f0befa41c65) #15 pc 0000000000016524 /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+112) (BuildId: a3acb0eba7fd91ea48db6f0befa41c65) #16 pc 000000000014acf8 /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int)+44) (BuildId: f21e19bfa4e5c3afad804a71681c9fca) #17 pc 00000000001cf22c /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (art_jni_trampoline+108) #18 pc 000000000200ffbc /memfd:jit-cache (deleted) (android.os.MessageQueue.next+204) #19 pc 00000000002ca764 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #20 pc 00000000002ee6b0 /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+312) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #21 pc 000000000040ade4 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+820) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #22 pc 00000000002c0ea4 /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+5380) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #23 pc 00000000002c4e94 /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #24 pc 000000000044cc10 /system/framework/framework.jar #25 pc 000000000076ce1c /apex/com.android.art/lib64/libart.so (MterpInvokeStatic+2120) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #26 pc 00000000002c5014 /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #27 pc 000000000044d394 /system/framework/framework.jar #28 pc 000000000076c840 /apex/com.android.art/lib64/libart.so (MterpInvokeStatic+620) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #29 pc 00000000002c5014 /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #30 pc 00000000001c8542 /system/framework/framework.jar #31 pc 000000000027d840 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.3351068054637636664)+644) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #32 pc 000000000027c9e8 /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+1176) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #33 pc 00000000002d4178 /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #34 pc 00000000002ca9e8 /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #35 pc 000000000035b5d0 /apex/com.android.art/lib64/libart.so (_jobject* art::InvokeMethod<(art::PointerSize)8>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long)+608) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #36 pc 000000000035b348 /apex/com.android.art/lib64/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*)+52) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #37 pc 00000000000b2f74 /apex/com.android.art/javalib/arm64/boot.oat (art_jni_trampoline+132) (BuildId: ad9ee401645a5135206a62ff86fc2ef5cdc29120) #38 pc 00000000002ca764 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #39 pc 00000000002ee6b0 /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+312) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #40 pc 000000000040ade4 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+820) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #41 pc 00000000002c0ea4 /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+5380) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #42 pc 00000000002c4e94 /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #43 pc 0000000000247596 /system/framework/framework.jar #44 pc 000000000027d840 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.3351068054637636664)+644) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #45 pc 000000000027c9e8 /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+1176) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #46 pc 00000000002d4178 /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #47 pc 00000000008598c8 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (com.android.internal.os.ZygoteInit.main+2232) #48 pc 00000000002ca9e8 /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #49 pc 000000000044ca04 /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+464) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #50 pc 000000000062cf30 /apex/com.android.art/lib64/libart.so (art::JNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+268) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #51 pc 00000000000aeac4 /system/lib64/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+120) (BuildId: f21e19bfa4e5c3afad804a71681c9fca) #52 pc 00000000000ba05c /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector const&, bool)+836) (BuildId: f21e19bfa4e5c3afad804a71681c9fca) #53 pc 000000000000258c /system/bin/app_process64 (main+1336) (BuildId: 4ecb2c57d6667e4a94a73568ce392d22) #54 pc 00000000000488c8 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+96) (BuildId: ba489d4985c0cf173209da67405662f9) Lost connection to device. Exited ```

Physcial test device was the Google Pixel 3 XL running on Android 12.

mkPytsNortal commented 2 years ago

@blasten thanks, seems like that works for us with custom map view for Android

littleGnAl commented 2 years ago

@blasten Thanks for your response but I am not sure your suggested changes are the solution to this issue. I tried it out and tested it but now the app crashes instantly as soon as the platform view is visible.

Click this to show crash log Physcial test device was the Google Pixel 3 XL running on Android 12.

I face this crash too, I think this issue should be reopened. @felix-mittermeier

blasten commented 2 years ago

@felix-mittermeier Thanks for the report. We missed a commit in the stable branch. I just filed a request to cherry pick the required commit. Could you confirm that this change works on the master channel?

blasten commented 2 years ago

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?

@littleGnAl No, it doesn't. The affected plugin would need to add a Flutter SDK constraint, so pub resolves to the right version of the plugin depending on the version of Flutter that is used. https://dart.dev/tools/pub/pubspec#flutter-sdk-constraints

littleGnAl commented 2 years ago

@felix-mittermeier Thanks for the report. We missed a commit in the stable branch. I just filed a request to cherry pick the required commit. Could you confirm that this change works on the master channel?

@blasten Thanks for the reply, it works fine on the master channel for my case.

littleGnAl commented 2 years ago

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?

@littleGnAl No, it doesn't. The affected plugin would need to add a Flutter SDK constraint, so pub resolves to the right version of the plugin depending on the version of Flutter that is used. https://dart.dev/tools/pub/pubspec#flutter-sdk-constraints

@blasten How can I compatible it without adding the Flutter SDK constraint? Our plugin supported the Flutter SDK >= 2.0, I'm not very willing to increase the minimal support for this change.

felix-mittermeier commented 2 years ago

@felix-mittermeier Thanks for the report. We missed a commit in the stable branch. I just filed a request to cherry pick the required commit. Could you confirm that this change works on the master channel?

@blasten Thanks for your answer. I tried it out switching to the master branch and the app still crashes immediately due to some native code but the message changed. The one I posted above is gone now but now we get this instead:

Click this to show crash log ``` Launching lib/main.dart on Pixel 3 XL in debug mode... ✓ Built build/app/outputs/flutter-apk/app-debug.apk. I/Mbgl-EGLConfigChooser(15612): In emulator: false W/Mbgl (15612): {GLThread 4569}[Android]: MapRenderer::onSurfaceCreated GlyphsRasterizationMode was specified without providing LocalIdeographFontFamily. Switching glyphsRasterizationMode to NoGlyphsRasterizedLocally mode. I/Mbgl (15612): {GLThread 4569}[General]: GPU Identifier: Adreno (TM) 630 E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): Failed to handle method call E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): com.mapbox.mapboxsdk.style.sources.CannotAddSourceException: Source already exists E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at com.mapbox.mapboxsdk.maps.NativeMapView.nativeAddSource(Native Method) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at com.mapbox.mapboxsdk.maps.NativeMapView.addSource(NativeMapView.java:937) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at com.mapbox.mapboxsdk.maps.Style.addSource(Style.java:119) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at com.mapbox.mapboxgl.MapboxMapController.addGeoJsonSource(MapboxMapController.java:357) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at com.mapbox.mapboxgl.MapboxMapController.onMethodCall(MapboxMapController.java:817) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at android.os.Handler.handleCallback(Handler.java:938) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at android.os.Handler.dispatchMessage(Handler.java:99) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at android.os.Looper.loopOnce(Looper.java:201) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at android.os.Looper.loop(Looper.java:288) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at android.app.ActivityThread.main(ActivityThread.java:7842) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) E/MethodChannel#plugins.flutter.io/mapbox_maps_1(15612): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) F/libc (15612): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 15612 (.dynamic_forest), pid 15612 (.dynamic_forest) *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** Build fingerprint: 'google/crosshatch/crosshatch:12/SP1A.210812.016.C1/8029091:user/release-keys' Revision: 'MP1.0' ABI: 'arm64' Timestamp: 2022-05-19 10:38:17.022000577+0200 Process uptime: 0s Cmdline: io.ocell.dynamic_forest pid: 15612, tid: 15612, name: .dynamic_forest >>> io.ocell.dynamic_forest <<< uid: 11216 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 Cause: null pointer dereference x0 0000000000000000 x1 000000760d949810 x2 0000000000000000 x3 000000753a0a573c x4 0000007fd2d474f8 x5 00000074c7c559bf x6 656d617246676e69 x7 0000007fd2d473a8 x8 9fc9e2991523aa9a x9 9fc9e2991523aa9a x10 000000000000002b x11 000000753a586630 x12 0000000000000021 x13 000000008d1a6dc0 x14 0000000000000002 x15 0000000000000003 x16 0000007479d7c3a0 x17 00000077e38e7bd8 x18 00000077f98d6000 x19 000000758d9c6430 x20 000000756da08710 x21 00000077f865a000 x22 00000075eda37838 x23 00000075eda378a4 x24 00000077f865a000 x25 0000000000000000 x26 0000007479d84968 x27 0000007479d84960 x28 0000007479d84980 x29 0000007fd2d47640 lr 0000007479933ed8 sp 0000007fd2d475c0 pc 0000007479956bac pst 0000000060000000 backtrace: #00 pc 000000000010ebac /data/app/~~tIJIOmZe9EfpGN8LsvSV_w==/io.ocell.dynamic_forest-ocyAEH4GbZdaJwPUsWAKoA==/lib/arm64/libmapbox-gl.so (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7) #01 pc 00000000000ebed4 /data/app/~~tIJIOmZe9EfpGN8LsvSV_w==/io.ocell.dynamic_forest-ocyAEH4GbZdaJwPUsWAKoA==/lib/arm64/libmapbox-gl.so (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7) #02 pc 00000000000ec48c /data/app/~~tIJIOmZe9EfpGN8LsvSV_w==/io.ocell.dynamic_forest-ocyAEH4GbZdaJwPUsWAKoA==/lib/arm64/libmapbox-gl.so (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7) #03 pc 00000000000fb3e0 /data/app/~~tIJIOmZe9EfpGN8LsvSV_w==/io.ocell.dynamic_forest-ocyAEH4GbZdaJwPUsWAKoA==/lib/arm64/libmapbox-gl.so (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7) #04 pc 000000000021b0c4 /data/app/~~tIJIOmZe9EfpGN8LsvSV_w==/io.ocell.dynamic_forest-ocyAEH4GbZdaJwPUsWAKoA==/lib/arm64/libmapbox-gl.so (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7) #05 pc 000000000021a930 /data/app/~~tIJIOmZe9EfpGN8LsvSV_w==/io.ocell.dynamic_forest-ocyAEH4GbZdaJwPUsWAKoA==/lib/arm64/libmapbox-gl.so (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7) #06 pc 000000000021a9fc /data/app/~~tIJIOmZe9EfpGN8LsvSV_w==/io.ocell.dynamic_forest-ocyAEH4GbZdaJwPUsWAKoA==/lib/arm64/libmapbox-gl.so (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7) #07 pc 0000000000219c24 /data/app/~~tIJIOmZe9EfpGN8LsvSV_w==/io.ocell.dynamic_forest-ocyAEH4GbZdaJwPUsWAKoA==/lib/arm64/libmapbox-gl.so (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7) #08 pc 000000000001691c /system/lib64/libutils.so (android::Looper::pollInner(int)+912) (BuildId: a3acb0eba7fd91ea48db6f0befa41c65) #09 pc 0000000000016524 /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+112) (BuildId: a3acb0eba7fd91ea48db6f0befa41c65) #10 pc 000000000014acf8 /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int)+44) (BuildId: f21e19bfa4e5c3afad804a71681c9fca) #11 pc 00000000001cf22c /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (art_jni_trampoline+108) #12 pc 000000000200dfac /memfd:jit-cache (deleted) (android.os.MessageQueue.next+204) #13 pc 00000000020290c8 /memfd:jit-cache (deleted) (android.os.Looper.loopOnce+168) #14 pc 00000000002ca9e8 /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #15 pc 00000000002ee6b8 /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+320) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #16 pc 000000000040ade4 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+820) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #17 pc 000000000076d4b8 /apex/com.android.art/lib64/libart.so (MterpInvokeStatic+3812) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #18 pc 00000000002c5014 /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #19 pc 000000000044d394 /system/framework/framework.jar #20 pc 000000000076c840 /apex/com.android.art/lib64/libart.so (MterpInvokeStatic+620) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #21 pc 00000000002c5014 /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #22 pc 00000000001c8542 /system/framework/framework.jar #23 pc 000000000027d840 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.3351068054637636664)+644) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #24 pc 000000000027c9e8 /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+1176) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #25 pc 00000000002d4178 /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #26 pc 00000000002ca9e8 /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #27 pc 000000000035b5d0 /apex/com.android.art/lib64/libart.so (_jobject* art::InvokeMethod<(art::PointerSize)8>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long)+608) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #28 pc 000000000035b348 /apex/com.android.art/lib64/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*)+52) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #29 pc 00000000000b2f74 /apex/com.android.art/javalib/arm64/boot.oat (art_jni_trampoline+132) (BuildId: ad9ee401645a5135206a62ff86fc2ef5cdc29120) #30 pc 00000000002ca764 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #31 pc 00000000002ee6b0 /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+312) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #32 pc 000000000040ade4 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+820) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #33 pc 00000000002c0ea4 /apex/com.android.art/lib64/libart.so (MterpInvokeVirtual+5380) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #34 pc 00000000002c4e94 /apex/com.android.art/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #35 pc 0000000000247596 /system/framework/framework.jar #36 pc 000000000027d840 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.3351068054637636664)+644) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #37 pc 000000000027c9e8 /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+1176) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #38 pc 00000000002d4178 /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #39 pc 00000000008598c8 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (com.android.internal.os.ZygoteInit.main+2232) #40 pc 00000000002ca9e8 /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #41 pc 000000000044ca04 /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+464) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #42 pc 000000000062cf30 /apex/com.android.art/lib64/libart.so (art::JNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+268) (BuildId: 34e3dd028e2e682b63a512d6a4f1b5eb) #43 pc 00000000000aeac4 /system/lib64/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+120) (BuildId: f21e19bfa4e5c3afad804a71681c9fca) #44 pc 00000000000ba05c /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector const&, bool)+836) (BuildId: f21e19bfa4e5c3afad804a71681c9fca) #45 pc 000000000000258c /system/bin/app_process64 (main+1336) (BuildId: 4ecb2c57d6667e4a94a73568ce392d22) #46 pc 00000000000488c8 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+96) (BuildId: ba489d4985c0cf173209da67405662f9) Lost connection to device. Exited ```

Edit: But this looks more MapBox related now because the onStyleLoadedCallback got called twice. We are not sure yet if this is some kind of MapBox issue or if the platform view get initialized twice for some reasons now. Will further investigate on this but cherry picking the one commit you mentioned into stable would definitely fix the first issue 👍🏻

blasten commented 2 years ago

But this looks more MapBox related now because the onStyleLoadedCallback got called twice.

@felix-mittermeier - I verified this behavior, and it wasn't intended. I was able to fix the issue by removing the create() call. Please see the updated patch: https://github.com/flutter/flutter/issues/103630#issuecomment-1129224567

On a side note, MapBox appears to be using Android's SurfaceView. Is there any way that MapBox can use Android's TextureView? TextureView allows you to use the fast path in the Flutter engine, so it improves performance, and fixes this issue too.

apkuhar commented 2 years ago

Even the Virtual Display method is broken in 3.0.1. I'm using AndroidView to show the camera preview. and after updating to 3.0.1, On Android 10: i can't round the corners on the native view anymore and cant render any content on top of it. On Android 7: i get an empty gray view.

AAverin commented 2 years ago

@blasten Debugging Mapbox, it looks like PlatformViewCreatedCallback is triggered twice by Flutter, using latest Flutter master.

littleGnAl commented 2 years ago

Even the Virtual Display method is broken in 3.0.1. I'm using AndroidView to show the camera preview. and after updating to 3.0.1, On Android 10: i can't round the corners on the native view anymore and cant render any content on top of it. On Android 7: i get an empty gray view.

@apkuhar On Android 7, I think you should set the setZOrderOnTop or setZOrderMediaOverlay for the SurfaceView

apkuhar commented 2 years ago

I took @blasten recommendation with initExpensiveAndroidView. Visually it worked like AndroidView in Flutter 2.10. I could clip it to round the corners, I could overlay over it. But the performance is much worse than AndroidView in Flutter 2.10.

Edit: Kind of sad, because same app on iOS using Flutter 3.0 is great.

AAverin commented 2 years ago

Any update on this major issue? Mapbox maps are now basically unusable due to PlatformViewCreatedCallback is triggered twice by Flutter, resulting in all the logic running twice and breaking the map.

AAverin commented 2 years ago

Applying all the suggested fixes, there are big performance issues and still some problems with native view overlapping everything on Android

felix-mittermeier commented 2 years ago

Applying all the suggested fixes, there are big performance issues and still some problems with native view overlapping everything on Android

Oh dear, that does not sound very satisfying and makes the impression there is no quick fix for it :/ But thanks a lot for testing it again with the mentioned change.

AAverin commented 2 years ago

I have tried to do a fix for Mapbox in this PR: https://github.com/flutter-mapbox-gl/maps/pull/1059 Even applying all the suggestions, there is still an issue with native view displayed on top of everything when navigating to another screen and a new native NPE that was not present there before.

blasten commented 2 years ago

there is still an issue with native view displayed on top of everything when navigating to another screen and a new native NPE that was not present there before.

@AAverin I was looking at https://github.com/flutter-mapbox-gl/maps/pull/1059, but I didn't see the steps to repro. Let me know how to reproduce the issue. I'm looking at this issue to see what can be done to improve performance.

AAverin commented 2 years ago

@blasten Is there some kind of minimal example of a platform plugin I can play with to reproduce the problem?

benneca commented 2 years ago

so does this affect all uses of Android's SurfaceView? I have this issue when using the adv_camera plugin as well and it also uses a surface view. I can correct the issue when switching the AndroidView to a PlatformViewLink with AndroidViewSurface (like the example above), provided I switch to the master channel. However, I still have the same issue on stable even with the PlatformViewLink. @blasten you mentioned something about cherry-picking, will this resolve the issue only when switching to the PlatformViewLink with AndroidViewSurface (like the provided example) or will this cherry-picking work with the AndroidView. Or is this ultimately an issue with Androids' SurfaceView not being compatible with clipping?

p-shapovalov commented 2 years ago

so does this affect all uses of Android's SurfaceView?

I'm afraid so. In my custom plugin platform view with AR shows on top of Stack widget and overlap other widgets - same as in several linked issues above. Surprisingly it also add periodic freezes for ios version. I'm afraid for now there is no way to upgrade to 3.0 if there is a PlatformView somewhere in project

felix-mittermeier commented 2 years ago

Would be quite a drastic step but maybe it would make sense to revert all the changes made in the flutter framework related to platform views (to the state in 2.10.5). If it is way more buggy now and the performance is worse I don't see the advantages of these changes currently. Feel free to correct me if I am wrong but that is just my feeling.

Ahmadre commented 2 years ago

My whole Flutter UI is hidden behind my PlatformView on Android.

I cannot use Flutter 3.* because of this Regression-Error....

blasten commented 2 years ago

@felix-mittermeier I'm looking at this issue. I think it's possible to do a soft-revert for SurfaceView. At the moment, I'm working on improving the tests, so this regression don't happen in the future.

sirmamedical commented 2 years ago

Would be quite a drastic step but maybe it would make sense to revert all the changes made in the flutter framework related to platform views (to the state in 2.10.5). If it is way more buggy now and the performance is worse I don't see the advantages of these changes currently. Feel free to correct me if I am wrong but that is just my feeling.

I believe this is the right step. Nothing related to the platform views works properly now. And because there are other breaking changes, staying with the 2.10.5 is not an option because the newer versions of the most of the plugins are incompatible with the previous Flutter version. Please do a hotfix and revert it to the previous state.

blasten commented 2 years ago

https://github.com/flutter/engine/pull/33599 will fix this issue

blasten commented 2 years ago

This screen recording was taken after applying https://github.com/flutter/engine/pull/33599 to the mapbox GL example app on the master branch.

https://user-images.githubusercontent.com/1410613/170386680-fc230915-930c-49af-81cb-b9eaef62d315.mp4

The only issue I saw is this fatal exception from the mapboxsdk. It does not seem related to platform views. Has anyone seen this issue before?

Click this to show crash log ``` F/libc (25495): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 25632 (GLThread 254), pid 25495 (mapboxglexample) *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** Build fingerprint: 'google/flame/flame:Tiramisu/TPB1.220310.029/8473704:user/release-keys' Revision: 'MP1.0' ABI: 'arm' Timestamp: 2022-05-25 16:22:45.617607995-0700 Process uptime: 18s Cmdline: com.mapbox.mapboxglexample pid: 25495, tid: 25632, name: GLThread 254 >>> com.mapbox.mapboxglexample <<< uid: 10299 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x00000000 Cause: null pointer dereference r0 00000000 r1 00000000 r2 00000001 r3 00000001 r4 acbfbaf4 r5 00000001 r6 00000000 r7 acbfbac0 r8 aaf04bb0 r9 e4e68410 r10 acbfbb30 r11 e4e68410 ip adac9e6c sp acbfbab8 lr ad80ed73 pc ad80ee32 backtrace: #00 pc 000c8e32 /data/app/~~uu3-m86ZITO9JvHcdD7AVA==/com.mapbox.mapboxglexample-48vzTxXfLB774zGzCHYgnw==/lib/arm/libmapbox-gl.so (BuildId: f97e0b40d4f1a81499746c3e5528d8d1b15d08af) #01 pc 000c8d6f /data/app/~~uu3-m86ZITO9JvHcdD7AVA==/com.mapbox.mapboxglexample-48vzTxXfLB774zGzCHYgnw==/lib/arm/libmapbox-gl.so (BuildId: f97e0b40d4f1a81499746c3e5528d8d1b15d08af) #02 pc 0006a765 /data/app/~~uu3-m86ZITO9JvHcdD7AVA==/com.mapbox.mapboxglexample-48vzTxXfLB774zGzCHYgnw==/lib/arm/libmapbox-gl.so (BuildId: f97e0b40d4f1a81499746c3e5528d8d1b15d08af) #03 pc 0038379d /apex/com.android.art/lib/libart.so (art_quick_generic_jni_trampoline+44) (BuildId: e9040b3c0072ef9b4d50ad70c6617763) #04 pc 000e9dec /apex/com.android.art/lib/libart.so (nterp_helper+2908) (BuildId: e9040b3c0072ef9b4d50ad70c6617763) #05 pc 00428f90 [anon:dalvik-classes2.dex extracted in memory from /data/app/~~uu3-m86ZITO9JvHcdD7AVA==/com.mapbox.mapboxglexample-48vzTxXfLB774zGzCHYgnw==/base.apk!classes2.dex] (com.mapbox.mapboxsdk.maps.renderer.MapRenderer.onDrawFrame+12) #06 pc 000e9d80 /apex/com.android.art/lib/libart.so (nterp_helper+2800) (BuildId: e9040b3c0072ef9b4d50ad70c6617763) #07 pc 0042ac70 [anon:dalvik-classes2.dex extracted in memory from /data/app/~~uu3-m86ZITO9JvHcdD7AVA==/com.mapbox.mapboxglexample-48vzTxXfLB774zGzCHYgnw==/base.apk!classes2.dex] (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer.onDrawFrame+0) #08 pc 000ea7e8 /apex/com.android.art/lib/libart.so (nterp_helper+5464) (BuildId: e9040b3c0072ef9b4d50ad70c6617763) #09 pc 0042b6e6 [anon:dalvik-classes2.dex extracted in memory from /data/app/~~uu3-m86ZITO9JvHcdD7AVA==/com.mapbox.mapboxglexample-48vzTxXfLB774zGzCHYgnw==/base.apk!classes2.dex] (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView$GLThread.guardedRun+994) #10 pc 000e9d80 /apex/com.android.art/lib/libart.so (nterp_helper+2800) (BuildId: e9040b3c0072ef9b4d50ad70c6617763) #11 pc 0042bc7c [anon:dalvik-classes2.dex extracted in memory from /data/app/~~uu3-m86ZITO9JvHcdD7AVA==/com.mapbox.mapboxglexample-48vzTxXfLB774zGzCHYgnw==/base.apk!classes2.dex] (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView$GLThread.run+48) #12 pc 0037edd5 /apex/com.android.art/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: e9040b3c0072ef9b4d50ad70c6617763) #13 pc 0037e945 /apex/com.android.art/lib/libart.so (void art::quick_invoke_reg_setup(art::ArtMethod*, unsigned int*, unsigned int, art::Thread*, art::JValue*, char const*) (.__uniq.192663596067446536341070919852553954320.llvm.1381966300580141391)+284) (BuildId: e9040b3c0072ef9b4d50ad70c6617763) #14 pc 002867d9 /apex/com.android.art/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+216) (BuildId: e9040b3c0072ef9b4d50ad70c6617763) #15 pc 004ac495 /apex/com.android.art/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*) (.__uniq.245181933781456475607640333933569312899.llvm.15212775879371097399)+40) (BuildId: e9040b3c0072ef9b4d50ad70c6617763) #16 pc 00330a61 /apex/com.android.art/lib/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*)+172) (BuildId: e9040b3c0072ef9b4d50ad70c6617763) #17 pc 003433b7 /apex/com.android.art/lib/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue const*)+42) (BuildId: e9040b3c0072ef9b4d50ad70c6617763) #18 pc 002d6e31 /apex/com.android.art/lib/libart.so (art::Thread::CreateCallback(void*)+1876) (BuildId: e9040b3c0072ef9b4d50ad70c6617763) #19 pc 000837bb /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+40) (BuildId: b0a867c5a658a10f1947a2f3e225b730) #20 pc 0003a64d /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30) (BuildId: b0a867c5a658a10f1947a2f3e225b730) ```

I used a device running Android 13 (T).

AAverin commented 2 years ago

@blasten I will be happy to test once the fix is merged to master.

The exception also started with Flutter 3.0 and I don't yet know what is causing it exactly. It is an NPE and nothing changed in the way mapbox was integrated in the recent updates.

vitable-dev commented 2 years ago

Are there any updates on this? Would it be possible to create a separate branch of flutter and merge https://github.com/flutter/engine/pull/33599 so we who don't build for Linux can be unblocked?

vitable-dev commented 2 years ago

Any updates on this?

sirmamedical commented 2 years ago

This is a breaking bug for many applications, because it completely breaks the UI. Please, make applying the fix top priority, it is not just a P4!!!

farabisameer commented 2 years ago

this is causing major issues on our apps! Can you please prioritize this fix! Thanks!!

c0dezli commented 2 years ago

Please this is a P1 breaking bug, we need a fix for this asap

felix-mittermeier commented 2 years ago

@sirmamedical @farabisameer @C0deZLee While I agree with you that it is important of course, it has to be said that Flutter has a strict priority system. Comments like "P1 breaking bug" are therefore not useful at all IMO because P0/P1 are only bugs that prevent the whole Flutter tool from building. So in other words "ultra urgent for ALL Flutter developers" - but if you are not using platform views in your app, you won't even notice this issue.

As written here: https://github.com/flutter/flutter/wiki/Issue-hygiene

P3 is the highest priority a bug can normally have.

So this bug could be promoted to P3 (which probably also would make sense according to the count of thumbs) but that's it. I read this kind of comments so often but there is a clear system for priorities and I think this has to be respected instead of questioned over and over.

Here is the overview:

Bildschirmfoto 2022-05-31 um 17 21 37
penhorwood commented 2 years ago

@felix-mittermeier I understand and agree with your priority system Flutter has in place. As for this bug it does seems to be a regression created by the Flutter team in version 3.0.0 and continues in 3.0.1. While I can downgrade to 2.10.5 to build my app all versions of 3.x are completely broken. Not sure how that doesn't equal a regression.

pitazzo commented 2 years ago

This issue is also affecting our team. In order to evaluate the possibility of downgrading the Flutter SDK, how long should we expect to take merging https://github.com/flutter/engine/pull/33599 ?

Rossdex commented 2 years ago

This is affecting our app and stopping a new release - we use the mapbox_gl plugin and have a map on our first page.

The map stays visible when the user opens the drawer or pushes a page on top.

felix-mittermeier commented 2 years ago

This is affecting our app and stopping a new release - we use the mapbox_gl plugin and have a map on our first page.

The map stays visible when the user opens the drawer or pushes a page on top.

Can't you use Flutter 2.10.5 for building the release? That's how we do it currently - and if this gets fixed we'll start using the 3.x.x version.

Edit: Don't understand why I get downvotes for a "question"? This was just a suggestion because using 2.10.5 to build the release is still better than not being able to build a release at all, right? 🤔

penhorwood commented 2 years ago

What I don't get is 4 days ago I was told this issue was waiting on a test case wrapped up in this pull request: https://github.com/flutter/engine/pull/33574. The pull request was merged but the pull request https://github.com/flutter/engine/pull/33599 is still a Draft. So what else are we waiting on?

cfsbhawkins commented 2 years ago

What I don't get is 4 days ago I was told this issue was waiting on a test case wrapped up in this pull request: flutter/engine#33574. The pull request was merged but the pull request flutter/engine#33599 is still a Draft. So what else are we waiting on?

If I'm following right, it looks like the test cases might have been reverted out by another dev because builds were failing? See: https://github.com/flutter/engine/pull/33813

penhorwood commented 2 years ago

I read over the pull request. I find the way they do their stuff very confusing. We use git and pull request with an online system at work but nothing this confusing.