I make a drawing application, on debug version everything works fine, but on the release, sometimes the crash happens, e.g there're a lot of objects on my drawing, I try to save it over 10 times, it happens.
I tried to remove the R8, R8 cause crashes in release mode. But that doesn't help.
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'Redmi/joyeuse_global/joyeuse:10/QKQ1.176215.002/V11.0.1.0.QJHFSM:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2020-08-12 21:28:34+0700
pid: 6718, tid: 6746, name: 1.ui >>> app.thinkso.drawing <<<
uid: 10349
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
x0 00000071e4e980a8 x1 000000727277d4a0 x2 000000007fffffff x3 0000000000000000
x4 0000000000000000 x5 0000000000000000 x6 0000000000000000 x7 00000000035810cc
x8 0000007189118000 x9 0000000000000000 x10 0000000000000001 x11 0000000000000000
x12 0000004b7427ccee x13 0000000000000000 x14 0000000000000058 x15 0000004b7419d1bb
x16 000000718903b1d8 x17 000000727277e1c0 x18 000000714b08ec94 x19 00000071e4ec8c00
x20 0000000000000000 x21 0000007189022440 x22 0000007189022460 x23 00000071607ba9a0
x24 0000000000b65268 x25 00000071e5337000 x26 00000071e4ec8c00 x27 0000007177b87ec0
x28 0000000000000004 x29 00000071e540fc60
sp 00000071e540fae0 lr 0000007188fa7574 pc 0000007188fa75f0
backtrace:
#00 pc 00000000006dd5f0 /data/app/app.thinkso.drawing-NAbHYAhOoz5NExIv1BSPPQ==/lib/arm64/libflutter.so (BuildId: b57a4557f090fa1289c835f596bfba88439338c8)
#01 pc 000000000072219c [anon:libc_malloc]
flutter doctor -v
Flutter (Channel stable, 1.20.1, on Mac OS X 10.15.2 19C57, locale en-US)
• Flutter version 1.20.1 at /Users/magicman/Workspace/flutter
• Framework revision 2ae34518b8 (7 days ago), 2020-08-05 19:53:19 -0700
• Engine revision c8e3b94853
• Dart version 2.9.0
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at /Users/magicman/Library/Android/sdk
• Platform android-29, build-tools 30.0.1
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.6, Build version 11E708
• CocoaPods version 1.9.3
[!] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.47.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.13.2
[✓] Connected device (1 available)
• Redmi Note 9 Pro (mobile) • 279538ee • android-arm64 • Android 10 (API 29)
</details>
waiting for customer response
The Flutter team cannot make further progress on this issue until the original reporter responds
labels
Aug 13, 2020
Hi @darshankawar , actually it's huge work to reproduce, in general I use a canvas to draw an image. Then exporting canvas to Picture to save to temp location, then share image with new Intent.
ui.Picture getPicture()
final recorder = ui.PictureRecorder();
final cullRect = Offset.zero & dimension;
Canvas canvas = Canvas(recorder, cullRect);
canvas.drawImage(drawing.image, Offset.zero, Paint());
_drawShapes(canvas);
return recorder.endRecording();
picture.toImage(width, height).then((image) {
image.toByteData().then((bytes) {
final rawImage = RawImageHolder(bytes: bytes.buffer.asUint8List(), width: width, height: height);
completer.complete(rawImage);
then using this picture, save as an image then write image to the storage
// save to uri here
val share = Intent(Intent.ACTION_SEND)
share.type = "image/jpeg"
share.flags = Intent.FLAG_ACTIVITY_NEW_TASK
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
share.putExtra(Intent.EXTRA_STREAM, uri)
context.startActivity(share)
resultHandler.reply(true)
I tested on the the image ONLY, no drawing object
With the image ~ 500KB, after 1-20 times
With the image ~ 1.5 - 2MB, after 1-10 times
With the image >= 4MB, after 1-4 times
Crashes have no rule but randomly. The BIG QUESTION is why it doesn't happen during debug?
Is there a way to see the stack trace or something?
If I remember correctly in the old versions ( older than 1.17.x) I didn't have so much crashes
waiting for customer response
The Flutter team cannot make further progress on this issue until the original reporter responds
label
Aug 13, 2020
OK after multiple isolate code and tests again and again, I definitely point out the problem is PictureRecorder, currently I use this to export the canvas to image, but after call this sometime (1 or more), it is going to crash, especially on big image.
But why does this not going to happen on debug?
waiting for customer response
The Flutter team cannot make further progress on this issue until the original reporter responds
label
Aug 14, 2020
Hi @darshankawar , below is the repo contains crash sample. It's very simple, there's only 1 dart file and 1 big image
You only need to press floating button to run the export one or more times and enjoy the crash (I tested on release mode/ Android 6GB RAM). I didn't test on iPhone yet.
Hope you will fix it soon, I love the good news 👍
Sample repo
waiting for customer response
The Flutter team cannot make further progress on this issue until the original reporter responds
label
Aug 15, 2020
More info: another crash error
Test device Huawei Android 5.0 (SDK 21), ram 2,048 MB
08-16 22:00:28.422: I/DEBUG(2326): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
08-16 22:00:28.422: I/DEBUG(2326): Build fingerprint: 'Huawei/ALE-L23/hwALE-H:5.0.1/HuaweiALE-L23/C605B150:user/release-keys'
08-16 22:00:28.422: I/DEBUG(2326): Revision: '0'
08-16 22:00:28.422: I/DEBUG(2326): ABI: 'arm64'
08-16 22:00:28.422: I/DEBUG(2326): pid: 20248, tid: 20383, name: Thread-1081 >>> app.thinkso.drawing <<<
08-16 22:00:28.422: I/DEBUG(2326): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7
08-16 22:00:28.452: I/art(26646): Can not find class: Lhuawei/android/view/LinearLayout;
08-16 22:00:28.452: I/art(26646): Can not find class: Lhuawei/android/widget/LinearLayout;
08-16 22:00:28.452: I/DEBUG(2326): x0 0000000000000000 x1 0000000000000001 x2 ffffffffffffffff x3 0000000000000000
08-16 22:00:28.452: I/DEBUG(2326): x4 fffffffffffffeb0 x5 0000000000000000 x6 0000000000000000 x7 0000000000000001
08-16 22:00:28.452: I/DEBUG(2326): x8 0000000000000000 x9 0000000000000000 x10 0000000000000000 x11 0000000000000000
08-16 22:00:28.452: I/DEBUG(2326): x12 0000000000000001 x13 0000000000000000 x14 0000000000000000 x15 0000000000000000
08-16 22:00:28.452: I/DEBUG(2326): x16 0000000000000001 x17 0000000000000000 x18 0000000000000000 x19 0000000000000001
08-16 22:00:28.452: I/DEBUG(2326): x20 0000000000000150 x21 0000007fac075000 x22 0000007fac076000 x23 0000000000000001
08-16 22:00:28.452: I/DEBUG(2326): x24 0000007fac075e20 x25 ffffffffffffffff x26 0000000000000113 x27 0000000000000110
08-16 22:00:28.452: I/DEBUG(2326): x28 0000000012fda790 x29 0000007f94be62f0 x30 ffffffffffffffc0
08-16 22:00:28.452: I/DEBUG(2326): sp 0000007f94be62f0 pc 0000007fac013984 pstate 0000000020000000
08-16 22:00:28.452: I/DEBUG(2326): backtrace:
08-16 22:00:28.462: I/DEBUG(2326): #00 pc 0000000000040984 /system/lib64/libc.so (dlmalloc+2212)
08-16 22:00:28.462: I/DEBUG(2326): #01 pc 000000000001772c /system/lib64/libc.so (malloc+20)
08-16 22:00:28.462: I/DEBUG(2326): #02 pc 00000000001404b8 /system/lib64/libicui18n.so (icu_53::RegexPattern::matcher(UErrorCode&) const+52)
08-16 22:00:28.462: I/DEBUG(2326): #03 pc 00000000000271fc /system/lib64/libjavacore.so
08-16 22:00:28.462: I/DEBUG(2326): #04 pc 000000000010a378 /data/dalvik-cache/arm64/system@[email protected]
08-16 22:00:28.462: I/art(26646): Can not find class: Lhuawei/android/view/FrameLayout;
08-16 22:00:28.462: I/art(26646): Can not find class: Lhuawei/android/widget/FrameLayout;
Hi @skquo,
Thanks for the repo. Since I don't have Huawei device or other device with Android 5, I am wondering if it's only happening on specific device and OS versions. Can you check the same on Android 8 or on any other device to see if it still crashes?
Thanks.
waiting for customer response
The Flutter team cannot make further progress on this issue until the original reporter responds
label
Aug 17, 2020
waiting for customer response
The Flutter team cannot make further progress on this issue until the original reporter responds
label
Aug 17, 2020
Make images contribute to Picture allocation size, more aggressively release references when dispose is called
flutter/engine#18706
Issue seem to be replicable on debug as well, since the app closes down after hitting the FAB few times which does the action of exporting the image and then completing it. Although, there's no log, but app just shuts down and prints a message in console lost connection to device
.
Tested on latest Stable (1.20.2). Here's the log:
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Waiting for SM A260G to report its views...
Debug service listening on ws://127.0.0.1:51760/L3GX8Jzmih4=/ws
Syncing files to device SM A260G...
I/flutter (31682): Loading image
I/flutter (31682): Load image completed 11317044 bytes
I/OpenGLRenderer(31682): Initialized EGL, version 1.4
D/OpenGLRenderer(31682): Swap behavior 2
D/mali_winsys(31682): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000, [540x960]-format:1
D/mali_winsys(31682): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000, [540x888]-format:1
I/flutter (31682): Export image
I/flutter (31682): Export completed!
I/flutter (31682): Export image
I/flutter (31682): Export completed!
I/flutter (31682): Export image
I/flutter (31682): Export completed!
I/flutter (31682): Export image
I/flutter (31682): Export completed!
I/zygote (31682): Do partial code cache collection, code=29KB, data=29KB
I/zygote (31682): After code cache collection, code=29KB, data=29KB
I/zygote (31682): Increasing code cache capacity to 128KB
I/flutter (31682): Export image
I/flutter (31682): Export completed!
I/flutter (31682): Export image
I/flutter (31682): Export completed!
I/flutter (31682): Export image
Lost connection to device.
flutter doctor -v
Flutter 1.20.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision bbfbf1770c (15 hours ago) • 2020-08-13 08:33:09 -0700
Engine • revision 9d5b21729f
Tools • Dart 2.9.1
Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.20.2, on Mac OS X 10.15.2 19C57, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions.
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
[✓] Android Studio (version 3.6)
[✓] Connected device (1 available)
! Doctor found issues in 1 category.
Unfortunately, this is only available on master right now. It should be available in the next dev release, which should happen "soon" :)
Otherwise, you'll have to wait for a hot fix.