Skip to content

[Bug] Crash when image is too small #164

@kaii-lb

Description

@kaii-lb

If the image is small enough (i tested with a 172x39) image, the library will crash with a
java.lang.RuntimeException: Canvas: trying to draw too large(106754160bytes) bitmap. exception.

which seems weird since the image is literally too small to ever fill up the canvas, and the library is handling 8k images just fine.

A work around is using .downsample(DownsampleStrategy.FIT_CENTER) on the glide request builder, which will upscale the image to the device resolution.

here's a snippet of the error log:

12-28 23:08:18.324 25419 25419 E AndroidRuntime: java.lang.RuntimeException: Canvas: trying to draw too large(106754160bytes) bitmap.
12-28 23:08:18.324 25419 25419 E AndroidRuntime: 	at android.graphics.RecordingCanvas.throwIfCannotDraw(RecordingCanvas.java:266)
12-28 23:08:18.324 25419 25419 E AndroidRuntime: 	at android.graphics.BaseRecordingCanvas.drawBitmap(BaseRecordingCanvas.java:94)
12-28 23:08:18.324 25419 25419 E AndroidRuntime: 	at androidx.compose.ui.graphics.AndroidCanvas.drawImageRect-HPBpro0(AndroidCanvas.android.kt:228)
12-28 23:08:18.324 25419 25419 E AndroidRuntime: 	at androidx.compose.ui.graphics.drawscope.CanvasDrawScope.drawImage-AZ2fEMs(CanvasDrawScope.kt:262)
12-28 23:08:18.324 25419 25419 E AndroidRuntime: 	at androidx.compose.ui.node.LayoutNodeDrawScope.drawImage-AZ2fEMs(Unknown Source:24)
12-28 23:08:18.324 25419 25419 E AndroidRuntime: 	at androidx.compose.ui.graphics.drawscope.DrawScope.drawImage-AZ2fEMs$default(DrawScope.kt:555)
12-28 23:08:18.324 25419 25419 E AndroidRuntime: 	at androidx.compose.ui.graphics.painter.BitmapPainter.onDraw(BitmapPainter.kt:89)
12-28 23:08:18.324 25419 25419 E AndroidRuntime: 	at androidx.compose.ui.graphics.painter.Painter.draw-x_KDEd0(Painter.kt:192)
12-28 23:08:18.324 25419 25419 E AndroidRuntime: 	at me.saket.telephoto.subsamplingimage.SubSamplingImageKt.drawImageTile(SubSamplingImage.kt:122)
12-28 23:08:18.324 25419 25419 E AndroidRuntime: 	at me.saket.telephoto.subsamplingimage.SubSamplingImageKt.access$drawImageTile(SubSamplingImage.kt:1)
12-28 23:08:18.324 25419 25419 E AndroidRuntime: 	at me.saket.telephoto.subsamplingimage.SubSamplingImageKt$SubSamplingImage$onDraw$1$1.invoke(SubSamplingImage.kt:61)
12-28 23:08:18.324 25419 25419 E AndroidRuntime: 	at me.saket.telephoto.subsamplingimage.SubSamplingImageKt$SubSamplingImage$onDraw$1$1.invoke(SubSamplingImage.kt:58)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions