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

Compose: Software rendering doesn't support hardware bitmaps #1560

Closed
yschimke opened this issue Dec 6, 2022 · 4 comments
Closed

Compose: Software rendering doesn't support hardware bitmaps #1560

yschimke opened this issue Dec 6, 2022 · 4 comments

Comments

@yschimke
Copy link
Contributor

yschimke commented Dec 6, 2022

Raising, because I haven't seen this with Coil and Compose before.

This is with Coil 2.2.2 (it's from a prod report, so possibly was older version)

Fatal Exception: java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps
       at android.graphics.BaseCanvas.onHwBitmapInSwMode(BaseCanvas.java:668)
       at android.graphics.BaseCanvas.throwIfHwBitmapInSwMode(BaseCanvas.java:675)
       at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:77)
       at android.graphics.BaseCanvas.drawBitmap(BaseCanvas.java:135)
       at android.graphics.Canvas.drawBitmap(Canvas.java:1648)
       at androidx.compose.ui.graphics.AndroidCanvas.drawImageRect-HPBpro0(AndroidCanvas.java:2)
       at androidx.compose.ui.graphics.drawscope.CanvasDrawScope.drawImage-AZ2fEMs(CanvasDrawScope.java:2)
       at androidx.compose.ui.node.LayoutNodeDrawScope.drawImage-AZ2fEMs(LayoutNodeDrawScope.java:34)
       at androidx.compose.ui.graphics.drawscope.DrawScope.drawImage-AZ2fEMs$default(DrawScope.java:4)
       at androidx.compose.ui.graphics.painter.BitmapPainter.onDraw(BitmapPainter.java:56)
       at androidx.compose.ui.graphics.painter.Painter.draw-x_KDEd0(Painter.java:14)
       at coil.compose.AsyncImagePainter.onDraw(AsyncImagePainter.java:7)
       at androidx.compose.ui.graphics.painter.Painter.draw-x_KDEd0(Painter.java:14)
       at androidx.compose.ui.draw.PainterModifier.draw(PainterModifier.java:6)
       at androidx.compose.ui.node.DrawEntity.draw(DrawEntity.java:25)
       at androidx.compose.ui.node.LayoutNodeWrapper.drawContainedDrawModifiers(LayoutNodeWrapper.java:3)
       at androidx.compose.ui.node.ModifiedLayoutNode.performDraw(ModifiedLayoutNode.java:2)
       at androidx.compose.ui.node.LayoutNodeWrapper.drawContainedDrawModifiers(LayoutNodeWrapper.java:4)
       at androidx.compose.ui.node.LayoutNodeWrapper$invoke$1.invoke(LayoutNodeWrapper.java:4)

Other reports like #31 seem to be View based.

My expectation is that by default Coil, will choose the right hardware more. Disabling presumably fixes this, but as it's working in almost all cases, that seems sub-optimal.

Should this be possible with Coil and Compose?

@colinrtwhite
Copy link
Member

@yschimke Sorry for the delayed response! Coil ideally should automatically disable hardware bitmaps, however there are some edge cases where it's not possible with 100% certainty. A few questions:

Are you adding AndroidComposeView nested inside another view (i.e. not using setContent inside an Activity)?
Are you seeing this on a specific device or API version?

My hypothesis is we're probably reaching this line and the view isn't attached yet. However, considering it only happens occasionally it could be a device-specific issue in which case we'd want to add it to the blocklist.

@yschimke
Copy link
Contributor Author

yschimke commented Mar 8, 2023

Let's close, it was from a prod report, so I don't know the code path

@yschimke yschimke closed this as not planned Won't fix, can't repro, duplicate, stale Mar 8, 2023
@Boydroidnl
Copy link

I've seen this issue once now @colinrtwhite and yes, I'm using an androidx.compose.ui.platform.ComposeView.

I'm seeing this issue on a OnePlus 6T.

@Boydroidnl
Copy link

Boydroidnl commented Jun 28, 2023

Can I gracefully ignore this error? I'm now setting 'allowHardware' to false:

val request = ImageRequest.Builder(LocalContext.current).data(image).allowHardware(false).build()
AsyncImage(model = request,
    contentDescription = null,
    contentScale = ContentScale.FillHeight,
...
)

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

3 participants