You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible at the moment to resize an image without "locking up" the Flutter app UI?
I am using the image_picker plugin to pick an image from the device's Photo Gallery and image.dart lib https://pub.dartlang.org/packages/image to resize the chosen image to a more manageable resolution and then upload it to Firebase Cloud Storage. While the image decoded and then encoded the Flutter UI locks up. Could a chosen image size be generated if passed to .getImage()?
You can try https://docs.flutter.io/flutter/foundation/compute.html
You need to copy the result back to the UI thread to upload to Cloud Storage because as far as I know currently only the UI thread is allowed to access platform channels.
EDIT: Potentially this is a Stack Overflow response
Thanks for the response.
I have this working now! After resizing the image, I write the bytes back to a temporary file, upload it and then delete the temp. It works well most of the time but I am having the odd device crash (iPhone 5s). Is there a good way to debug this?
Some times this error is thrown on the resize
[VERBOSE-2:dart_isolate.cc(713)] Isolate (149972410) 'main.dart:_spawn()' exited with an error
[VERBOSE-2:dart_error.cc(16)] isolate terminated by Isolate.kill
Is there a maximum of isolates that can be called at once? Do we need to clean them up?
@vagrantrobbie I don't think there is a hard limit of isolates, but they take up memory and if you run to many at once you can easily run out of memory.
@urbanmania please add details about the problems.
@urbanmania I never really fixed the problem but with a clean run on the app and no hot reloading the error was infrequent enough for me to be happy.
ImagePicker plugin has a maxWidth property which I utilised
ImagePicker.pickImage(source: ImageSource.gallery, maxWidth: 800.0); and this was enough to fix my problem. FlutterNativeImage looks handy
@vagrantrobbie do you think there is still something the Flutter team needs to do?
The ImagePicker issue you mentioned should better be reported in a new issue.
@zoechi@vagrantrobbie I think this isn't enough since we need to generate the thumbnail for every image in general. Therefore maxWidth property is not enough. I've played around with flutter-native-image for this currently but I think ImagePicker should support this feature itself.
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.
Activity
zoechi commentedon May 14, 2018
You can try https://docs.flutter.io/flutter/foundation/compute.html
You need to copy the result back to the UI thread to upload to Cloud Storage because as far as I know currently only the UI thread is allowed to access platform channels.
vagrantrobbie commentedon May 14, 2018
EDIT: Potentially this is a Stack Overflow response
Thanks for the response.
I have this working now! After resizing the image, I write the bytes back to a temporary file, upload it and then delete the temp. It works well most of the time but I am having the odd device crash (iPhone 5s). Is there a good way to debug this?
Some times this error is thrown on the resize
[VERBOSE-2:dart_isolate.cc(713)] Isolate (149972410) 'main.dart:_spawn()' exited with an error
[VERBOSE-2:dart_error.cc(16)] isolate terminated by Isolate.kill
Is there a maximum of isolates that can be called at once? Do we need to clean them up?
urbanmania commentedon Jul 11, 2018
@vagrantrobbie did you ever get this sorted? I'm having similar problems, odd crashes on older devices.
zoechi commentedon Jul 11, 2018
@vagrantrobbie I don't think there is a hard limit of isolates, but they take up memory and if you run to many at once you can easily run out of memory.
@urbanmania please add details about the problems.
urbanmania commentedon Jul 11, 2018
ok, thanks. I'm looking at this plugin now to get around this problem https://github.com/btastic/flutter_native_image
vagrantrobbie commentedon Jul 11, 2018
@urbanmania I never really fixed the problem but with a clean run on the app and no hot reloading the error was infrequent enough for me to be happy.
ImagePicker plugin has a maxWidth property which I utilised
ImagePicker.pickImage(source: ImageSource.gallery, maxWidth: 800.0); and this was enough to fix my problem. FlutterNativeImage looks handy
urbanmania commentedon Jul 11, 2018
ah, had forgotten about that, I should look into that, thanks for reminding me of that.
zoechi commentedon Jul 12, 2018
@vagrantrobbie do you think there is still something the Flutter team needs to do?
The
ImagePickerissue you mentioned should better be reported in a new issue.vagrantrobbie commentedon Jul 13, 2018
@zoechi sorry for the late reply. I consider this closed. Thanks for following!
zoechi commentedon Jul 13, 2018
@vagrantrobbie thanks for the status update!
hyochan commentedon Sep 24, 2018
@zoechi @vagrantrobbie I think this isn't enough since we need to generate the
thumbnailfor every image in general. ThereforemaxWidthproperty is not enough. I've played around withflutter-native-imagefor this currently but I think ImagePicker should support this feature itself.zoechi commentedon Sep 24, 2018
@dooboolab I think it's better to create a new issue.
flutter-team-archive/engine@2d42c74...d7ad50c
flutter-team-archive/engine@2d42c74...d7ad50c
github-actions commentedon Sep 2, 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 -vand a minimal reproduction of the issue.