Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GlideImage no longer works with Modifier.weight() #5385

Open
ryandt opened this issue Mar 20, 2024 · 0 comments
Open

GlideImage no longer works with Modifier.weight() #5385

ryandt opened this issue Mar 20, 2024 · 0 comments

Comments

@ryandt
Copy link

ryandt commented Mar 20, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants