bumptech / glide

An image loading and caching library for Android focused on smooth scrolling
https://bumptech.github.io/glide/
Other
34.46k stars 6.11k forks source link

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

Open nordfalk opened 5 months ago

nordfalk commented 5 months ago

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)
                )
            }
Zweihui commented 2 months ago

I have same issue.

pawelnuzka commented 2 months ago

Same issue, happens mostly on low end devices.

Jhiertz commented 2 months ago

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.

KriskotooBG commented 1 month ago

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

KriskotooBG commented 1 month ago

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