iZakirSheikh / toolkit

Apache License 2.0
79 stars 5 forks source link

Software rendering doesn't support hardware bitmaps #12

Open mahmood199 opened 7 months ago

mahmood199 commented 7 months ago

When applying legacyBackgroundBlur(radius = 25f, downsample = 0.4f) on the top bar of the app, we're getting the above error with a crash.

Our UI hierarchy is Box{ content() TitleHeader(modifier applied here) // this header is aligned to the top of the box }

Android Version 12 Device - MIUI

Attaching the crash log

java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps at android.graphics.BaseCanvas.onHwBitmapInSwMode(BaseCanvas.java:699) at android.graphics.BaseCanvas.throwIfHwBitmapInSwMode(BaseCanvas.java:706) at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:81) at android.graphics.MiuiCanvas.throwIfCannotDraw(MiuiCanvas.java:358) at android.graphics.BaseCanvas.drawBitmap(BaseCanvas.java:139) at android.graphics.MiuiCanvas.drawBitmap(MiuiCanvas.java:139) at android.graphics.Canvas.drawBitmap(Canvas.java:1607) 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:271) at androidx.compose.ui.graphics.painter.Painter.draw-x_KDEd0(Painter.kt:212) at androidx.compose.ui.draw.PainterNode.draw(PainterModifier.kt:342) at androidx.compose.ui.node.LayoutNodeDrawScope.drawDirect-x_KDEd0$ui_release(LayoutNodeDrawScope.kt:105) at androidx.compose.ui.node.LayoutNodeDrawScope.draw-x_KDEd0$ui_release(LayoutNodeDrawScope.kt:86) at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:364) at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:176) at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:361) at androidx.compose.ui.node.NodeCoordinator.access$drawContainedDrawModifiers(NodeCoordinator.kt:54) at androidx.compose.ui.node.NodeCoordinator$drawBlock$1$1.invoke(NodeCoordinator.kt:383) at androidx.compose.ui.node.NodeCoordinator$drawBlock$1$1.invoke(NodeCoordinator.kt:382) at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2303) at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:500) at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256) at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133) at androidx.compose.ui.node.NodeCoordinator$drawBlock$1.invoke(NodeCoordinator.kt:382) at androidx.compose.ui.node.NodeCoordinator$drawBlock$1.invoke(NodeCoordinator.kt:380) at androidx.compose.ui.platform.RenderNodeLayer.drawLayer(RenderNodeLayer.android.kt:311) at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:348) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:176) at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:361) at androidx.compose.ui.node.NodeCoordinator.access$drawContainedDrawModifiers(NodeCoordinator.kt:54) at androidx.compose.ui.node.NodeCoordinator$drawBlock$1$1.invoke(NodeCoordinator.kt:383) at androidx.compose.ui.node.NodeCoordinator$drawBlock$1$1.invoke(NodeCoordinator.kt:382) at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2303) at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:500) at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256) at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133) at androidx.compose.ui.node.NodeCoordinator$drawBlock$1.invoke(NodeCoordinator.kt:382)

iZakirSheikh commented 6 months ago

Thanks for reporting. Alas, currently the app doesn't support hardware bitmaps. You can disable them for now. Like if you are using coil, you have to set **_

allowHardware to false

_**. There is an solution to the issue but currently, I don't have time to implication it. I will work on the solution as soon as I find free time. If anyone wants to fix the issue, I can accept the pull request.

ultraon commented 2 months ago

I found another issue (even with disabled allowHardware for the Coil library. The content behind the blurred box (AppBar) while scrolling has just been constantly stretching when I scroll it at the edge position.