-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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 size compression takes too long and freezes the UI #19383
Comments
It seems like this line is the one that is taking really long and freezing the UI.
|
Someone built an image compression component that uses native compression tools rather than what was provided with that image library. https://github.com/btastic/flutter_native_image I recommend using that instead. The only real issue I've run into is an incompatibility with the Master Channel. |
Alternatively you can use https://docs.flutter.io/flutter/foundation/compute.html to move computation off the UI thread to a new thread. |
Where is |
Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away! |
@goderbauer this line here |
Move the work to another isolate that you start up manually. This is not perfect yet. |
@zoechi to be honest I have found another solution, not that great but works for my case at this point of time. What one can do, if the |
image_picker work around is not the perfect solution. It would be fine to hav a elegant and performant solution to resize and compress image in pure dart language. |
@fvisticot follow #26194 |
Start a platform thread as a plan b. |
I can confirm that I successfuly resized an image from an isolate without locking the UI thread.
The only drawback is that the image needs to be read again after execution. |
Unfortunately isolates approach doesn't seem to work for Flutter Web. The UI still freezes. Is it a known issue? |
@aloisdeniel Thanks for you idea. It works for me as well. But you don't need to save the file again. You can try this:
|
Looks like the image picker plugin now supports it 😃 #34523 |
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 |
I am trying to compress the size of the image before uploading it to firebase storage, but the image compression takes way too long and freezes the UI.
The code I am using is the following code, which was taken from
this stack overflow question:
The text was updated successfully, but these errors were encountered: