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

[image_picker] losing connection with device #48016

Closed
maheshmnj opened this issue Dec 31, 2019 · 167 comments
Closed

[image_picker] losing connection with device #48016

maheshmnj opened this issue Dec 31, 2019 · 167 comments
Labels
c: crash Stack traces logged to the console c: fatal crash Crashes that terminate the process customer: crowd Affects or could affect many people, though not necessarily a specific customer. e: device-specific Only manifests on certain devices e: OS-version specific Affects only some versions of the relevant operating system found in release: 1.22 Found to occur in 1.22 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: image_picker The Image Picker plugin. P1 High-priority issues at the top of the work list package flutter/packages repository. See also p: labels. platform-android Android applications specifically r: invalid Issue is closed as not valid

Comments

@maheshmnj
Copy link
Member

maheshmnj commented Dec 31, 2019

I am trying to use image_picker^0.6.1+11 to capture images from camera as the source it works fine for the first time but when I try to retake the image the app crashes with a log lost connection to the device without any exception or error.
UseCase: I want to capture three images from camera and view them in an imageview.
I have tested the app on the latest flutter master and stable channels but has same issue here's my flutter doctor -v output

[✓] Flutter (Channel master, v1.13.4-pre.12, on Mac OS X 10.14.6 18G1012, locale en-IN)
    • Flutter version 1.13.4-pre.12 at /Users/almac03/Documents/flutter
    • Framework revision cc1c9649c4 (11 days ago), 2019-12-19 19:53:01 -0800
    • Engine revision 472197a8e9
    • Dart version 2.8.0 (build 2.8.0-dev.0.0 8d11c1dce6)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/almac03/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.0, Build version 11A420a
    • CocoaPods version 1.7.5

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 42.0.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

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

[✓] Connected device (1 available)
    • Redmi 6A • be0f68897d2a • android-arm • Android 8.1.0 (API 27)

• No issues found!

Steps to Reproduce

pubspec.yaml

camera: ^0.5.6+3
path: ^1.6.4
image_picker: ^0.6.1+11
path_provider: ^1.5.1
  1. example from image_picker:https://pub.dev/packages/image_picker
  2. capture a image
  3. re capture the image
    it crashes

Logs

