Skip to content

Commit

Permalink
No-op on Android impl when LocalInspectionMode is true (#72)
Browse files Browse the repository at this point in the history
See #71
  • Loading branch information
chrisbanes authored Jan 3, 2024
1 parent 56dbafd commit 29321fc
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import androidx.compose.ui.node.invalidateDraw
import androidx.compose.ui.node.observeReads
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntSize
Expand Down Expand Up @@ -106,6 +107,13 @@ internal class HazeNode31(
}

override fun ContentDrawScope.draw() {
if (currentValueOf(LocalInspectionMode)) {
// If LocalInspectionMode is true, we're likely running in a preview/screenshot test
// and therefore don't have full access to Android drawing APIs. To avoid crashing we
// no-op and return early.
return
}

val contentDrawScope = this

val contentNode = RenderNode("content").apply {
Expand Down

0 comments on commit 29321fc

Please sign in to comment.