flutter icon indicating copy to clipboard operation
flutter copied to clipboard

[Flutter 3] new native crash - null pointer dereference

Open AAverin opened this issue 2 years ago • 32 comments

I am looking for some help debugging a new critical native crash that affects Mapbox Flutter plugin.

The issue doesn't reproduce on Flutter 2.13 and is only present in Flutter 3.x. No changes to the way plugin was integrated were made and no changes to the native code that plugin relies on were made. The only change was upgrade to Flutter 3.

I have checked the changes done in Flutter engine between 2.13 and 3.0 releases and it's only dart revision: https://github.com/flutter/engine/compare/3096903c8923608d3c1ccf8058a29c31a2bfbc53..d1b9a6938ad77326ac3a94d92bbc77933ed829ed.

Any insight on where to dig?

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Click on any button that would open the map (try again if it didn't crash)
  3. Observer native crash
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/sdk_gphone64_arm64/emulator64_arm64:12/S2B2.211203.006/8015633:userdebug/dev-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2022-07-08 13:33:24.673577251+0200
Process uptime: 0s
Cmdline: com.mapbox.mapboxglexample
pid: 4347, tid: 4489, name: GLThread 98  >>> com.mapbox.mapboxglexample <<<
uid: 10152
tagged_addr_ctrl: 0000000000000001
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
    x0  0000000000000000  x1  0000000000000000  x2  0000000000000001  x3  00000073580c68fc
    x4  00000072b018e338  x5  000000000000004a  x6  4900ff55284901ff  x7  7f7f7f7f7f7f7f7f
    x8  0000000000000000  x9  00000072b018f040  x10 0000000000000001  x11 0000000000000001
    x12 00000000000000ff  x13 0000000000000000  x14 7ffbffff00000000  x15 0000000000000000
    x16 00000072c0d5ef70  x17 00000075f77d72cc  x18 000000728602c000  x19 00000072b018e448
    x20 0000000000000000  x21 0000000000000001  x22 00000072dde6f7a4  x23 0000000000001070
    x24 0000007358200880  x25 00000072b018e5b0  x26 00000072b018e5e0  x27 00000072b018e5b0
    x28 00000072b018e4b0  x29 00000072b018e3e0
    lr  00000072c094981c  sp  00000072b018e3d0  pc  00000072c0949948  pst 0000000060001000
backtrace:
      #00 pc 000000000011d948  /data/app/~~Q0TqeVocFhBLh_eRCp4W2Q==/com.mapbox.mapboxglexample-2g_T8q8jdDQ3a3tJWF_j1g==/lib/arm64/libmapbox-gl.so (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7)
      #01 pc 000000000011d818  /data/app/~~Q0TqeVocFhBLh_eRCp4W2Q==/com.mapbox.mapboxglexample-2g_T8q8jdDQ3a3tJWF_j1g==/lib/arm64/libmapbox-gl.so (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7)
      #02 pc 00000000000adc2c  /data/app/~~Q0TqeVocFhBLh_eRCp4W2Q==/com.mapbox.mapboxglexample-2g_T8q8jdDQ3a3tJWF_j1g==/lib/arm64/libmapbox-gl.so (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7)
      #03 pc 00000000002d7644  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
      #04 pc 000000000020a0a0  /apex/com.android.art/lib64/libart.so (nterp_helper+4016) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
      #05 pc 00000000004297a4  [anon:dalvik-classes2.dex extracted in memory from /data/app/~~Q0TqeVocFhBLh_eRCp4W2Q==/com.mapbox.mapboxglexample-2g_T8q8jdDQ3a3tJWF_j1g==/base.apk!classes2.dex] (com.mapbox.mapboxsdk.maps.renderer.MapRenderer.onDrawFrame+12)
      #06 pc 000000000020a044  /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
      #07 pc 000000000042b484  [anon:dalvik-classes2.dex extracted in memory from /data/app/~~Q0TqeVocFhBLh_eRCp4W2Q==/com.mapbox.mapboxglexample-2g_T8q8jdDQ3a3tJWF_j1g==/base.apk!classes2.dex] (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer.onDrawFrame+0)
      #08 pc 000000000020af10  /apex/com.android.art/lib64/libart.so (nterp_helper+7712) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
      #09 pc 000000000042befa  [anon:dalvik-classes2.dex extracted in memory from /data/app/~~Q0TqeVocFhBLh_eRCp4W2Q==/com.mapbox.mapboxglexample-2g_T8q8jdDQ3a3tJWF_j1g==/base.apk!classes2.dex] (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView$GLThread.guardedRun+994)
      #10 pc 000000000020a044  /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
      #11 pc 000000000042c490  [anon:dalvik-classes2.dex extracted in memory from /data/app/~~Q0TqeVocFhBLh_eRCp4W2Q==/com.mapbox.mapboxglexample-2g_T8q8jdDQ3a3tJWF_j1g==/base.apk!classes2.dex] (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView$GLThread.run+48)
      #12 pc 00000000002cdd64  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
      #13 pc 0000000000317fb0  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+156) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
      #14 pc 00000000003cc480  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*)+380) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
      #15 pc 000000000045efd8  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+992) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
      #16 pc 00000000000b1810  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+264) (BuildId: b2e84269f59e7b1658e3a470fd302458)
      #17 pc 00000000000512f0  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: b2e84269f59e7b1658e3a470fd302458)

Expected results: App shouldn't crash

Actual results: App crashes with native crash that doesn't happen in Flutter 2.13

Code sample https://github.com/flutter-mapbox-gl/maps/tree/master/example

Follow readme instructions on how to run mapbox example app

Logs
[✓] Flutter (Channel master, 3.1.0-0.0.pre.1542, on macOS 12.4 21F79 darwin-arm, locale en-GB)
    • Flutter version 3.1.0-0.0.pre.1542 on channel master at /Volumes/MyData/Common/Flutter/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b748d1fb1a (18 hours ago), 2022-07-07 10:46:07 -0700
    • Engine revision 61a3788bb9
    • Dart version 2.18.0 (build 2.18.0-261.0.dev)
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Volumes/MyData/Common/Android/sdk
    • Platform android-32, build-tools 32.1.0-rc1
    • Java binary at: /Volumes/MyData/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.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13F100
    • CocoaPods version 1.11.2

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

[✓] Android Studio (version 2021.2)
    • Android Studio at /Volumes/MyData/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)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2)
    • IntelliJ at /Volumes/MyData/Applications/IntelliJ IDEA.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.68.1)
    • VS Code at /Volumes/MyData/Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.42.0

