Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flutter 3] Null pointer dereference in libmapbox-gl.so #107297

Closed
AAverin opened this issue Jul 8, 2022 · 93 comments · Fixed by flutter/engine#43423
Closed

[Flutter 3] Null pointer dereference in libmapbox-gl.so #107297

AAverin opened this issue Jul 8, 2022 · 93 comments · Fixed by flutter/engine#43423
Assignees
Labels
a: platform-views Embedding Android/iOS views in Flutter apps c: crash Stack traces logged to the console c: regression It was better in the past than it is now engine flutter/engine repository. See also e: labels. P2 Important issues not at the top of the work list platform-android Android applications specifically

Comments

@AAverin
Copy link

AAverin commented Jul 8, 2022

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!

@huycozy huycozy added the in triage Presently being triaged by the triage team label Jul 11, 2022
@huycozy
Copy link
Member

huycozy commented Jul 11, 2022

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
Screen.Recording.2022-07-11.at.10.31.19.mp4
Screen.Recording.2022-07-11.at.10.38.22.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 huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 11, 2022
@AAverin
Copy link
Author

AAverin commented Jul 14, 2022

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 #103630 being fixed there.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 14, 2022
@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 14, 2022
@AAverin
Copy link
Author

AAverin commented Jul 14, 2022

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.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 14, 2022
@AAverin
Copy link
Author

AAverin commented Jul 14, 2022

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.

@huycozy
Copy link
Member

huycozy commented Jul 15, 2022

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 huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 15, 2022
@AAverin
Copy link
Author

AAverin commented Jul 16, 2022

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

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 16, 2022
@huycozy
Copy link
Member

huycozy commented Jul 18, 2022

@flutter-symbolizer-bot #107297 (comment) flutter#v3.1.0-0.0.pre.1542 debug arm64

@flutter-symbolizer-bot
Copy link

crash from #107297 (comment) 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)

@huycozy
Copy link
Member

huycozy commented Jul 18, 2022

@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
Screen.Recording.2022-07-18.at.09.36.01.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 huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 18, 2022
@AAverin
Copy link
Author

AAverin commented Jul 22, 2022

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.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 22, 2022
@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 22, 2022
@Szymon3125
Copy link

Szymon3125 commented Jul 22, 2022

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!

@dawid-niedzwiecki
Copy link

Same issue here, also with mapbox :/

@piotrkovsy1331
Copy link

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.

@AAverin
Copy link
Author

AAverin commented Jul 25, 2022

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?

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 25, 2022
@cfsbhawkins
Copy link

Any possibility it's related to what was stated here?
#103630 (comment)

@huycozy
Copy link
Member

huycozy commented Jul 25, 2022

