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.45k stars 27.31k forks source link

Android APP Crash on flutter 3.26.0 on huawei mate60 phone #156623

Open yaochangliang159 opened 3 days ago

yaochangliang159 commented 3 days 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

  #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 createState() => _MyHomePageState(); }

class _MyHomePageState extends State { 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: 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

  #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 3 days 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 3 days 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 3 days ago

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

iapicca commented 2 days 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 22 hours 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 22 hours 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 22 hours ago

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

jonahwilliams commented 22 hours 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 11 hours 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 10 hours 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 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