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
166.83k stars 27.65k forks source link

[Impeller] Vulkan driver crash on Huawei mate60 phone. #156623

Closed yaochangliang159 closed 1 month ago

yaochangliang159 commented 1 month ago

Steps to reproduce

1.create new flutter project with flutter sdk 3.26 2.run app to huawei mate60 or mate x5 3.APP crash

Expected results

i Expected that flutter 3.26 build an android app can work well on huawei mate60、huawei mate X5

Actual results

Build fingerprint: 'HUAWEI/BRA-AL00/HWBRA:12/HUAWEIBRA-AL00/104.2.0.138C00:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2024-10-12 05:39:28.189144429+0800
Process uptime: 0s
Cmdline: com.example.test001
pid: 4541, tid: 14792, name: example.test001  >>> com.example.test001 <<<
uid: 10502
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
    x0  3f77f7f83f7efeff  x1  0000007870312960  x2  0000000000000000  x3  0000000000000000
    x4  0000000000000000  x5  0000007738229d00  x6  00000077bb815030  x7  0000007736b341a0
    x8  0000007872292230  x9  0000000000000003  x10 0000000000000000  x11 0000000000000000
    x12 0000007736b49650  x13 00000077bb815450  x14 0000007738228830  x15 000000788057deb8
    x16 00000077a431b740  x17 0000007880552284  x18 0000007720e9c000  x19 0000007721b111e0
    x20 0000007721b11100  x21 0000007721b11208  x22 0000007721b11238  x23 000000773468115b
    x24 0000007736b352e0  x25 0000007721a1ba10  x26 0000000000000000  x27 0000007743a95100
    x28 00000000aaaaaaab  x29 0000007721a1b960
    lr  00000077347b9c60  sp  0000007721a1b960  pc  0000000000000000  pst 0000000020001400
backtrace:
      #00 pc 0000000000000000  <unknown>
      #01 pc 0000000000165c5c  /vendor/lib64/hw/vulkan.hvgr_v200.so (BuildId: 44d3bc026e1dcb7c91763d53eabba274)
      #02 pc 00000000002f9e68  /vendor/lib64/hw/vulkan.hvgr_v200.so (BuildId: 44d3bc026e1dcb7c91763d53eabba274)
      #03 pc 00000000002fb4f0  /vendor/lib64/hw/vulkan.hvgr_v200.so (BuildId: 44d3bc026e1dcb7c91763d53eabba274)
      #04 pc 0000000000234210  /vendor/lib64/hw/vulkan.hvgr_v200.so (BuildId: 44d3bc026e1dcb7c91763d53eabba274)
      #05 pc 00000000000fc370  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+176) (BuildId: 82f181b5d9da8999785cca84af3dad4b)
      #06 pc 000000000009a4fc  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+40) (BuildId: 82f181b5d9da8999785cca84af3dad4b)
Lost connection to device.
the Dart compiler exited unexpectedly.