Hi @AAverin and anyone else facing this issue, there is a new beta release: 3.3.0 (also see #103630 (comment)). Could you retry the issue on the latest beta to see if the issue still reproduces?

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 25, 2022
@AAverin
Copy link
Author

AAverin commented Jul 27, 2022

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?

@stuartmorgan
Copy link
Contributor

stuartmorgan commented Jan 24, 2023

For anyone interested in making progress on this issue, the most useful next step would be to bisect versions of Flutter master to figure out what the exact build that started failing is. That would give us an indication of what exactly changed that might have triggered a latent race condition in libmapbox-gl, and from there whether there's a feasible workaround that could be made either in Flutter or in the plugin.

This doesn't require any specific expertise, just a reproduction case and some time to devote to trying lots of builds.

@srmncnk
Copy link

srmncnk commented Jan 24, 2023

There's also this workaround, use at your own risk: flutter-mapbox-gl/maps#1172

@novriamsyah
Copy link

same issue, try mapbox_gl_modified new package. work for me

@Shiba-Kar
Copy link

@JulianBissekkou
Copy link

@stuartmorgan
We worked on a minimal reproducable example that uses maplibre (which is an early for of mapbox) and it has the exact same problem.

Flutter version Worked?
2.10.5
3.10.0
3.10.2
3.10.5
master (Flutter 3.9.0-20.0.pre.59 - revision 63e3048)

You can see our example in this repository:
https://github.com/tappeddev/tapped_maplibre_flutter

I created multiple branches for the different flutter verisons:
flutter-2.10.5
flutter-3.10.5
flutter-master

Steps to reproduce the crash:

  • Run example app
  • Click on the button "run simple"
  • Close the page immediatly after it was pushed (sometimes even before the map was fully loaded)
  • Repeat this process a few times and it should crash

We did the exact same with the native android example app (can be found in the maplibre-gl-native repo) and we didn't see any problems.

@JulianBissekkou
Copy link

I did a bisect of all the commits between 2.10.5 and 3.10.0:

This commit was the "bad" one:

d1c11213493c4dd1add018dd26b6238ad40efb41 is the first bad commit
commit d1c11213493c4dd1add018dd26b6238ad40efb41
Author: engine-flutter-autoroll <[email protected]>
Date:   Sat Mar 19 15:30:22 2022 -0400

    Roll Engine from 8403d67febdf to 8dc7cd1b1a33 (1 revision) (#100425)

 bin/internal/engine.version | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Which corresponds to this engine commit:
flutter/engine@8dc7cd1

@JulianBissekkou
Copy link

@johnmccutchan I see that you assigned yourself to the issue.
If you start working on it then please also take my latest workaround into consideration.
For this check the PR in maplibre/flutter-maplibre-gl#259

@johnmccutchan
Copy link
Contributor

Thanks @JulianBissekkou for finding the root cause commit to the engine repository. I will look into this next.

@johnmccutchan
Copy link
Contributor

Thank you for the reproduction, I am able to get it to crash.

@fatihmerickoc
Copy link

So whats the final decision? Should i migrate to a new dependencies like mapbox_maps_flutter?
Its really annoying to get errors when you are tring to build an MVP for your Startup

@JulianBissekkou
Copy link

@fatihmerickoc
That really depends on your personal situation. If you need a working app right now, then you have to go with mapbox_maps_flutter as its the most stable right now.
If you can't use mapbox for any reason, feel free to try out maplibre and use the branch maplibre/flutter-maplibre-gl#259 where I implemented a workaround that should fix the problem until @johnmccutchan came up with his findings.

@AAverin
Copy link
Author

AAverin commented Jul 4, 2023

https://github.com/flutter-mapbox-gl/maps already has the fix implemented too (flutter-mapbox-gl/maps#1293).
@fatihmerickoc If you are invested into Mapbox ecosystem, then migration to the new official mapbox_maps_flutter makes sense, although I still didn't see any development roadmaps for it.
If you are not in the Mapbox ecosystem or don't have to be – use Maplibre, all of the fixes from old community-driven Mapbox plugin are migrated to Maplibre plugin too, they are essentially the same from the flutter perspective, only underlying native libraries are different.

JulianBissekkou added a commit to maplibre/flutter-maplibre-gl that referenced this issue Jul 4, 2023
This PR should fix the crash as described in #182  and #257 
The status is still in draft because I would like to get feedback from
android devs of maplibre-gl-native.

### Problem
The crash started to occure with flutter 3.x and after some
investigations we were able to detect the exact change that broke it.
See flutter/flutter#107297 or
flutter/flutter#107297 (comment)
for details.

The engine change in
flutter/engine@8dc7cd1
is not calling `removeView` in all cases which might be the reason why
this issue is happening.
I digged into the framework and saw that `removeView` will trigger
`onDetachedFromWindow` in the subviews. This is important since once of
the subviews is `TextureView` which destorys the surface texture:


Here is `TextureView.onDeatachedFromWindowInternal`
```java
    @OverRide
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    protected void onDetachedFromWindowInternal() {
        destroyHardwareLayer();
        releaseSurfaceTexture();
        super.onDetachedFromWindowInternal();
    }
```

My guess: If this is not called we might still draw onto a surface which
triggers the crash.

### The fix
If my assumptions are correct then this should be fixed in the engine
and not in the libraries that need a platform view. You can find the
workaround in this PR. We simply create a view container that calls
`removeView` to trigger the `onDetachedFromWindow`.
We tested this in an example app with success and also in some of our
internal projects.

Please give some feedback if my assumptions are correct. Thanks!

---------

Co-authored-by: Julian Bissekkou <[email protected]>
Co-authored-by: Stefan Schaller <[email protected]>
@johnmccutchan
Copy link
Contributor

I actually have not been able to reproduce the null pointer crash. I keep getting heap corruption in the emulator. Still trying to reproduce.

@johnmccutchan
Copy link
Contributor

I was able to reproduce the null pointer crash:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/sdk_gphone64_arm64/emu64a:13/TE1A.220922.021/9526604:userdebug/dev-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2023-07-05 10:33:42.242032766-0700
Process uptime: 9s
Cmdline: tapped.maplibre.flutter.tapped_maplibre_flutter_example
pid: 3971, tid: 4444, name: Thread-5  >>> tapped.maplibre.flutter.tapped_maplibre_flutter_example <<<
uid: 10163
tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
pac_enabled_keys: 000000000000000f (PR_PAC_APIAKEY, PR_PAC_APIBKEY, PR_PAC_APDAKEY, PR_PAC_APDBKEY)
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000000
Cause: null pointer dereference
    x0  0000000000000000  x1  0000000000000000  x2  0000000000000001  x3  0000006e50cc5a1f
    x4  0000006db067b4e0  x5  000000000000004a  x6  ff284900ff302349  x7  7f7f7f7f7f7f7f7f
    x8  0000000000000000  x9  0000006db067c040  x10 0000000000000001  x11 0000000000000001
    x12 0000000000000050  x13 0000006db067b4b8  x14 0000000000080100  x15 00000000ebad6a89
    x16 0000006db95b9e40  x17 00000070e9dd6fb4  x18 0000006db03e0000  x19 0000006db067b528
    x20 0000000000000000  x21 0000000000000001  x22 0000006db95c4060  x23 0000000000000001
    x24 b400006f642377b0  x25 0000006db067b6d0  x26 0000006db067b700  x27 0000006db067b6d0
    x28 0000006db067b5d0  x29 0000006db067b4c0
    lr  0000006db919fdc8  sp  0000006db067b4c0  pc  0000006db919fe3c  pst 0000000060001000
backtrace:
      #00 pc 0000000000557e3c  /data/app/~~L1HfoMB8nwMsPGhoS2LF3w==/tapped.maplibre.flutter.tapped_maplibre_flutter_example-0yyDgdh6L5hEXtDmGyjD-A==/lib/arm64/libmapbox-gl.so (BuildId: 0ca6fcacfa62e5433d32610ec52e8c93ed5b89ae)
      #01 pc 0000000000438cc4  /data/app/~~L1HfoMB8nwMsPGhoS2LF3w==/tapped.maplibre.flutter.tapped_maplibre_flutter_example-0yyDgdh6L5hEXtDmGyjD-A==/lib/arm64/libmapbox-gl.so (mbgl::android::MapRenderer::render(_JNIEnv&)+176) (BuildId: 0ca6fcacfa62e5433d32610ec52e8c93ed5b89ae)
      #02 pc 000000000043b57c  /data/app/~~L1HfoMB8nwMsPGhoS2LF3w==/tapped.maplibre.flutter.tapped_maplibre_flutter_example-0yyDgdh6L5hEXtDmGyjD-A==/lib/arm64/libmapbox-gl.so (auto auto jni::MakeNativeMethod<auto jni::NativeMethodMaker<void (auto jni::NativePeerMemberFunctionMethod<void (mbgl::android::MapRenderer::*)(_JNIEnv&), &(mbgl::android::MapRenderer::render(_JNIEnv&))>::operator()<mbgl::android::MapRenderer, mbgl::android::MapRenderer, void>(jni::Field<mbgl::android::MapRenderer, long> const&)::'lambda'(_JNIEnv&, jni::Object<mbgl::android::MapRenderer>&)::*)(_JNIEnv&, jni::Object<mbgl::android::MapRenderer>&) const>::operator()<auto jni::NativePeerMemberFunctionMethod<void (mbgl::android::MapRenderer::*)(_JNIEnv&), &(mbgl::android::MapRenderer::render(_JNIEnv&))>::operator()<mbgl::android::MapRenderer, mbgl::android::MapRenderer, void>(jni::Field<mbgl::android::MapRenderer, long> const&)::'lambda'(_JNIEnv&, jni::Object<mbgl::android::MapRenderer>&)>(char const*, auto jni::NativePeerMemberFunctionMethod<void (mbgl::android::MapRenderer::*)(_JNIEnv&), &(mbgl::android::MapRenderer::render(_JNIEnv&))>::operator()<mbgl::android::MapRenderer, mbgl::android::MapRenderer, void>(jni::Field<mbgl::android::MapRenderer, long> const&)::'lambda'(_JNIEnv&, jni::Object<mbgl::android::MapRenderer>&) const&)::'lambda'(_JNIEnv*, jni::jobject*)>(char const*, char const*, auto jni::NativePeerMemberFunctionMethod<void (mbgl::android::MapRenderer::*)(_JNIEnv&), &(mbgl::android::MapRenderer::render(_JNIEnv&))>::operator()<mbgl::android::MapRenderer, mbgl::android::MapRenderer, void>(jni::Field<mbgl::android::MapRenderer, long> const&)::'lambda'(_JNIEnv&, jni::Object<mbgl::android::MapRenderer>&) const&, std::__ndk1::enable_if<std::is_class<auto jni::NativePeerMemberFunctionMethod<void (mbgl::android::MapRenderer::*)(_JNIEnv&), &(mbgl::android::MapRenderer::render(_JNIEnv&))>::operator()<mbgl::android::MapRenderer, mbgl::android::MapRenderer, void>(jni::Field<mbgl::android::MapRenderer, long> const&)::'lambda'(_JNIEnv&, jni::Object<mbgl::android::MapRenderer>&)>::value, void>::type*)::'lambda'(_JNIEnv*, auto...)::__invoke<jni::jobject*>(_JNIEnv*, auto...)+44) (BuildId: 0ca6fcacfa62e5433d32610ec52e8c93ed5b89ae)
      #03 pc 0000000000440554  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: e24a1818231cfb1649cb83a5d2869598)
      #04 pc 000000000020a2b0  /apex/com.android.art/lib64/libart.so (nterp_helper+4016) (BuildId: e24a1818231cfb1649cb83a5d2869598)
      #05 pc 000000000032332c  [anon:dalvik-classes.dex extracted in memory from /data/app/~~L1HfoMB8nwMsPGhoS2LF3w==/tapped.maplibre.flutter.tapped_maplibre_flutter_example-0yyDgdh6L5hEXtDmGyjD-A==/base.apk] (com.mapbox.mapboxsdk.maps.renderer.MapRenderer.onDrawFrame+12)
      #06 pc 000000000020a254  /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: e24a1818231cfb1649cb83a5d2869598)
      #07 pc 0000000000326838  [anon:dalvik-classes.dex extracted in memory from /data/app/~~L1HfoMB8nwMsPGhoS2LF3w==/tapped.maplibre.flutter.tapped_maplibre_flutter_example-0yyDgdh6L5hEXtDmGyjD-A==/base.apk] (com.mapbox.mapboxsdk.maps.renderer.textureview.TextureViewMapRenderer.onDrawFrame+0)
      #08 pc 000000000020a254  /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: e24a1818231cfb1649cb83a5d2869598)
      #09 pc 000000000032725e  [anon:dalvik-classes.dex extracted in memory from /data/app/~~L1HfoMB8nwMsPGhoS2LF3w==/tapped.maplibre.flutter.tapped_maplibre_flutter_example-0yyDgdh6L5hEXtDmGyjD-A==/base.apk] (com.mapbox.mapboxsdk.maps.renderer.textureview.TextureViewRenderThread.run+458)
      #10 pc 0000000000436b6c  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+556) (BuildId: e24a1818231cfb1649cb83a5d2869598)
      #11 pc 0000000000468938  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+156) (BuildId: e24a1818231cfb1649cb83a5d2869598)
      #12 pc 0000000000468620  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*)+388) (BuildId: e24a1818231cfb1649cb83a5d2869598)
      #13 pc 0000000000618214  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1668) (BuildId: e24a1818231cfb1649cb83a5d2869598)
      #14 pc 00000000000b63b0  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208) (BuildId: 01331f74b0bb2cb958bdc15282b8ec7b)
      #15 pc 00000000000530b8  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 01331f74b0bb2cb958bdc15282b8ec7b)
Lost connection to device.

@johnmccutchan
Copy link
Contributor

@JulianBissekkou Could you confirm that you don't see the crash with flutter/engine#43423 applied?

johnmccutchan added a commit to flutter/engine that referenced this issue Jul 6, 2023
…43423)

Eagerly remove the PlatformView from the view hierarchy on Android.

Fixes [#107297](flutter/flutter#107297)

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.
@stuartmorgan
Copy link
Contributor

@johnmccutchan Do you know if this addresses the Flutter-side regression in #105965 as well? (There was an underlying bug in Google Maps that has been fixed, but it started happening a lot more in Flutter 3, and the crash has similar characteristics.)

@JulianBissekkou
Copy link

@johnmccutchan
Can you explain how I am able to run the app with the latest engine version that contains your fix?
When will this change be release to beta or stable?

@felix-ht
Copy link

@johnmccutchan Do you know if this addresses the Flutter-side regression in #105965 as well? (There was an underlying bug in Google Maps that has been fixed, but it started happening a lot more in Flutter 3, and the crash has similar characteristics.)

The situation with the mapbox plugin was the same as well. The crash was already happening in old versions, but very rarely.

It's was fixed by disposing the map differently.

@johnmccutchan
Copy link
Contributor

@felix-ht Can you point me at the PR that fixed how the map was disposed in the mapbox plugin? I'd like to read them.

@JulianBissekkou
Copy link

JulianBissekkou commented Jul 11, 2023

@felix-ht
We used the same fix as well, but I didn't fully understand why this was needed and why the map continues to draw after we called destroy.
Do you know why?

@felix-ht
Copy link

@johnmccutchan flutter-mapbox-gl/maps#1293 -> changes to android/src/main/java/com/mapbox/mapboxgl/MapboxMapController.java

I am under the impression that the onStop is faster than the onDestroy, and thus stops the java code from drawing after the android view has already been destroyed. But this is just an assumption as i know nearly nothing about the inner workings of the native java/c++ stack of mapbox.

Here is also a link to the android lib we use in the background:

https://github.com/mapbox/mapbox-gl-native-android/blob/7f03a710afbd714368084e4b514d3880bad11c27/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java

kjlubick pushed a commit to kjlubick/engine that referenced this issue Jul 14, 2023
…lutter#43423)

Eagerly remove the PlatformView from the view hierarchy on Android.

Fixes [#107297](flutter/flutter#107297)

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: platform-views Embedding Android/iOS views in Flutter apps c: crash Stack traces logged to the console c: regression It was better in the past than it is now engine flutter/engine repository. See also e: labels. P2 Important issues not at the top of the work list platform-android Android applications specifically
Projects
None yet
Development

Successfully merging a pull request may close this issue.