[✓] Connected device (3 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64  • Android 12 (API 32) (emulator)
    • macOS (desktop)             • macos         • darwin-arm64   • macOS 12.4 21F79 darwin-arm
    • Chrome (web)                • chrome        • web-javascript • Google Chrome 103.0.5060.114

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

• No issues found!

AAverin avatar Jul 08 '22 11:07 AAverin

Hi @AAverin I can not reproduce the issue on the latest stable and master channels. The sample code runs normally without crashing.

Tested on devices:

  • Pixel 3a Android 12
  • Samsung Galaxy Tab A7 Lite Android 11 OneUI 3.1, SM-T225
Demo

https://user-images.githubusercontent.com/104349824/178183646-85bce262-aa34-4c18-966e-8e2ba048a784.mp4

https://user-images.githubusercontent.com/104349824/178184508-3e85fba9-c4a6-48cd-bc95-0b2d04aed9bd.mov

flutter doctor -v
[✓] Flutter (Channel stable, 3.0.4, on macOS 12.2.1 21D62 darwin-x64, locale en-VN)
    • Flutter version 3.0.4 at /Users/huynq/Documents/GitHub/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 85684f9300 (3 days ago), 2022-06-30 13:22:47 -0700
    • Engine revision 6ba2af10bb
    • Dart version 2.17.5
    • 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-33, 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.3)
    • 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
    • Android Studio at /Applications/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.

[✓] 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)

[✓] 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

[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
    • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/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.68.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.42.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 103.0.5060.53

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

! Doctor found issues in 1 category.
[✓] Flutter (Channel master, 3.1.0-0.0.pre.1591, on macOS 12.2.1 21D62 darwin-x64, locale en-VN)
    • Flutter version 3.1.0-0.0.pre.1591 on channel master at /Users/huynq/Documents/GitHub/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8d4cad8149 (87 minutes ago), 2022-07-10 21:20:06 -0400
    • Engine revision 15402b25b0
    • Dart version 2.18.0 (build 2.18.0-271.0.dev)
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, 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.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13E113
    • 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)

[✓] 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

