Compose-Cropper
Compose-Cropper copied to clipboard
Fatal Exception: java.lang.RuntimeException Canvas: trying to draw too large(192000000bytes) bitmap
I am using Compose-Cropper in one of my apps. I am receiving the below error for many users. The Bitmap size mentioned is random but usually large.
Fatal Exception: java.lang.RuntimeException
Canvas: trying to draw too large(201326592bytes) bitmap.
android.graphics.RecordingCanvas.throwIfCannotDraw (RecordingCanvas.java:287)
androidx.compose.ui.graphics.drawscope.DrawScope.drawImage-AZ2fEMs$default (DrawScope.kt:510)
com.smarttoolfactory.cropper.draw.ImageDrawCanvasKt$ImageDrawCanvas$1.invoke (ImageDrawCanvas.kt:26)
com.smarttoolfactory.cropper.draw.ImageDrawCanvasKt$ImageDrawCanvas$1.invoke (ImageDrawCanvas.kt:21)
androidx.compose.ui.draw.DrawBackgroundModifier.draw (DrawModifier.kt:116)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1049)
Is there any workaround that can be implemented to prevent this exception?
Try to get a scaled-down version of the bitmap from the device as described here https://developer.android.com/topic/performance/graphics/load-bitmap. You might find more specific information on how to load large bitmaps on stack overflow
In my app, due to specific flow I am scaling the bitmap but at the later stage after the image is cropped using the Cropper. As you suggested, I think I should scale the bitmap earlier. Anyways, thanks :)