-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Crash in glide compose alpha.5, when computing scale factor #5256
Comments
Thanks for reporting this! |
sjudd
added a commit
that referenced
this issue
Aug 24, 2023
This will happen if either width or height (or both) are constrained to have a 0 size. We already avoid loading the image via AsyncImageSize / inferredGlideSize. This only impacts layout. Fixes #5256
sjudd
added a commit
that referenced
this issue
Aug 24, 2023
This will happen if either width or height (or both) are constrained to have a 0 size. We already avoid loading the image via AsyncImageSize / inferredGlideSize. This only impacts layout. Fixes #5256
@sjudd Just wanted to let you know this fix doesn't look like it got correctly pulled into the alpha 6 build. I know you were trying a new build process so maybe there is a glitch in this process. Here is what I noticed related to the new build:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Glide Version: 1.0.0-alpha.5/4.16.0
Integration libraries: okhttp4-integration (although issue is not here)
Device/Android Version: Emulator/Pixel 6a
Issue details / Repro steps / Use case background:
Looks like glide triggers a
ScaleFactor is unspecified
exception, if either the width or height is implicit and the other is computed from a ratio if the width or height resolves to 0.dp.I found this, because I had gotten 1.0.0-alpha.3 working with a compose MotionLayout where the image is "Gone" in the initial constraints and appears in end constraints. It took time to determine the root cause to see if it was the MotionLayout code or Glide, but I was able to reproduce using a standard GlideImage without MotionLayout involved.
Here is the abbreviated stack:
It seems like the bug is the intrinsicWidth/intrinsicHeight is 0.dp and/or the constrainedWidth/Height is 0.dp. Essentially this should be checked for 0.dp as division by 0 results in NaN and ends up triggering the exception. I suspect if 0.dp is determined as the width or height there is no need to issue the network download or draw the image as it can not be seen. The easy fix is to not crash, but I couldn't quite follow to determine if there is an optimization to avoid the network/cache fetch as well.
The code in question is:
Here are some examples outside of the MotionLayout that trigger the same. I suspect MotionLayout under the covers is doing one of these variations when the image layout is marked as Gone.
Technically it doesn't make sense to have a width/height resolve to zero. However a MotionLayout where the image is initially Gone will trigger the issue. It also seems related to the aspect ratio. I'm downloading into a square so I used 1, but essentially I don't know the exact size as it is a percentage of the width.
I do have a few work arounds but neither are ideal for the final solution:
The text was updated successfully, but these errors were encountered: