glide icon indicating copy to clipboard operation
glide copied to clipboard

Glide compose crash when using GlideImage inside a Row(Modifier.height(IntrinsicSize.Min))

Open nordfalk opened this issue 1 year ago • 6 comments

Glide Version: 5.0.0-rc01

    implementation "com.github.bumptech.glide:glide:5.0.0-rc01"
    implementation "com.github.bumptech.glide:okhttp3-integration:5.0.0-rc01"
    implementation platform("androidx.compose:compose-bom:2023.10.01")
    implementation "androidx.compose.ui:ui:"
    implementation "androidx.compose.material:material"
    implementation 'androidx.compose.material3:material3-android:1.2.0-beta02'
    implementation "com.github.bumptech.glide:compose:1.0.0-beta01"

Device/Android Version: I only tried in the emulator

If I use GlideImage inside Row(Modifier.height(IntrinsicSize.Min)) it crashes:

            Row(Modifier.height(IntrinsicSize.Min)) {
                GlideImage(
                    model = "https://javabog.dk/JSP-lille.jpg",
                    contentDescription = "Text",
                )
            }

Stack trace / LogCat:

FATAL EXCEPTION: main
             Process: dk.dinero.android.debug, PID: 30072
             java.lang.IllegalArgumentException: Cannot round NaN value.
             	at kotlin.math.MathKt__MathJVMKt.roundToInt(MathJVM.kt:1165)
             	at com.bumptech.glide.integration.compose.GlideNode.modifyConstraints-ZezNO4M(GlideModifier.kt:571)
             	at com.bumptech.glide.integration.compose.GlideNode.measure-3p2s80s(GlideModifier.kt:523)
             	at androidx.compose.ui.node.LayoutModifierNode$minIntrinsicHeight$1.measure-3p2s80s(LayoutModifierNode.kt:92)
             	at androidx.compose.ui.node.NodeMeasuringIntrinsics.minHeight$ui_release(LayoutModifierNode.kt:201)
             	at androidx.compose.ui.node.LayoutModifierNode.minIntrinsicHeight(LayoutModifierNode.kt:90)
             	at androidx.compose.ui.node.LayoutModifierNodeCoordinator.minIntrinsicHeight(LayoutModifierNodeCoordinator.kt:144)
             	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.minIntrinsicHeight(LayoutNodeLayoutDelegate.kt:785)
             	at androidx.compose.foundation.layout.IntrinsicMeasureBlocks$HorizontalMinHeight$1$1.invoke(RowColumnImpl.kt:465)
             	at androidx.compose.foundation.layout.IntrinsicMeasureBlocks$HorizontalMinHeight$1$1.invoke(RowColumnImpl.kt:463)
             	at androidx.compose.foundation.layout.RowColumnImplKt.intrinsicCrossAxisSize(RowColumnImpl.kt:601)
             	at androidx.compose.foundation.layout.RowColumnImplKt.intrinsicSize(RowColumnImpl.kt:546)
             	at androidx.compose.foundation.layout.RowColumnImplKt.access$intrinsicSize(RowColumnImpl.kt:1)
             	at androidx.compose.foundation.layout.IntrinsicMeasureBlocks$HorizontalMinHeight$1.invoke(RowColumnImpl.kt:463)
             	at androidx.compose.foundation.layout.IntrinsicMeasureBlocks$HorizontalMinHeight$1.invoke(RowColumnImpl.kt:462)
             	at androidx.compose.foundation.layout.RowColumnMeasurePolicy.minIntrinsicHeight(RowColumnImpl.kt:108)

If dont use Row(Modifier.height(IntrinsicSize.Min)), or specifies size, it works fine: These 2 examples works fine and shows the image:

            Row() {
                GlideImage(
                    model = "https://javabog.dk/JSP-lille.jpg",
                    contentDescription = "Text",
                )
            }

            Row(Modifier.height(IntrinsicSize.Min)) {
                GlideImage(
                    model = "https://javabog.dk/JSP-lille.jpg",
                    contentDescription = "Text",
                    modifier = Modifier
                        .width(80.dp)
                        .height(80.dp)
                )
            }

nordfalk avatar Jan 23 '24 14:01 nordfalk

I have same issue.

Zweihui avatar Apr 07 '24 06:04 Zweihui

Same issue, happens mostly on low end devices.

pawelnuzka avatar Apr 25 '24 19:04 pawelnuzka

Same issue, happens mostly on low end devices.

Same for our application.

What we've observed is that with the compose version bom 2024.02.01 the crash occurs more frequently than with bom 2023.10.01.

Jhiertz avatar May 02 '24 07:05 Jhiertz

Same issue here.. The issue I'm facing is a Column, inside of a Scaffold, with only the 'vertocalScroll' modifier set

KriskotooBG avatar May 10 '24 19:05 KriskotooBG

Seem like wrapping the image in a row seems to fix the issue in some of the cases I tested, as a workaround

KriskotooBG avatar May 11 '24 19:05 KriskotooBG

We are experiencing the same issue while having modifier = Modifier.height(IntrinsicSize.Min) on the Row and modifier = Modifier.fillMaxHeight() on the GlideImage.

Did anyone find a workaround yet that keeps the IntrinsicSize.Min behavior? Or does someone have a reproducer that crashes reliably?

Looking at the code I would assume that it's the same issue for width calculations: https://github.com/bumptech/glide/blob/a7351b0ecf6656ad937fbc52fe9e90d3b289c265/integration/compose/src/main/java/com/bumptech/glide/integration/compose/GlideModifier.kt#L542-L585

ln-12 avatar Jul 30 '24 07:07 ln-12