[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
    • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/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.68.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.44.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 103.0.5060.114

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

• No issues found!

Does this issue happen on Flutter stable 3.0.4 and latest Flutter master 3.1.0-0.0.pre.1591? And could you please retry on a physical device and see if the issue's still reproducible?

huycozy avatar Jul 11 '22 03:07 huycozy

Also couldn't reproduce on 3.1.0-0.0.pre.1650. Will keep testing once I have better network connection and can compare with previous master states. Latest master is required due to https://github.com/flutter/flutter/issues/103630 being fixed there.

AAverin avatar Jul 14 '22 08:07 AAverin

I am still getting the crash on the latest version of Flutter master, usually on hot reload. Will see if find a way to reproduce on a sample somehow.

AAverin avatar Jul 14 '22 13:07 AAverin

The issue looks to be related to the creation of a new instance of the plugin. Were there any changes done there? I can definitely see an improvement on the latest master, before that crashes were happening much more often. Will still need to test it in more detail once I have better network connection.

AAverin avatar Jul 14 '22 21:07 AAverin

Were there any changes done there?

There are many changes that are updated every day. So it's pretty hard to find the PR that fixed this. But if it has improved on master, please try again and again to make sure the issue is fixed. Anyway, I'd love to hear your feedback.

huycozy avatar Jul 15 '22 12:07 huycozy

@huycozy On 3.1.0-0.0.pre.1650 in the mapbox example app, going in and out "User Interface" test screen results in that native crash still. Doesn't reproduce that often anymore, but still does. Looks to be related to creation of a new plugin instance.

AAverin avatar Jul 16 '22 08:07 AAverin

@flutter-symbolizer-bot https://github.com/flutter/flutter/issues/107297#issue-1298925304 flutter#v3.1.0-0.0.pre.1542 debug arm64

huycozy avatar Jul 18 '22 02:07 huycozy

crash from https://github.com/flutter/flutter/issues/107297#issue-1298925304 symbolized using symbols for 61a3788bb933c71c3f8ff13cf57cad7ea18e8a34 android-arm64-debug

#00 000000000011d948 <...>/lib/arm64/libmapbox-gl.so (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7)
#01 000000000011d818 <...>/lib/arm64/libmapbox-gl.so (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7)
#02 00000000000adc2c <...>/lib/arm64/libmapbox-gl.so (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7)
#03 00000000002d7644 /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
#04 000000000020a0a0 /apex/com.android.art/lib64/libart.so (nterp_helper+4016) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
#05 00000000004297a4 [anon:dalvik-classes2.dex extracted in memory from /data/app/~~Q0TqeVocFhBLh_eRCp4W2Q==/com.mapbox.mapboxglexample-2g_T8q8jdDQ3a3tJWF_j1g==/base.apk!classes2.dex] (com.mapbox.mapboxsdk.maps.renderer.MapRenderer.onDrawFrame+12)
#06 000000000020a044 /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
#07 000000000042b484 [anon:dalvik-classes2.dex extracted in memory from /data/app/~~Q0TqeVocFhBLh_eRCp4W2Q==/com.mapbox.mapboxglexample-2g_T8q8jdDQ3a3tJWF_j1g==/base.apk!classes2.dex] (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer.onDrawFrame+0)
#08 000000000020af10 /apex/com.android.art/lib64/libart.so (nterp_helper+7712) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
#09 000000000042befa [anon:dalvik-classes2.dex extracted in memory from /data/app/~~Q0TqeVocFhBLh_eRCp4W2Q==/com.mapbox.mapboxglexample-2g_T8q8jdDQ3a3tJWF_j1g==/base.apk!classes2.dex] (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView$GLThread.guardedRun+994)
#10 000000000020a044 /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
#11 000000000042c490 [anon:dalvik-classes2.dex extracted in memory from /data/app/~~Q0TqeVocFhBLh_eRCp4W2Q==/com.mapbox.mapboxglexample-2g_T8q8jdDQ3a3tJWF_j1g==/base.apk!classes2.dex] (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView$GLThread.run+48)
#12 00000000002cdd64 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
#13 0000000000317fb0 /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+156) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
#14 00000000003cc480 /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*)+380) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
#15 000000000045efd8 /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+992) (BuildId: adb75d6f792faa24b1bc8cf512fb112c)
#16 00000000000b1810 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+264) (BuildId: b2e84269f59e7b1658e3a470fd302458)
#17 00000000000512f0 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: b2e84269f59e7b1658e3a470fd302458)

flutter-symbolizer-bot avatar Jul 18 '22 02:07 flutter-symbolizer-bot

@huycozy On 3.1.0-0.0.pre.1650 in the mapbox example app, going in and out "User Interface" test screen results in that native crash still. Doesn't reproduce that often anymore, but still does. Looks to be related to creation of a new plugin instance.

I still can not reproduce the issue on the latest stable and master channels with this reproduction step.

Demo

https://user-images.githubusercontent.com/104349824/179438996-ca46d77f-26aa-478a-9d92-a88c248c5161.mp4

flutter doctor -v
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.2.1 21D62 darwin-x64, locale en-VN)
    • Flutter version 3.0.5 at /Users/huynq/Documents/GitHub/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (9 hours ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • 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-33, 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.3)
    • 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)

[✓] 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

[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
    • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/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.69.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.44.0

[✓] Connected device (3 available)
    • SM T225 (mobile) • R9JT3004VRJ • android-arm64  • Android 11 (API 30)
    • macOS (desktop)  • macos       • darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)     • chrome      • web-javascript • Google Chrome 103.0.5060.114

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

• No issues found!

[✓] Flutter (Channel master, 3.1.0-0.0.pre.1698, on macOS 12.2.1 21D62 darwin-x64, locale en-VN)
    • Flutter version 3.1.0-0.0.pre.1698 on channel master at /Users/huynq/Documents/GitHub/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a4ba62fd9d (17 hours ago), 2022-07-17 05:48:06 -0400
    • Engine revision b438edfd1a
    • Dart version 2.19.0 (build 2.19.0-5.0.dev)
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, 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.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13E113
    • 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)

[✓] 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

[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
    • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/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.69.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.44.0

[✓] Connected device (3 available)
    • SM T225 (mobile) • R9JT3004VRJ • android-arm64  • Android 11 (API 30)
    • macOS (desktop)  • macos       • darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)     • chrome      • web-javascript • Google Chrome 103.0.5060.114

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