V/PhoneWindow( 7827): DecorView setVisiblity: visibility = 0, Parent = ViewRoot{9cbda4f com.altorumleren.app_amc_design/com.altorumleren.app_amc_design.MainActivity,ident = 0}, this = DecorView@6a35dc[MainActivity]
D/Surface ( 7827): Surface::disconnect(this=0x9394f000,api=1)
D/GraphicBuffer( 7827): unregister, handle(0x924fd0c0) (w:720 h:1344 s:736 f:0x1 u:b00)
D/GraphicBuffer( 7827): unregister, handle(0x8ae40440) (w:720 h:1344 s:736 f:0x1 u:b00)
D/GraphicBuffer( 7827): unregister, handle(0x8ae3fa80) (w:720 h:1344 s:736 f:0x1 u:b00)
D/Surface ( 7827): Surface::disconnect(this=0x9394f000,api=-1)
D/Surface ( 7827): Surface::disconnect(this=0x9394e800,api=1)
D/GraphicBuffer( 7827): unregister, handle(0x91bf9bc0) (w:720 h:1440 s:736 f:0x1 u:b00)
D/GraphicBuffer( 7827): unregister, handle(0x91bf9d40) (w:720 h:1440 s:736 f:0x1 u:b00)
D/GraphicBuffer( 7827): unregister, handle(0x8bac1900) (w:720 h:1440 s:736 f:0x1 u:b00)
V/PhoneWindow( 7827): DecorView setVisiblity: visibility = 4, Parent = ViewRoot{9cbda4f com.altorumleren.app_amc_design/com.altorumleren.app_amc_design.MainActivity,ident = 0}, this = DecorView@6a35dc[MainActivity]
V/PhoneWindow( 7827): DecorView setVisiblity: visibility = 0, Parent = ViewRoot{9cbda4f com.altorumleren.app_amc_design/com.altorumleren.app_amc_design.MainActivity,ident = 0}, this = DecorView@6a35dc[MainActivity]
I/OpenGLRenderer( 7827): Initialized EGL, version 1.4
D/OpenGLRenderer( 7827): Swap behavior 2
D/HWUIExtension( 7827): MTKProgramCache.init: enable enhancement 1
I/HWUIExtension( 7827): Already had program atlas...
D/HWUIExtension( 7827): Initializing program cache from 0x0, size = -1
D/Surface ( 7827): Surface::connect(this=0x9394f000,api=1)
D/Surface ( 7827): Surface::connect(this=0x9394e800,api=1)
D/GraphicBuffer( 7827): register, handle(0xa1332cc0) (w:720 h:1344 s:736 f:0x1 u:b00)
D/GraphicBuffer( 7827): register, handle(0x8bac1900) (w:720 h:1440 s:736 f:0x1 u:b00)
D/HWUIExtension( 7827): MTKProgramCache.generateProgram: 0
D/HWUIExtension( 7827): createProgram 0x0000000000000000, binary 0xa0de6000, length 10736, format 37168 within 667ns
D/HWUIExtension( 7827): MTKProgramCache.generateProgram: 34359738368
D/HWUIExtension( 7827): createProgram 0x0000000800000000, binary 0xa0e24467, length 10736, format 37168 within 536ns
D/skia    ( 7827): SkJpegCodec::onGetPixels + (1936, 1936)
D/skia    ( 7827): SkJpegCodec::onGetPixels -
W/ExifInterface( 7827): Skip the tag entry since tag number is not defined: 544
W/ExifInterface( 7827): Skip the tag entry since tag number is not defined: 545
W/ExifInterface( 7827): Skip the tag entry since tag number is not defined: 546
W/ExifInterface( 7827): Skip the tag entry since tag number is not defined: 547
W/ExifInterface( 7827): Skip the tag entry since tag number is not defined: 548
W/ExifInterface( 7827): Skip the tag entry since tag number is not defined: 549
W/ExifInterface( 7827): Skip the tag entry since tag number is not defined: 39321
W/ExifInterface( 7827): Skip the tag entry since tag number is not defined: 34953
W/ExifInterface( 7827): Skip the tag entry since tag number is not defined: 2
D/GraphicBuffer( 7827): register, handle(0x924fe380) (w:720 h:1344 s:736 f:0x1 u:b00)
D/GraphicBuffer( 7827): register, handle(0x924ffb80) (w:720 h:1344 s:736 f:0x1 u:b00)
D/Surface ( 7827): Surface::disconnect(this=0x9394f000,api=1)
D/GraphicBuffer( 7827): unregister, handle(0xa1334f40) (w:720 h:1344 s:736 f:0x1 u:b00)
D/GraphicBuffer( 7827): unregister, handle(0x924ffa00) (w:720 h:1344 s:736 f:0x1 u:b00)
D/GraphicBuffer( 7827): unregister, handle(0x924fff40) (w:720 h:1344 s:736 f:0x1 u:b00)
D/Surface ( 7827): Surface::disconnect(this=0x9394f000,api=-1)
D/Surface ( 7827): Surface::disconnect(this=0x9394e800,api=1)
D/GraphicBuffer( 7827): unregister, handle(0x91bf9d40) (w:720 h:1440 s:736 f:0x1 u:b00)
V/PhoneWindow( 7827): DecorView setVisiblity: visibility = 4, Parent = ViewRoot{9cbda4f com.altorumleren.app_amc_design/com.altorumleren.app_amc_design.MainActivity,ident = 0}, this = DecorView@6a35dc[MainActivity]
Lost connection to device.
@VladyslavBondarenko
Copy link

Hi @maheshmnj
Try to use the latest version of image_picker and camera.
Are you still experiencing with this issue?
Thank you

@VladyslavBondarenko VladyslavBondarenko added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 31, 2019
@maheshmnj
Copy link
Member Author

maheshmnj commented Jan 1, 2020

thanks for that info I tried it on an android as well as ios device,it works without a problem with the latest version of the image picker. 0.6.2+3

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 1, 2020
@akshaybenk
Copy link

