Skip to content

empty bitmap file creation #173

Closed
Closed
@truthofmatthew

Description

bug 😭
@Yalantis
This bug is shown when:
1- we chose an image from google drive app.
2- we chose an image from external sd card.

Waz goin on:
1- we open the app
2- we chose an image from gdrive, here two things will happen
1- if we crop the image, its okay and it will work because ucrop copy the bitmap into where we set
2- if we do not crop it, it will not work cuz the app didnt copy the image into the path we set as default, i was looking at the source code, if we dont crop the app will say: cropped needed? false. then its just create an empty bitmap file and will load that empty file.

Solution i Think:
this is what i think is right, for the files on internal or some external cards the behaviour is right and works well, but on some devices and gdrive files will not work, but this idea i have maybe can be helpful.

1- if we do not crop, u crop should copy the selected image into the path we set in any situation.
2- or put an option to ask the user, do you want to copy or use the original?

and here is the stacktrace:
onFailure: setImageUri java.lang.IllegalArgumentException: Bounds for bitmap could not be retrieved from the Uri: [file:///data/user/0/com.yalantis.ucrop.sample/cache/SampleCropImage.jpg] at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:113) at com.yalantis.ucrop.task.BitmapLoadTask.doInBackground(BitmapLoadTask.java:41) at android.os.AsyncTask$2.call(AsyncTask.java:295) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818)

and i think the bug is in the copying stage:
the class BitmapCropTask.java
line 148: FileUtils.copyFile(mImageInputPath, mImageOutputPath);
because everything works fine if we comment: boolean shouldCrop = shouldCrop(width, height);
its not the solution but it can make it work because of the cropping solutions and...

the FileUtils.java: copyFile()...
i didnt have time to look into the codes and find the main reason and best solution, but for now its good to know this kinda things is there.

thanks a lot, ill be happy to know more about this.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions