glide icon indicating copy to clipboard operation
glide copied to clipboard

Fix NaN exception when rounding dimensions

Open dmytroKarataiev opened this issue 9 months ago • 3 comments

Description

Fixes this issue: https://github.com/bumptech/glide/issues/5356

This change:

  1. Checks if the scaled width/height values are finite (not NaN or infinite) using isFinite()
  2. If the value is finite, rounds it to an integer as before
  3. If the value is not finite (NaN or infinite), falls back to using the constraints' minimum dimensions This prevents any potential IllegalArgumentException that could be thrown when trying to round NaN or infinite values, making the code more robust.

Motivation and Context

dmytroKarataiev avatar Feb 20 '25 17:02 dmytroKarataiev

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Feb 20 '25 17:02 google-cla[bot]

Can you add tests?

falhassen avatar Mar 21 '25 03:03 falhassen

I didn't notice this (or the several bugs filed starting with https://github.com/bumptech/glide/issues/5256), but I think https://github.com/bumptech/glide/pull/5499 subsumes this?

donaldchai avatar Apr 14 '25 21:04 donaldchai