This issue still persists in
image_picker: ^0.6.2+1.
The image_picker crashes and the app goes back to the previous screen.
I tried it on redmi 6A and realme 3 pro android devices.

This is frustrating as it is an important feature for an app.

@maheshmnj
Copy link
Member Author

maheshmnj commented Jan 1, 2020

This issue still persists in
image_picker: ^0.6.2+1.
The image_picker crashes and the app goes back to the previous screen.
I tried it on redmi 6A and realme 3 pro android devices.

This is frustrating as it is an important feature for an app.

Can you try with v0.6.2+3 I tried it, it seems to work pretty well on Android, Also I have tested on Redmi 6a and I saw it seemed to loose connection sometimes but when I ran a release version of the app it worked without any problem, I could click images multiple times and it worked well.

@akshaybenk
Copy link

akshaybenk commented Jan 2, 2020

Hey @maheshmnj,
Thank you for your kind response.
The problem I am facing is, I have checked with 0.6.2+3 on the test devices(mi4w and miA2 and iPhone 6s).
Everything is working perfectly on these devices.
Even the previous versions of the plugin were working perfectly on the test devices.
When I checked with client devices, I found it was crashing for 0.6.2+1.

If I release an update for the app with the latest version of the plugin, I am not sure how will it work on redmi6a and realme 3 pro. Because these were the client's device running the release apk.It would be a huge problem if it fails to work as releasing frequent updates becomes frustrating for clients to keep on updating the app.

I checked 0.6.2+3 on 1gb ram device (to see if low ram is the issue), it worked smoothly.

try{ var image = await ImagePicker.pickImage( imageQuality: 90, source: ImageSource.camera, ); debugPrint('Image size : ${image.lengthSync()}'); imageFiles.add(image); setState(() {}); } catch(e){ debugPrint('image-picker-error ${e.toString()}'); }

The above code stores clicked images in a list.
Please correct me if the code is wrong.

@iapicca iapicca added e: device-specific Only manifests on certain devices p: first party p: image_picker The Image Picker plugin. c: crash Stack traces logged to the console labels Jan 2, 2020
@iapicca iapicca changed the title Flutter image_picker losing connection to device when captured image for the second time. [image_picker] [xiaomi] losing connection with device Jan 2, 2020
@billymahmood
Copy link

billymahmood commented Jan 7, 2020

Hey,

I am having the same issue on Android, after I click the tick on Camera to accept the picture, the App crashes with no errors

Device:
Google Pixel 3a

OS Version:
Android 10

Plugin version:
image_picker: ^0.6.2+3
camera: ^0.5.7+2

Code:
var image = await ImagePicker.pickImage( imageQuality: 90, source: ImageSource.camera, );

@maheshmnj
Copy link
Member Author

maheshmnj commented Jan 7, 2020

I am using the latest image picker plugin it works well .is there any specific reason to use the camera plugin?if not, Can you try removing the camera plugin from pubspec.yaml

Hey,

I am having the same issue on Android, after I click the tick on Camera to accept the picture, the App crashes with no errors

Device:
Google Pixel 3a

OS Version:
Android 10

Plugin version:
image_picker: ^0.6.2+3
camera: ^0.5.7+2

Code:
var image = await ImagePicker.pickImage( imageQuality: 90, source: ImageSource.camera, );

@OliverNarramore
Copy link

Using Flutter version 1.12.13+hotfix.5, i'm also experiencing issues with the image_picker package.

On Android, if I use the gallery as a source and select an image it works fine. If I use gallery as the source, but select the back button on my device, the app crashes with no logs.

Furthermore, If I use the camera as the source, I can capture and recapture images, but when I select "OK" to confirm the image, the app, again, crashes with no logs.

I'm using the latest image_picker and camera plugin versions.

I have also tried removing the camera plugin from pubspec.yaml, but the behaviour is exactly the same with or without it.

This also crashes on an emulator.

@maheshmnj
Copy link
Member Author

maheshmnj commented Jan 25, 2020

