-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
[BUG] - Null bitmap provided to OnCropImageCompleteListener #355
Comments
Hey @marekoid thanks for the issue, will need your help to understand some details...
Which version of the library are you?
From which version to which version?
Could you please share this code you are using? I know can be redundant, but helps =)
Not sure what I can do here for you exactly. Still having issues?
You need to use Java 11 since version 3.3.4, the wrong Java version can bring unexpected behaviours. I try to reproduce using the CropImageView Sample code we have in the library but was not successful from this steps, could you give me more insights how can I reproduce? Sorry not been very useful so far, but we will get there =D |
Thanks @Canato for your quick reply! It works on 3.2.2, but doesn't work on 3.3.4. I have also checked the latest version (4.2.1) and it doesn't work there too so I assume that any version above 3.2.2 won't work. imageView.setOnCropImageCompleteListener { view: CropImageView, result: CropResult ->
val bitmap = result.bitmap
// bitmap will be null...
}
imageView.setImageBitmap(bitmap)
imageView.croppedImageAsync() Why Java 11 is needed since 3.3.4? Do you reckon that using Java 8 instead could result in such an odd issue of bitmap being null? I would expect it to be more likely a build-time issue. |
We update to Java 11 so we could update Gradle. And is always good to keep the most updated versions available. Those who do not update, keep using old versions of the library, but those who update can get the benefits of the latest versions.
Maybe, unexpected behaviours hahaha. Not sure how the file handling happens at the bottom of Java code. I would suggest sticking with |
Thanks for your quick reply @Canato! I played a bit with it and it's not Java 11 related issue. I created the most basic sample project that showcases the issue. It's Java 11, and bitmap passed to the callback is |
I see that Result is never created with a bitmap... so that clearly looks like a regression? Also I've noticed that it's reporting the following exception, which I don't see in the real project I'm working on (over there java.lang.IllegalArgumentException: width must be > 0
at android.graphics.Bitmap.checkWidthHeight(Bitmap.java:450)
at android.graphics.Bitmap.createBitmap(Bitmap.java:874)
at com.canhub.cropper.BitmapUtils.cropBitmapObjectWithScale(BitmapUtils.kt:218)
at com.canhub.cropper.BitmapUtils.cropBitmapObjectHandleOOM(BitmapUtils.kt:160)
at com.canhub.cropper.BitmapCroppingWorkerJob$start$1.invokeSuspend(BitmapCroppingWorkerJob.kt:65)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
|
Maybe the sample was too basic. The view was not yet measured when I requested immediately
|
Hey, @marekoid sorry for the long time to reply these days... going crazy with some work-related issues. Your issue looks correct, for some reason Plus, would be great for a small sample of its usage of it, so we won't allow this to be broken again in the future. Will pin and tag this issue in case someone wanna help and take ownership of it |
@marekoid ok! I understood the problem and found the issue. Instead of trying to retrieve This was done because a bitmap is too huge/big to pass as a result in the android intent. But for sure we need to improve this contract. |
It's view integration, not activity one, so binder transaction size limits shouldn't be relevant here.
Do you mean that bitmap integration won't be supported any more? Currently it's present both in the README and the code API.
I was indeed thinking about it but it's legacy code which would need a bigger overhaul to support bitmap reading/decoding/rendering which really should happen asynchronously off the main thread. The library was providing all of it with the loading indicator in the |
Sorry that I couldn't help early =/ Still need to spend some time understanding how to better improve these. If you have a clue please feel free to drop a PR, will help your case and many others =D |
I'm rewriting the documentation and planning to check this bug ASAP... putting this here cause may help someone or my self in the future when checking the bug |
@marekoid do you still have this issue or were you able to work around it? |
@vanniktech @Canato I'm having this issue as well,
|
@siddeshpillai can you modify the sample app of this repository in order to create a reproducible issue? If so, I can have a look at it! |
I created a basic sample that reproduced the issue and linked to it in that comment. Addressing the earlier question, it didn't feel like worth looking for a work around really, just didn't upgrade beyond the version that has introduced the regression. I'm no loner working on the project were the bug prevented the library upgrade so will be unsubscribing from this thread but definitely if feels like something worth fixing for the active users of the library. |
Describe the bug
I've upgraded the library and now I'm getting
null
bitmap inCropResult
provided to the listener set usingsetOnCropImageCompleteListener
. InterestinglyisSuccessful
istrue
anderror
isnull
.The project is using
CropImageView
integration. The only change I needed to do when updating was to changegetCroppedImageAsync()
tocroppedImageAsync()
.The project is using Java 8, had issues upgrading it to Java 11. The files integrating with the library are in Kotlin. Not sure if it's not Java 8 issue but I would expect any such issues to be more likely build-time issues, not such an odd runtime issue of bitmap being
null
right at the end of the flow.To Reproduce
Steps to reproduce the behavior:
Expected behavior
cropResult.bitmap provided to the listener should not be
null
Please help/advise.
The text was updated successfully, but these errors were encountered: