mattprecious / telescope

A simple tool to allow easy bug report capturing within your app.
Apache License 2.0
1.18k stars 116 forks source link

Hardware accelerated compose node crashes canvas capture #142

Closed mattprecious closed 6 days ago

mattprecious commented 2 months ago

This can be reproduced by using Coil's AsyncImage without disabling hardware rendering:

AsyncImage(
  model = "https://picsum.photos/id/237/200/300",
  contentDescription = null,
  imageLoader = ImageLoader.Builder(it).build(),
)

Calling allowHardware(false) on the loader avoids the crash.

java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps
    at android.graphics.BaseCanvas.throwIfHwBitmapInSwMode(BaseCanvas.java:731)
    at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:81)
    at android.graphics.BaseCanvas.drawBitmap(BaseCanvas.java:139)
    at android.graphics.Canvas.drawBitmap(Canvas.java:1663)
    at androidx.compose.ui.graphics.AndroidCanvas.drawImageRect-HPBpro0(AndroidCanvas.android.kt:275)
    at androidx.compose.ui.graphics.drawscope.CanvasDrawScope.drawImage-AZ2fEMs(CanvasDrawScope.kt:256)
    at androidx.compose.ui.node.LayoutNodeDrawScope.drawImage-AZ2fEMs(Unknown Source:24)
    at androidx.compose.ui.graphics.drawscope.DrawScope.drawImage-AZ2fEMs$default(DrawScope.kt:551)
    at androidx.compose.ui.graphics.painter.BitmapPainter.onDraw(BitmapPainter.kt:93)
    at androidx.compose.ui.graphics.painter.Painter.draw-x_KDEd0(Painter.kt:212)
    at coil.compose.AsyncImagePainter.onDraw(AsyncImagePainter.kt:272)
    at androidx.compose.ui.graphics.painter.Painter.draw-x_KDEd0(Painter.kt:212)
    at coil.compose.ContentPainterNode.draw(ContentPainterModifier.kt:241)
        ...
        at com.mattprecious.telescope.TelescopeLayout.lambda$captureCanvasScreenshot$3$com-mattprecious-telescope-TelescopeLayout(TelescopeLayout.java:490)
        ...
mattprecious commented 2 months ago

I'm ~tempted to~ likely going to completely remove canvas capturing for the 2.0 release and only support system capturing.

mattprecious commented 2 months ago

For the time being, we could add ScreenshotMode.SYSTEM_ONLY which does not fall back to canvas capturing. Rejecting the system capture would invoke the lens without a screenshot.