I dont know whats wrong for you but this works well for me on emulator as well as real device on ios and android heres the working demo
Peek 2020-01-25 09-42

image_picker: ^0.6.2+3
Flutter (Channel master, v1.13.6-pre.13, on Linux, locale en_US.UTF-8)
    • Flutter version 1.13.6-pre.13 at /home/al004/flutter_linux_v1.7.8+hotfix.4-stable/flutter
    • Framework revision ef398d9e87 (5 weeks ago), 2019-12-20 18:43:01 -0800
    • Engine revision 33813929e3
    • Dart version 2.8.0 (build 2.8.0-dev.0.0 886615d0f9)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /home/al004/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /home/al004/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Android Studio (version 3.5)
    • Android Studio at /home/al004/android-studio
    • Flutter plugin version 41.1.2
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (3 available)
    • Android SDK built for x86 • emulator-5554 • android-x86    • Android 10 (API 29) (emulator)
    • Chrome                    • chrome        • web-javascript • Google Chrome 78.0.3904.87
    • Web Server                • web-server    • web-javascript • Flutter Tools

@OliverNarramore
Copy link

Whenever I use camera as the source for image picker on Android Q, the device immediately loses connection with no explanation or errors. I can see the camera, take the image but when confirming the image nothing happens. If i select the "X", my app restarts because it had initially crashed opening the camera. This only happens on android. When testing this on a simulator, I get an error stating "Camera Error Can't connect to the camera"

I have attempted flutter pub cache repair, as well as using "flutter clean" multiple times. Does anyone have any suggestions?

image_picker: ^0.6.3+1

[✓] Flutter (Channel stable, v1.12.13+hotfix.7, on Mac OS X 10.15.3 19D76, locale en-GB) • Flutter version 1.12.13+hotfix.7 at /Users/student/flutter • Framework revision 9f5ff2306b (2 weeks ago), 2020-01-26 22:38:26 -0800 • Engine revision a67792536c • Dart version 2.7.0

@Nnnnnnnnnical
Copy link

I have the same problem when I use it in iOS emulator,it will lost the connection with the devices.The image_picker from the lastest 0.6.3+1 to 0.6.0.Only 0.5.4+3 or the older version it works nomal.

@chiragmittal19
Copy link

chiragmittal19 commented Feb 12, 2020

Still losing connection and app restarts every time, not even sometimes.

Device: Redmi 7
OS: Pie(28)
Min SDK: 21
Target SDK: 29
image_picker: ^0.6.3+1

I've tested in Mi A3, Nokia 6.1 Plus and Motorola E5. Works perfectly in those.

@chiragmittal19
Copy link

Still waiting for a solution. This is a severe crash and I've no idea what's going wrong in this particular Xiaomi device.

@OliverNarramore
Copy link

Also occurring still on a One Plus device. Fine on Samsung S10. Wondering if there’s something different for specific device brands.

@hfranco346
Copy link

I am facing this problem now, when i run the app on a virtual device it works fine, but when i run it into my xiaomi device it stop debbugin in vscode and pop to the main activity, i need help

@VladyslavBondarenko VladyslavBondarenko added the customer: crowd Affects or could affect many people, though not necessarily a specific customer. label Mar 20, 2020
@lazyseals
Copy link

Hey I am also facing this issue and app restarts every time, not even sometimes.

Device: Moto g 7 play
OS: Pie
image_picker: ^0.6.4

@rajtri
Copy link

rajtri commented Mar 31, 2020

i am also facing same issue with xiaomi phone.

image_picker: ^0.6.4

@lakshanmamalgaha
Copy link

I also have the same problem. Detaching device when opening image picker.
Device: Google pixel 3
image_picker: ^0.6.4

@rajtri
Copy link

rajtri commented Apr 2, 2020

this issue is in debug mode only, if you build the app in release mode, it works perfectly fine.

@maheshmnj
Copy link
Member Author

This issue still persists in
image_picker: ^0.6.2+1.
The image_picker crashes and the app goes back to the previous screen.
I tried it on redmi 6A and realme 3 pro android devices.
This is frustrating as it is an important feature for an app.