• No issues found!

It looks like you're testing on an emulator device. Could you retry on a physical device instead to see if the issue still reproduces?

huycozy avatar Jul 18 '22 03:07 huycozy

Sorry for the delay, I will run some more tests once I am back home after vacation next week. Anybody else from mapbox community is also welcome to add information here.

AAverin avatar Jul 22 '22 06:07 AAverin

I have the same issue. When I switch between screens very fast, after a few repeats I manage to crash my app.

Example code:
import 'package:flutter/material.dart';
import 'package:mapbox_gl/mapbox_gl.dart';
void main() {
  runApp(const MapTest());
}
class MapTest extends StatelessWidget {
  const MapTest({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'MapTest',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const HomeScreen(),
    );
  }
}
class HomeScreen extends StatelessWidget {
  const HomeScreen({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        actions: [
          IconButton(
            icon: const Icon(Icons.map),
            onPressed: () {
              Navigator.of(context).push(
                    MaterialPageRoute(
                  builder: (context) => const MapScreen(),
                ),
              );
            }
          ),
        ],
      ),
      body: const Center(child: Icon(Icons.home, size: 50)),
    );
  }
}
class MapScreen extends StatefulWidget {
  const MapScreen({super.key});
  @override
  State<MapScreen> createState() => _MapScreenState();
}
class _MapScreenState extends State<MapScreen> {
  late MapboxMapController mapController;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        actions: [
          IconButton(
            onPressed: () => Navigator.of(context).pop(),
            icon: const Icon(Icons.home),
          ),
        ],
      ),
      body: MapboxMap(
        accessToken: const String.fromEnvironment('SDK_REGISTRY_TOKEN'),
        initialCameraPosition: const CameraPosition(target: LatLng(0, 0)),
        onMapCreated: _onMapCreated,
      ),
    );
  }
  Future<void> _onMapCreated(MapboxMapController controller) async {
    mapController = controller;
  }
}

Mapbox version: 0.16.0

flutter doctor -v output:
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-x64, locale pl-PL)
    • Flutter version 3.0.5 at /Users/glowacki/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (9 days ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/glowacki/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • 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.4.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)

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

[✓] Connected device (3 available)
    • M2006C3MNG (mobile) • SSY9AAZLZXTKQWJN • android-arm    • Android 10 (API 29)
    • macOS (desktop)     • macos            • darwin-x64     • macOS 12.4 21F79 darwin-x64
    • Chrome (web)        • chrome           • web-javascript • Google Chrome 103.0.5060.134

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

• No issues found!

Szymon3125 avatar Jul 22 '22 13:07 Szymon3125

Same issue here, also with mapbox :/

dawid-niedzwiecki avatar Jul 22 '22 13:07 dawid-niedzwiecki

I've been working on that problem quite a long time and did not managed to solve it. I've thought that newest version on flutter might help with that but it did no changes with that case at all. It would be helpful if someone could find a workaround for this problem.

piotrkovsy1331 avatar Jul 25 '22 07:07 piotrkovsy1331

Mapbox Andorid SDK that Mapbox Flutter is using at the moment is not supported anymore, so recompiling the plugin is not an option. Any possible workaround that doesn't involve touching the native C++ library behind Mapbox Android SDK?

AAverin avatar Jul 25 '22 10:07 AAverin

Any possibility it's related to what was stated here? https://github.com/flutter/flutter/issues/103630#issuecomment-1193013914

cfsbhawkins avatar Jul 25 '22 14:07 cfsbhawkins

