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() #5372

Closed
ryandt opened this issue Feb 8, 2024 · 2 comments
Closed

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

ryandt opened this issue Feb 8, 2024 · 2 comments
Labels

Comments

@ryandt
Copy link

ryandt commented Feb 8, 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? Possibly related to this? cc: @sjudd

@sjudd sjudd added the Compose label Mar 20, 2024
@sjudd
Copy link
Collaborator

sjudd commented Mar 20, 2024

1.0.0-beta01 is newer than 1.0.0-alpha.3, so I think this is fixed :)

@sjudd sjudd closed this as completed Mar 20, 2024
@ryandt
Copy link
Author

ryandt commented Mar 20, 2024

@sjudd Oops, I typo'd the issue description and accidentally flipped the bug version and the non-bug version around. Just updated the description. To clarify, the issue I'm seeing is present in 1.0.0-beta01 and not present in 1.0.0-alpha.3

Created a new issue here

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

No branches or pull requests

2 participants