Can you try with 0.6.2+3 I tried it, it seems to work pretty well for Android,Also I have tested on redmi 6a and I saw it seemed to loose connection sometimes but when I ran a release version of the app it worked without any problems I could click images multiple times and it worked well

yes Everyone who is facing this issue please try the release version of the app,for me the debug verison works well too

@phanbaohuy96
Copy link

Hi, any solution to this problem yet? I get a lot of reports of problems selecting images from the camera. Also, Crashlytics can't log where the crash is coming from.

@kari538
Copy link

kari538 commented Jul 20, 2021 via email

@Werisu
Copy link

Werisu commented Jul 21, 2021

I tried putting a <uses-permission android:name="android.permission.CAMERA"> but it didn't work

@maheshmnj
Copy link
Member Author

maheshmnj commented Jul 23, 2021

Is this issue still valid with the latest image_picker: ^0.8.2 ?, I could not reproduce it on k20 Pro, Incase if anyone wants to try here is the sample code with the updated API. https://gist.github.com/maheshmnj/666de97c013a804b8b343966fca0941c

(Note: No configuration is required for Android for image_picker ^0.8.1 and above, meaning you can just add the plugin and try the sample code )

flutter doctor -v
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-arm, locale en-GB)
    • Flutter version 2.2.3 at /Users/mahesh/Documents/flutter
    • Framework revision f4abaa0735 (3 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

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

[✓] Android Studio (version 4.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.8+10-b944.6916264)

[✓] IntelliJ IDEA Community Edition (version 2021.1.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 57.0.5
    • Dart plugin version 211.7233

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

[✓] Connected device (3 available)
    • iPhone 12 Pro Max (mobile) • 6A434744-B348-4FB3-AB10-131292174456 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS
      11.4 20F71 darwin-arm
    • Chrome (web)               • chrome                               • web-javascript • Google
      Chrome 91.0.4472.164

• No issues found!
[✓] Flutter (Channel master, 2.4.0-5.0.pre.166, on macOS 11.4 20F71 darwin-arm, locale en-GB)
    • Flutter version 2.4.0-5.0.pre.166 at /Users/mahesh/Documents/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2dc11a85ff (4 hours ago), 2021-07-22 17:56:03 -0700
    • Engine revision fbbb3b3f7b
    • Dart version 2.14.0 (build 2.14.0-343.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

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

[✓] Android Studio (version 4.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.8+10-b944.6916264)

[✓] IntelliJ IDEA Community Edition (version 2021.1.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 57.0.5
    • Dart plugin version 211.7233

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

[✓] Connected device (4 available)
    • sdk gphone arm64 (mobile)  • emulator-5554                        • android-arm64  • Android 11 (API 30)
      (emulator)
    • iPhone 12 Pro Max (mobile) • 6A434744-B348-4FB3-AB10-131292174456 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 11.4 20F71
      darwin-arm
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome
      91.0.4472.164

• No issues found!

@moaabid
Copy link

moaabid commented Jul 26, 2021

Crashes while taking picture using camera. Is there any other solution ?

Shows - Lost connection to device.

Using latest image_picker: ^0.8.2.

Devices:
Redmi 7A (Android 10)

@kadnan0900
Copy link

kadnan0900 commented Aug 4, 2021

facing same issue while capturing image from camera.
crash_dump.cpp:460] failed to attach to thread 532: Permission denied

WhatsApp Image 2021-08-04 at 12 10 23 PM

@tiagosito
Copy link

Lost connection to device.

@mangei
Copy link

mangei commented Aug 8, 2021

maybe related #87896

@MatheusFelix17
Copy link

Hello everyone! After countless fails with "lost connection with device" while trying to pick an image from gallery, I found a plugin which met my demands: "photo_manager" plugin, alone, or used also here: https://pub.dev/packages/wechat_assets_picker

Although it does not directly load the gallery and you pick from it and it goes back to the app, in this case the plugin loads the images of your device as assets, and you can access any image from any folder, and you can choose how to display those images, like a grid view "emulating" your gallery.

I hope it helps you as it helped me! :D

@Vaytrex
Copy link

Vaytrex commented Aug 13, 2021

Device: Xiaomi A2 lite (Android One device)

Step to reproduce: Image picker pick multiple image then app crashed (losing connection with device)
image_picker version: 0.8.3+2

@OlaleyeJumoke
Copy link

Using the image_picker with image_cropper sorted the issue for me. I can't really explain it, but it did sort it for me.

@carman247
Copy link

carman247 commented Oct 18, 2021

Using the image_picker with image_cropper sorted the issue for me. I can't really explain it, but it did sort it for me.

@OlaleyeJumoke Can you try to explain?

@carman247
Copy link

Can't find a way to fix this in my app. Will have to use the camera plugin for now, which is a shame.

@agiletechie
Copy link

Still crashes and shows blank screen sometimes. Works fine on emulator though.
Using latest image_picker: ^0.8.4+4

@mothattack
Copy link

almost 2 years and many updates later, and this is still broken on a physical android device. I'm over it

@Abhijithsp

This comment has been minimized.

@maheshmnj maheshmnj added the platform-android Android applications specifically label Nov 12, 2021
@oodavid
Copy link

oodavid commented Nov 12, 2021

@Abhijithsp we've had very similar reports. Our solution has been to bundle different camera modules into the app and let the user try different plugins via a settings screen. It's been needlessly troublesome - especially since the camera package forces 16:9 aspect ratio - #80393 #15953 and #45665. Essentially, we're letting our users choose between image_picker (unstable and correct images) or camera (more stable, but incorrect images)

@stuartmorgan
Copy link
Contributor

This is not something that can be fixed in the plugin; it is not technically a bug, although I understand the frustration with the effect it has on the experience. The reason that there aren't any logs or crash reports is that the app isn't crashing, it's being terminated by the OS to free memory, because while the image picker activity is active the Flutter application is technically a background app, and thus subject to collection by the OS when there is memory pressure.

  • For end users, the solution is to implement state restoration in your application, and to use these instructions from the plugin README to get the results of the image picker activity during restoration.
  • For the flutter run workflow, I don't see a solution other than re-attaching to the restored application on completion.

The only way to avoid this would be to implement a custom, in-application image picker experience from scratch. That's out of scope of this plugin—but is something that interested members of the community could certainly build.

(The reason this is specific to Android is that on iOS the system model is extremely different; instead of providing a standard set of activities for operations like these, the OS provides components that are displayed within the application, so the application that's doing the image selection is in the foreground the entire time. If at some point Android provides a similar component, image_picker could switch to that to resolve this.)

Given that this is, within the constrains of the way Android activities work, not something we can change, I'm going to close this. #93807 tracks improving the README to make this more clear.

Plugin 2021Q2 Hotlist automation moved this from To Do to Done Nov 17, 2021
@oodavid
Copy link

oodavid commented Nov 19, 2021

@stuartmorgan - this is a most excellent insight! Thank you

Do you have any articles we can read about how Android chooses which apps to terminate in the background? ie: does it select those using the most memory? If so, it may mean that we may have an undetected memory leak.

@stuartmorgan
Copy link
Contributor

stuartmorgan commented Nov 19, 2021

Do you have any articles we can read about how Android chooses which apps to terminate in the background? ie: does it select those using the most memory?

Android documentation discusses it at a very high level, but there is (likely by design) not a clearly described set of rules; it's up to the OS to decide when to terminate processes, and which ones.

Given that how recently used the process was is called out as one factor that's likely to be considered, it could very well be the case that on some devices the image picker is using so much memory that all other non-essential processes are killed.

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

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 Dec 3, 2021
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console c: fatal crash Crashes that terminate the process customer: crowd Affects or could affect many people, though not necessarily a specific customer. e: device-specific Only manifests on certain devices e: OS-version specific Affects only some versions of the relevant operating system found in release: 1.22 Found to occur in 1.22 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: image_picker The Image Picker plugin. P1 High-priority issues at the top of the work list package flutter/packages repository. See also p: labels. platform-android Android applications specifically r: invalid Issue is closed as not valid
Development

No branches or pull requests