Skip to content
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

Fatal Exception: java.lang.RuntimeException Canvas: trying to draw too large(192000000bytes) bitmap #31

Open
mehul4795 opened this issue Oct 3, 2023 · 2 comments

Comments

@mehul4795
Copy link

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?

@anton-begeima-okcupid
Copy link

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

@mehul4795
Copy link
Author

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants