GlideImage no longer works with Modifier.weight()
ryandt opened this issue · comments
Integration libraries: okhttp3-4.9.1
Device/Android version: Pixel 4, Android 13
Issue details / Repro steps / Use case background:
I recently upgraded Glide from 4.15.1
to 5.0.0-rc01
and Glide Compose from 1.0.0-alpha.3
to 1.0.0-beta01
. Upon doing so, a few GlideImage
usages throughout my app failed to load their image resources. They all happened to have weighted sizes. After the update, the size in onSizeChanged()
returns 0x0
whereas previously the initial size would be 0x0
and subsequent size change would be non-zero once the weights were applied.
val imageSize = remember { mutableStateOf(IntSize.Zero) }
val placeholder = ColorDrawable(LocalContext.current.colorFromAttr(R.attr.some_color))
GlideImage(
modifier = Modifier
.weight(1f, false)
.then(
if (imageSize.value.width == 0) {
Modifier.onSizeChanged {
if (it.width != 0) imageSize.value = it
}
} else Modifier,
),
model = getSizedImageUrl(topStart, imageSize.value),
loading = placeholder(placeholder),
failure = placeholder(placeholder),
contentDescription = null,
)
I created a demo project to demonstrate the bug. The first commit is with Glide Compose 1.0.0-alpha.3
and weights working; the second commit is with Glide Compose 1.0.0-beta01
and weights not working.
Does anyone have any thoughts on what may have caused this change in behavior?