Code sample

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(

        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {

      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        // TRY THIS: Try changing the color here to a specific color (to
        // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
        // change color while the other colors stay the same.
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(

          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

this is my demo code(720KB),it is jush a new flutter project test001.zip

Screenshots or Video

No response

Logs

Launching lib/main.dart on BRA AL00 in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk
Installing build/app/outputs/flutter-apk/app-debug.apk...
I/flutter ( 4541): [IMPORTANT:flutter/shell/platform/android/android_context_vk_impeller.cc(60)] Using the Impeller rendering backend (Vulkan).
Debug service listening on ws://127.0.0.1:56879/DlLcfkjhzxQ=/ws
Syncing files to device BRA AL00...
I/example.test00( 4541): Compiler allocated 5042KB to compile void android.view.ViewRootImpl.performTraversals()
I/AwareBitmapCacher( 4541): init lrucache size: 4194304 pid=4541
I/HwViewRootImpl( 4541): removeInvalidNode jank list is null
I/DecorView[]( 4541): pkgName:com.example.test001 old windowMode:1 new windoMode:1, isFixedSize:false, isStackNeedCaptionView:true
D/ProfileInstaller( 4541): Installing profile for com.example.test001
D/stylus  ( 4541): init stylus touchlistener.
I/Hwaps   ( 4541): APS: EventAnalyzed: initAPS: version is 11.0.0.4
D/Hwaps   ( 4541): Fpsrequest create,type:EXACTLY_IDENTIFY
D/Hwaps   ( 4541): Fpsrequest create,type:EXACTLY_IDENTIFY
D/Hwaps   ( 4541): Fpsrequest create,type:OPENGL_SETTING
D/Hwaps   ( 4541): FpsController create
D/Hwaps   ( 4541): APS: EventAnalyzed: reInitFpsPara :mBaseFps = 120; mMaxFps = 120
I/HwViewRootImpl( 4541): Add sceneId 11 topId: 10
W/Settings( 4541): Setting device_provisioned has moved from android.provider.Settings.Secure to android.provider.Settings.Global.
V/HiTouch_HiTouchSensor( 4541): User setup is finished.
D/HwDragEnhancementImpl( 4541): handleTimerDrag: false
D/HwDragEnhancementImpl( 4541): handleTimerDrag: false
W/HwApsManager( 4541): HwApsManagerService, registerCallback, start !
D/Hwaps   ( 4541): APS: EventAnalyzed: registerCallbackInApsManagerService, mPkgName:com.example.test001; result = true
D/HwViewRootImpl( 4541): [DetectViewsLocationRunner] current resolutionScale: 1.0
I/HwViewRootImpl( 4541): remove sceneId 11 topId: 10
D/WebViewDragEnhancement( 4541): dragReset.
D/WebViewDragEnhancement( 4541): dragReset cacheSize = 0
V/AudioManager( 4541): querySoundEffectsEnabled...
I/AudioManager( 4541): querySoundEffectsEnabled fail id: 0
F/libc    ( 4541): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 14792 (example.test001), pid 4541 (example.test001)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'HUAWEI/BRA-AL00/HWBRA:12/HUAWEIBRA-AL00/104.2.0.138C00:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2024-10-12 05:39:28.189144429+0800
Process uptime: 0s
Cmdline: com.example.test001
pid: 4541, tid: 14792, name: example.test001  >>> com.example.test001 <<<
uid: 10502
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
    x0  3f77f7f83f7efeff  x1  0000007870312960  x2  0000000000000000  x3  0000000000000000
    x4  0000000000000000  x5  0000007738229d00  x6  00000077bb815030  x7  0000007736b341a0
    x8  0000007872292230  x9  0000000000000003  x10 0000000000000000  x11 0000000000000000
    x12 0000007736b49650  x13 00000077bb815450  x14 0000007738228830  x15 000000788057deb8
    x16 00000077a431b740  x17 0000007880552284  x18 0000007720e9c000  x19 0000007721b111e0
    x20 0000007721b11100  x21 0000007721b11208  x22 0000007721b11238  x23 000000773468115b
    x24 0000007736b352e0  x25 0000007721a1ba10  x26 0000000000000000  x27 0000007743a95100
    x28 00000000aaaaaaab  x29 0000007721a1b960
    lr  00000077347b9c60  sp  0000007721a1b960  pc  0000000000000000  pst 0000000020001400
backtrace:
      #00 pc 0000000000000000  <unknown>
      #01 pc 0000000000165c5c  /vendor/lib64/hw/vulkan.hvgr_v200.so (BuildId: 44d3bc026e1dcb7c91763d53eabba274)
      #02 pc 00000000002f9e68  /vendor/lib64/hw/vulkan.hvgr_v200.so (BuildId: 44d3bc026e1dcb7c91763d53eabba274)
      #03 pc 00000000002fb4f0  /vendor/lib64/hw/vulkan.hvgr_v200.so (BuildId: 44d3bc026e1dcb7c91763d53eabba274)
      #04 pc 0000000000234210  /vendor/lib64/hw/vulkan.hvgr_v200.so (BuildId: 44d3bc026e1dcb7c91763d53eabba274)
      #05 pc 00000000000fc370  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+176) (BuildId: 82f181b5d9da8999785cca84af3dad4b)
      #06 pc 000000000009a4fc  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+40) (BuildId: 82f181b5d9da8999785cca84af3dad4b)
Lost connection to device.
the Dart compiler exited unexpectedly.

Flutter Doctor output

Last login: Fri Oct 11 20:50:04 on ttys000 yaochangliang@yaochangliang ~ % flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 3.26.0-1.0.pre.414, on macOS 12.7.6 21H1320
    darwin-x64, locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor
      --android-licenses
[!] Xcode - develop for iOS and macOS (Xcode 14.2)
    ! Flutter recommends a minimum Xcode version of 15.
      Download the latest version or update via the Mac App Store.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
[✓] Connected device (2 available)
    ! Device atc.alltesting.cn:48512 is offline.
[✓] Network resources

! Doctor found issues in 2 categories.
yaochangliang@yaochangliang ~ % 
yaochangliang159 commented 1 month ago

when i downgrade flutter sdk from master 3.26 to stable 3.22,it works well on huawei mate 60,there have no crash! why? Does it means the future flutter sdk stable version will still crash on huawei mate 60????

jonahwilliams commented 1 month ago

This device is a harmony OS device, right? Do you know what Android api level it is running on?

It looks like the application is crashing on something in the Vulkan driver. Flutter now uses Vulkan on devices that support it.

Its not possible for me to say by looking at the obfuscated stack trace whether this is caused by a bug in the flutter engine or a bug in this particular device/vulkan driver. To start with you could try running with --enable-vulkan-validation. That will show some valudation messages if there is API misuse.

Another path to try would be to disable the android surface control. That can be done with the AndroidManifest setting

<meta-data
    android:name="ioio.flutter.embedding.android.DisableSurfaceControl"
    android:value="true" />

If that doesn't work you could opt back into the old Skia renderer:

 <meta-data
    android:name="ioio.flutter.embedding.android.EnableImpeller"
    android:value="false" />

However we will eventually remove this option as long term we only plan to support one rendering backend.

jonahwilliams commented 1 month ago

EDIT: I forgot to include the manifest configuration in "```" so it didn't show up, fixed now.

iapicca commented 1 month ago

@yaochangliang159

i Expected that flutter 3.26 build an android app can work well on huawei mate60、huawei mate X5

Huawei Mate60 and Huawei Mate X5 are HarmonyOS devices outside Europe (links: 1, 2) and flutter doesn't support HarmonyOS

image

so the correct approach should be a custom embedder

yaochangliang159 commented 1 month ago

@jonahwilliams YES it is harmony OS device,you can test this device on this web site: 泽众云真机,click me! this web site Free use for 30 minutes for new register user QQ20241014-101451 A2534A720778EE8516D69C25D166D107

yaochangliang159 commented 1 month ago

@iapicca you say "flutter doesn't support HarmonyOS",but why i downgrade flutter to 3.22.4,it can run app to huawei mate60 works well? it happens on flutter 3.26,app crashed,you can try it on this web site: https://atc.alltesting.cn:8888/atc/debug/test

jonahwilliams commented 1 month ago

@yaochangliang159 @iapicca lets keep this discussion focused on the bug report.

jonahwilliams commented 1 month ago

Waiting on:

  1. confirmation that either of the android manifest flags provided work
  2. report on what the device's API level claims to be.
yaochangliang159 commented 1 month ago

@jonahwilliams i add this code to manifest node,but app still crash :

<meta-data
    android:name="io.flutter.embedding.android.DisableSurfaceControl"
    android:value="true" />

<meta-data
    android:name="io.flutter.embedding.android.EnableImpeller"
    android:value="false" />
yaochangliang159 commented 1 month ago

@jonahwilliams

the huawei mate 60 is harmony os 4.2.0

i add device_info_plus: ^11.0.0 in yaml file and i add this code in initState method:

Future<void> printDeviceInfo() async {
    DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
    AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
    String result =androidInfo.toString();
    print('androidInfo: ${androidInfo.toString()}');
  }

this is my print:

BaseDeviceInfo{data: {product: ALN-AL80, supportedAbis: [arm64-v8a, armeabi-v7a, armeabi], serialNumber: unknown, supported32BitAbis: [armeabi-v7a, armeabi], display: ALN-AL80 4.2.0.120(SP5C00E100R4P16), type: user, isPhysicalDevice: true, version: {baseOS: , securityPatch: 2021-10-05, sdkInt: 31, release: 12, codename: REL, previewSdkInt: 0, incremental: 104.2.0.120SP5C00}, systemFeatures: [android.hardware.sensor.proximity, android.hardware.sensor.accelerometer, android.software.controls, android.hardware.faketouch, android.hardware.usb.accessory, android.software.backup, android.hardware.touchscreen, android.hardware.touchscreen.multitouch, android.software.print, android.hardware.consumerir, com.huawei.emui.api.23, com.huawei.software.features.full, android.software.activities_on_secondary_displays, android.software.voice_recognizers, android.software.picture_in_picture, android.hardware.fingerprint, android.hardware.sensor.gyroscope, android.hardware.audio.low_latency, android.software.vulkan.deqp.level, android.software.cant_save_state, android.hardware.security.model.compatible, android.hardware.opengles.aep, android.hardware.bluetooth, android.hardware.camera.autofocus, android.hardware.telephony.gsm, android.hardware.telephony.ims, android.software.incremental_delivery, android.hardware.se.omapi.ese, android.software.opengles.deqp.level, android.hardware.usb.host, android.hardware.audio.output, android.software.verified_boot, android.hardware.camera.flash, android.hardware.camera.front, android.hardware.se.omapi.uicc, android.hardware.screen.portrait, android.hardware.nfc, com.nxp.mifare, android.hardware.sensor.stepdetector, android.software.home_screen, com.huawei.system.feature, android.hardware.microphone, com.huawei.software.features.huawei, android.software.autofill, android.software.securely_removes_users, android.hardware.bluetooth_le, android.hardware.sensor.compass, android.hardware.touchscreen.multitouch.jazzhand, android.hardware.sensor.barometer, android.software.app_widgets, android.software.input_methods, android.hardware.sensor.light, android.hardware.vulkan.version, android.software.companion_device_setup, android.software.device_admin, android.hardware.wifi.passpoint, android.hardware.camera, android.hardware.screen.landscape, android.hardware.ram.normal, android.software.managed_users, android.software.webview, android.hardware.sensor.stepcounter, android.hardware.camera.capability.manual_post_processing, android.hardware.camera.any, android.hardware.vulkan.compute, com.huawei.software.features.china, android.software.connectionservice, android.hardware.touchscreen.multitouch.distinct, android.hardware.location.network, android.software.cts, android.software.app_enumeration, android.hardware.wifi.direct, android.software.live_wallpaper, android.software.ipsec_tunnels, android.software.freeform_window_management, android.hardware.nfc.hcef, android.hardware.nfc.uicc, android.hardware.location.gps, android.software.midi, android.hardware.nfc.any, android.hardware.nfc.hce, com.huawei.software.features.handset, android.hardware.wifi, android.hardware.location, android.hardware.vulkan.level, android.software.secure_lock_screen, huawei.android.hardware.stylus, android.hardware.telephony, android.software.file_based_encryption], manufacturer: HUAWEI, tags: release-keys, supported64BitAbis: [arm64-v8a], bootloader: unknown, fingerprint: HUAWEI/ALN-AL80/HWALN:12/HUAWEIALN-AL80/104.2.0.120SP5C00:user/release-keys, host: cn-west-hcd-5a-d4f16f6941713243224288-589f66ffbd-l75dx, isLowRamDevice: false, model: ALN-AL80, id: HUAWEIALN-AL80, brand: HUAWEI, device: HWALN, board: ALN, hardware: kirin9000s}}

we can get messages from above prints:

sdkInt is 31

the device is android 12 system

darshankawar commented 1 month ago

I tried to symbolicate as below but it seems to be coming back with same info:

dart pub global run symbolizer:symbolize https://github.com/flutter/flutter/issues/156623#issue-2582243695 "flutter#ee624bc arm64 debug force android"

dhs@Dhss-MacBook-Pro ~ % dart pub global run symbolizer:symbolize https://github.com/flutter/flutter/issues/156623#issue-2582243695 "flutter#ee624bc arm64 debug force android"
INFO: 2024-10-15 11:22:38.909128: checking for llvm-{symbolizer,readobj,objdump} in $PATH
INFO: 2024-10-15 11:22:38.935906: checking for llvm-{symbolizer,readobj,objdump} in tools/android-ndk/toolchains/llvm/prebuilt/darwin-x86_64/bin/
INFO: 2024-10-15 11:22:38.967790: checking for llvm-{symbolizer,readobj,objdump} in /Users/dhs/Library/Android/sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/darwin-x86_64/bin/
INFO: 2024-10-15 11:22:40.293778: downloading /var/folders/w0/6j3m5z913hbd94smbfmz6y6h0000gn/T/symbols-cache/059e4e6d8ff6de39c29441c53e949bfb0bf17972-android-arm64 for EngineBuild(engineHash: 059e4e6d8ff6de39c29441c53e949bfb0bf17972, variant: EngineVariant(os: android, arch: arm64, mode: debug))
INFO: 2024-10-15 11:22:40.296135: gsutil cp gs://flutter_infra_release/flutter/059e4e6d8ff6de39c29441c53e949bfb0bf17972/android-arm64/symbols.zip /var/folders/w0/6j3m5z913hbd94smbfmz6y6h0000gn/T/kuJjrM/symbols.zip
INFO: 2024-10-15 11:23:00.078290: Symbolizing using /var/folders/w0/6j3m5z913hbd94smbfmz6y6h0000gn/T/symbols-cache/059e4e6d8ff6de39c29441c53e949bfb0bf17972-android-arm64/libflutter.so

--------------------------------------------------------------------------------
symbolized using symbols for 059e4e6d8ff6de39c29441c53e949bfb0bf17972 android-arm64-debug

  #00 0000000000000000 <unknown> 
  #01 0000000000165c5c /vendor/lib64/hw/vulkan.hvgr_v200.so (BuildId: 44d3bc026e1dcb7c91763d53eabba274)
  #02 00000000002f9e68 /vendor/lib64/hw/vulkan.hvgr_v200.so (BuildId: 44d3bc026e1dcb7c91763d53eabba274)
  #03 00000000002fb4f0 /vendor/lib64/hw/vulkan.hvgr_v200.so (BuildId: 44d3bc026e1dcb7c91763d53eabba274)
  #04 0000000000234210 /vendor/lib64/hw/vulkan.hvgr_v200.so (BuildId: 44d3bc026e1dcb7c91763d53eabba274)
  #05 00000000000fc370 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+176) (BuildId: 82f181b5d9da8999785cca84af3dad4b)
  #06 000000000009a4fc /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+40) (BuildId: 82f181b5d9da8999785cca84af3dad4b)

--------------------------------------------------------------------------------

dhs@Dhss-MacBook-Pro ~ % 

I will keep the issue open for team's tracking.

jonahwilliams commented 1 month ago

@yaochangliang159 does you app still have an Android Manifest? If so, please confirm where you added this data. It needs to be metadata under the <application> tag

jonahwilliams commented 1 month ago

Also please try them one at a time.

yaochangliang159 commented 1 month ago

@jonahwilliams i add this code under application tag in manifest

my problem solved!!! APP works well!

<meta-data android:name="io.flutter.embedding.android.EnableImpeller" android:value="false" />

thank you very much!!!!! thank you very much!!! thank you very much!!!

jonahwilliams commented 1 month ago

@yaochangliang159 can you separately try the other flag? Like I mentioned, we will eventually remove Skia support too, so any hints as to why its crashing would be helpful

yaochangliang159 commented 1 month ago

@jonahwilliams when i only add this code under application tag,App Crash:

<meta-data android:name="io.flutter.embedding.android.DisableSurfaceControl" android:value="true" />

when i only add this code under application tag,App Works Well: <meta-data android:name="io.flutter.embedding.android.EnableImpeller" android:value="false" />

jonahwilliams commented 1 month ago

Thank you @yaochangliang159 ! one more flag if you have time to check. This one will only work in debug mode:

<meta-data android:name="io.flutter.embedding.android.ImpellerBackend" android:value="opengles" />

This will switch the app to using the Impeller OpenGLES backend.

yaochangliang159 commented 1 month ago

@jonahwilliams yes, you are right!when i only add this code under application tag: <meta-data android:name="io.flutter.embedding.android.ImpellerBackend" android:value="opengles" />

in debug mode ,App Works Well!

but in release mode ,App Crash!

jonahwilliams commented 1 month ago

Thanks again @yaochangliang159 . So the situation is:

Using Skia OpenGL works (via opting out of Impeller) Using the Impeller OpenGL backend works (via debug opt in) - but this isn't supported in release builds as its just a debug flag.

It seems like a reasonable short term change is to add this driver to the denylist so that it continues to use Skia OpenGL, and later when we finish the Impeller OpenGL backend it can use that. In the meantime, you can opt out of impeller with the EnableImpeller manifest flag.

github-actions[bot] commented 3 weeks ago

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.