Hi @AAverin and anyone else facing this issue, there is a new beta release: 3.3.0 (also see https://github.com/flutter/flutter/issues/103630#issuecomment-1190733675). Could you retry the issue on the latest beta to see if the issue still reproduces?

huycozy avatar Jul 25 '22 14:07 huycozy

Mapbox is using SurfaceAndroidViewController for hybrid composition: https://github.com/flutter-mapbox-gl/maps/blob/3496907955cd4b442e4eb905d67e8d46692174f1/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart#L160 Was initSurfaceAndroidView also changed and calling create is no longer needed?

AAverin avatar Jul 27 '22 06:07 AAverin

Just updating to Flutter beta track 3.3 doesn't fix the crash

AAverin avatar Jul 27 '22 06:07 AAverin

If calling create is no longer needed when creating SurfaceAndroidViewController and PlatformViewsService with expensive controller, @huycozy could you please link to some Flutter issue or at least commit when this was changed? Just trying to understand some reasoning behind the change and link it to a possible fix PR in mapbox repo.

AAverin avatar Jul 27 '22 06:07 AAverin

@AAverin There is issue #103630 (closed and recently fixed) related to this issue as far as I can see (the issue was initially filed regarding Mapbox). By the way, there is a new issue #107313 related to AndroidView that you can follow. Keeping this open for further insights from the team.

huycozy avatar Jul 27 '22 07:07 huycozy

I am testing now with the controller.create() line removed here https://github.com/flutter-mapbox-gl/maps/blob/3496907955cd4b442e4eb905d67e8d46692174f1/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart#L160. Seems to be quite stable so far, no NPE crash. I will keep checking and if everything is fine make a PR to Mapbox Flutter for a possible fix.

AAverin avatar Jul 27 '22 07:07 AAverin

Ok, this was a bit too rushed. Crash is still there even with controller.create() line removed.

AAverin avatar Jul 27 '22 07:07 AAverin

Just to be safe I have downgraded to flutter 2.10.5, returned back controller.create() call for SurfaceAndroidViewController and tested my exact codebase state. No crash on Flutter 2.10.5.

AAverin avatar Jul 27 '22 07:07 AAverin

@AAverin Based on the number of people affected by this issue and it's not happening on Flutter 2.10.5 as you confirmed in https://github.com/flutter/flutter/issues/107297#issuecomment-1196378158, I label this issue for further opinions/investigation from the team. Thanks!

huycozy avatar Jul 27 '22 08:07 huycozy

Application Crashes as I navigate between pages and come back to MapBox page. This is happening only in the Android, IOS release build working fine . Android both release and debug crashes.

Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 9791 (GLThread 34140), pid 9313 (azei.totempole2)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'xiaomi/whyred/whyred:9/PKQ1.180904.001/V12.0.2.0.PEIMIXM:user/release-keys'
Revision: '0'
ABI: 'arm64'
pid: 9313, tid: 9791, name: GLThread 34140  >>> com.swazei.totempole2 <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
    x0  0000000000000000  x1  0000000000000000  x2  0000000000000001  x3  0000007a760ec708
    x4  0000007a48bf1f98  x5  8000000080000000  x6  ff284900ff302349  x7  7f7f7f7f7f7f7f7f
    x8  0000000000000000  x9  0000000000000001  x10 0000000000000001  x11 0000000000000000
    x12 0000007a48bf2134  x13 0000007a48bf2128  x14 0000000000000000  x15 0000007a48bf0bf8
    x16 0000007a471e3f70  x17 0000007af6d5eb14  x18 0000000000000001  x19 0000007a48bf20b8
    x20 0000000000000000  x21 0000000000000001  x22 0000000013ac4b38  x23 0000000013ac4b18
    x24 0000c1b36f03f7e8  x25 0000007a48bf3588  x26 0000007a4dbe00a0  x27 0000000000000002
    x28 0000007a48bf2130  x29 0000007a48bf2050
    sp  0000007a48bf2040  lr  0000007a46dce81c  pc  0000007a46dce948
backtrace:
    #00 pc 000000000011d948  /data/app/com.swazei.totempole2-g9Bj7xkxkez2k7QDtVnitQ==/lib/arm64/libmapbox-gl.so
    #01 pc 000000000011d818  /data/app/com.swazei.totempole2-g9Bj7xkxkez2k7QDtVnitQ==/lib/arm64/libmapbox-gl.so
    #02 pc 00000000000adc2c  /data/app/com.swazei.totempole2-g9Bj7xkxkez2k7QDtVnitQ==/lib/arm64/libmapbox-gl.so
    #03 pc 00000000005603e0  /system/lib64/libart.so (art_quick_generic_jni_trampoline+144)
    #04 pc 000000000004bea0  /dev/ashmem/dalvik-jit-code-cache (deleted) (com.mapbox.mapboxsdk.maps.renderer.MapRenderer.onDrawFrame+96)    
    #05 pc 0000000000557388  /system/lib64/libart.so (art_quick_invoke_stub+584)
    #06 pc 00000000000cfcc8  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
    #07 pc 0000000000280338  /system/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+344)
    #08 pc 000000000027a34c  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968)
    #09 pc 0000000000526b60  /system/lib64/libart.so (MterpInvokeSuper+1420)
    #10 pc 0000000000549a14  /system/lib64/libart.so (ExecuteMterpImpl+14356)
    #11 pc 00000000001bfcb0  /dev/ashmem/dalvik-classes3.dex extracted in memory from /data/app/com.swazei.totempole2-g9Bj7xkxkez2k7QDtVnitQ==/base.apk!classes3.dex (deleted) (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer.onDrawFrame)
    #12 pc 0000000000254050  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.3557229793+488)
    #13 pc 0000000000259b44  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
    #14 pc 000000000027a330  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
    #15 pc 0000000000527444  /system/lib64/libart.so (MterpInvokeInterface+1392)
    #16 pc 0000000000549b94  /system/lib64/libart.so (ExecuteMterpImpl+14740)
    #17 pc 00000000001c072e  /dev/ashmem/dalvik-classes3.dex extracted in memory from /data/app/com.swazei.totempole2-g9Bj7xkxkez2k7QDtVnitQ==/base.apk!classes3.dex (deleted) (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView$GLThread.guardedRun+998)
    #18 pc 0000000000254050  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.3557229793+488)
    #19 pc 0000000000259b44  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
    #20 pc 000000000027a330  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
    #21 pc 0000000000527808  /system/lib64/libart.so (MterpInvokeDirect+296)
    #22 pc 0000000000549a94  /system/lib64/libart.so (ExecuteMterpImpl+14484)
    #23 pc 00000000001c0ca0  /dev/ashmem/dalvik-classes3.dex extracted in memory from /data/app/com.swazei.totempole2-g9Bj7xkxkez2k7QDtVnitQ==/base.apk!classes3.dex (deleted) (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView$GLThread.run+48)
    #24 pc 0000000000254050  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.3557229793+488)
    #25 pc 0000000000516d7c  /system/lib64/libart.so (artQuickToInterpreterBridge+1020)
    #26 pc 00000000005604fc  /system/lib64/libart.so (art_quick_to_interpreter_bridge+92)
    #27 pc 0000000000557388  /system/lib64/libart.so (art_quick_invoke_stub+584)
    #28 pc 00000000000cfcc8  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
    #29 pc 000000000045dd7c  /system/lib64/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+104)
    #30 pc 000000000045ee38  /system/lib64/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue*)+424)
    #31 pc 0000000000489d28  /system/lib64/libart.so (art::Thread::CreateCallback(void*)+1120)
    #32 pc 0000000000090328  /system/lib64/libc.so (__pthread_start(void*)+36)
    #33 pc 0000000000023a28  /system/lib64/libc.so (__start_thread+68)
Lost connection to device.
[√] Flutter (Channel master, 3.1.0-0.0.pre.1709, on Microsoft Windows [Version 10.0.22621.232], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.6)
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.69.2)
[√] VS Code (version 1.70.0-insider)
[√] Connected device (5 available)
[√] HTTP Host Availability

Shiba-Kar avatar Jul 29 '22 06:07 Shiba-Kar

Any updates on this issue?

dawid-niedzwiecki avatar Aug 01 '22 08:08 dawid-niedzwiecki

Looking for update too.

MarkHarcosHUN avatar Aug 01 '22 11:08 MarkHarcosHUN

@AAverin Do you still see the crash if you change initSurfaceAndroidView to initExpensiveAndroidView. In Flutter 3, we switched away from using Hybrid Composition by default, but it looks like it is causing bugs for Android Views that don't draw to the canvas provided by a ViewParent. This is being addressed in https://github.com/flutter/flutter/issues/107313.

Using initExpensiveAndroidView sets the Platform View to be rendered with Hybrid Composition in Flutter 3.

And yes, create still needs to be called.

bparrishMines avatar Aug 04 '22 00:08 bparrishMines

And yes, create still needs to be called.

There's actually a regression I just found where we're double-calling create now for HC in some cases. I'm fixing it as part of my in-progress PR.

Since we already shipped it and people are starting to remove create as a workaround, I'm going to have to handle it internally by dropping duplicate create's, and then clean this up later in a new API that didn't ship with two different behaviors.

(See also https://github.com/flutter/flutter/issues/103630#issuecomment-1193013914 where someone else hit this.)

stuartmorgan avatar Aug 05 '22 18:08 stuartmorgan

@stuartmorgan Sorry if I've misunderstood, but I'm assigning you and marking this P3 based on your comment.

zanderso avatar Aug 08 '22 17:08 zanderso

Given:

Ok, this was a bit too rushed. Crash is still there even with controller.create() line removed.

it sounds like the original issue here won't be fixed by my PR, but we can re-test once it lands.

stuartmorgan avatar Aug 08 '22 17:08 stuartmorgan

Since we already shipped it and people are starting to remove create as a workaround, I'm going to have to handle it internally by dropping duplicate create's, and then clean this up later in a new API that didn't ship with two different behaviors.

I was incorrect; this regression is currently beta-only. So I'll fix it with something cleaner that we can cherry-pick to beta.

stuartmorgan avatar Aug 08 '22 19:08 stuartmorgan

I can confirm this crash is still happening on 3.3.0 stable, while the UX issues are now solved pressing back from the map causes the app to crash a few seconds later. This was seen on emulator and on a real device (Pixel 2 XL).

I/Choreographer(13108): Skipped 32 frames!  The application may be doing too much work on its main thread.
F/libc    (13108): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 15410 (GLThread 1030), pid 13108 (re.flutter.core)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/taimen/taimen:11/RP1A.201005.004.A1/6934943:user/release-keys'
Revision: 'rev_10'
ABI: 'arm64'
Timestamp: 2022-08-30 15:30:18-0500
pid: 13108, tid: 15410, name: GLThread 1030  >>> com.coolfire.flutter.core <<<
uid: 10038
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
    x0  0000000000000000  x1  0000000000000000  x2  0000000000000001  x3  000000746c8fd605
    x4  00000073f2bc8c48  x5  000000000000004a  x6  284901ff3a535328  x7  7f7f7f7f7f7f7f7f
    x8  0000000000000000  x9  0000000000000001  x10 0000000000000001  x11 0000000000000000
    x12 0000000000000051  x13 00000073f2bc8dc8  x14 0000000000000000  x15 00000000ebad6a89
    x16 00000073f31fef70  x17 00000076fe348f60  x18 000000736abf0000  x19 00000073f2bc8d68
    x20 0000000000000000  x21 0000000000000001  x22 0000000014305aa8  x23 0000000014305a88
    x24 0000003779dc0715  x25 00000073f2bca000  x26 00000000000002c1  x27 0000000000000002
    x28 00000073f2bc8de0  x29 00000073f2bc8d00
    lr  00000073f2de981c  sp  00000073f2bc8cf0  pc  00000073f2de9948  pst 0000000060000000
backtrace:
      #00 pc 000000000011d948  /data/app/~~teoNPxgO3C9Bj7rc77jgYQ==/com.coolfire.flutter.core-ZCcsvQG7FJoNaQk7uDGKAQ==/base.apk!libmapbox-gl.so (offset 0x30e7000) (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7)
      #01 pc 000000000011d818  /data/app/~~teoNPxgO3C9Bj7rc77jgYQ==/com.coolfire.flutter.core-ZCcsvQG7FJoNaQk7uDGKAQ==/base.apk!libmapbox-gl.so (offset 0x30e7000) (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7)
      #02 pc 00000000000adc2c  /data/app/~~teoNPxgO3C9Bj7rc77jgYQ==/com.coolfire.flutter.core-ZCcsvQG7FJoNaQk7uDGKAQ==/base.apk!libmapbox-gl.so (offset 0x30e7000) (BuildId: 5340fab4c92fd87f8304775de4bc95627e863fd7)
      #03 pc 000000000013ced4  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: d0f321775158ed00df284edfabf672b6)
      #04 pc 0000000002087fb4  /memfd:jit-cache (deleted) (offset 0x2000000) (com.mapbox.mapboxsdk.maps.renderer.MapRenderer.onDrawFrame+100)
      #05 pc 0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: d0f321775158ed00df284edfabf672b6)
      #06 pc 00000000001a97e8  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: d0f321775158ed00df284edfabf672b6)
      #07 pc 000000000031c040  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376) (BuildId: d0f321775158ed00df284edfabf672b6)
      #08 pc 0000000000312228  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+912) (BuildId: d0f321775158ed00df284edfabf672b6)
      #09 pc 000000000068647c  /apex/com.android.art/lib64/libart.so (MterpInvokeSuper+1804) (BuildId: d0f321775158ed00df284edfabf672b6)
      #10 pc 000000000012d894  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_super+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #11 pc 00000000003f53c8  [anon:dalvik-classes20.dex extracted in memory from /data/app/~~teoNPxgO3C9Bj7rc77jgYQ==/com.coolfire.flutter.core-ZCcsvQG7FJoNaQk7uDGKAQ==/base.apk!classes20.dex] (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer.onDrawFrame)
      #12 pc 00000000006873a4  /apex/com.android.art/lib64/libart.so (MterpInvokeInterface+1812) (BuildId: d0f321775158ed00df284edfabf672b6)
      #13 pc 000000000012da14  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_interface+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #14 pc 00000000003f5e42  [anon:dalvik-classes20.dex extracted in memory from /data/app/~~teoNPxgO3C9Bj7rc77jgYQ==/com.coolfire.flutter.core-ZCcsvQG7FJoNaQk7uDGKAQ==/base.apk!classes20.dex] (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView$GLThread.guardedRun+994)
      #15 pc 0000000000687fe8  /apex/com.android.art/lib64/libart.so (MterpInvokeDirect+1248) (BuildId: d0f321775158ed00df284edfabf672b6)
      #16 pc 000000000012d914  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_direct+20) (BuildId: d0f321775158ed00df284edfabf672b6)
      #17 pc 00000000003f63c8  [anon:dalvik-classes20.dex extracted in memory from /data/app/~~teoNPxgO3C9Bj7rc77jgYQ==/com.coolfire.flutter.core-ZCcsvQG7FJoNaQk7uDGKAQ==/base.apk!classes20.dex] (com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView$GLThread.run+52)
      #18 pc 00000000003094d0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.7618685802058321727)+264) (BuildId: d0f321775158ed00df284edfabf672b6)
      #19 pc 00000000006740c0  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+776) (BuildId: d0f321775158ed00df284edfabf672b6)
      #20 pc 000000000013cff8  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: d0f321775158ed00df284edfabf672b6)
      #21 pc 0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: d0f321775158ed00df284edfabf672b6)
      #22 pc 00000000001a97e8  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200) (BuildId: d0f321775158ed00df284edfabf672b6)
      #23 pc 000000000055c384  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*)+460) (BuildId: d0f321775158ed00df284edfabf672b6)
      #24 pc 00000000005ac204  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1308) (BuildId: d0f321775158ed00df284edfabf672b6)
      #25 pc 00000000000b0758  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64) (BuildId: c78cdff5b820a550771130d6bde95081)
      #26 pc 0000000000050150  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: c78cdff5b820a550771130d6bde95081)
Lost connection to device.```

[✓] Flutter (Channel stable, 3.3.0, on macOS 12.5.1 21G83 darwin-x64, locale en-US)
    • Flutter version 3.3.0 on channel stable at /Users/bhawkins/FlutterSDK/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ffccd96b62 (20 hours ago), 2022-08-29 17:28:57 -0700
    • Engine revision 5e9e0e0aa8
    • Dart version 2.18.0
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/bhawkins/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • 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.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13F100
    • 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/bhawkins/Desktop/Android Studio Mil.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)

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

[✓] Connected device (3 available)
    • Pixel 2 XL (mobile) • 712KPPB1140192 • android-arm64  • Android 11 (API 30)
    • macOS (desktop)     • macos          • darwin-x64     • macOS 12.5.1 21G83 darwin-x64
    • Chrome (web)        • chrome         • web-javascript • Google Chrome 104.0.5112.101

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

• No issues found!

cfsbhawkins avatar Aug 30 '22 20:08 cfsbhawkins

This issue seems kind of stale. Is the Flutter Team going to resolve the issue any time soon? My company would really like to release their apps without downgrading flutter.

dawid-niedzwiecki avatar Aug 30 '22 20:08 dawid-niedzwiecki

android mapbox is crashing as soon as it is rendered. Some times it takes time to crash happening on 3.3.0 as well

junaidlodhi22 avatar Sep 05 '22 14:09 junaidlodhi22

Also mapbox transparent background is showing black background in android. works fine in iOS

junaidlodhi22 avatar Sep 05 '22 14:09 junaidlodhi22

This issue seems kind of stale. Is the Flutter Team going to resolve the issue any time soon? My company would really like to release their apps without downgrading flutter.

The crash doesn't happen for me when myLocationEnabled is set to false. I haven't implemented this yet, but my plan is to set it to false for Android, and add a custom "my location" marker. E: That being said, the Mapbox examples already have myLocationEnabled set to false (the default), so this doesn't seem to be a complete workaround.

android mapbox is crashing as soon as it is rendered. Some times it takes time to crash happening on 3.3.0 as well

I'm only seeing a crash after popping a MapboxMap from the navigation stack. What Android version and device model are you testing on?

Also mapbox transparent background is showing black background in android. works fine in iOS

This may be a different issue. My custom markers sometimes show completely black on Android emulators. I haven't found anyone who's experienced this on a real device, though.

cohenadair avatar Sep 05 '22 15:09 cohenadair

This issue seems kind of stale. Is the Flutter Team going to resolve the issue any time soon? My company would really like to release their apps without downgrading flutter.

The crash doesn't happen for me when myLocationEnabled is set to false. I haven't implemented this yet, but my plan is to set it to false for Android, and add a custom "my location" marker.

Well, myLocationEnabled is set to false by default.

dawid-niedzwiecki avatar Sep 06 '22 07:09 dawid-niedzwiecki

https://github.com/flutter-mapbox-gl/maps/tree/master/example

I see. Took a quick look at the Mapbox sample and most examples don't set myLocationEnabled at all, so simply setting it to false (for those who had previously set it to true) probably isn't a complete workaround. I will do some more testing.

cohenadair avatar Sep 06 '22 12:09 cohenadair

Some more details from my testing that may or may not be helpful:

  • Testing with the Mapbox example app, crashes seem to be random. There's no sequence of actions that reproduces it every time, and there's no specific map option that triggers the crash.
  • The crash is always delayed after a map is popped from the navigation stack.
  • There are 2 examples that have myLocationEnabled set to true - User Interface, and Layer. Explicitly setting these to false did not fix the crash.
  • In my own app, I can load a MapboxMap as the main widget of bottom navigation without seeing a crash.
  • In my own app, I can push a new MapboxMap onto the navigation stack without seeing a crash; I only see a crash after popping the stack.
  • In my own app (and several people on the Mapbox repo. issue) no longer see the crash when myLocationEnabled is false.

cohenadair avatar Sep 06 '22 13:09 cohenadair

If it's happening on 3.3, then the double-create issue I fixed was apparently unrelated, so un-assigning.

@AAverin Have you tried switching to initExpensiveAndroidView as suggested here?

(Since the crash here is in Mapbox code that we can't see, on a thread created by Mapbox, our ability to debug this from the Flutter side is extremely limited. If initExpensiveAndroidView doesn't resolve it, the next step would be to bisect to the specific change that caused it.)

stuartmorgan avatar Sep 06 '22 13:09 stuartmorgan

@stuartmorgan I have experimented with different kinds of the ways plugin view can be created while trying to fix the other issue with distortion. Applying initExpensiveAndroidView was causing significant slowdown of the plugin, as far as I remember. Original branch where I have tried this is still there: https://github.com/flutter-mapbox-gl/maps/tree/fix-flutter-3

AAverin avatar Sep 06 '22 13:09 AAverin