material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[RangeSlider] Crash occurs when assigning a large value to `valueTo`.

Open Park-SM opened this issue 2 years ago • 1 comments

Description: Crash occurs when assigning a large value to valueTo. To reproduce, set the values ​​as follows.

  • valueFrom : 1000.0
  • valueTo : 258896000.0
  • stepSize : 1000.0

Expected behavior:

Source code: The cause is the floating point rounding error.

private boolean valueLandsOnTick(float value) {
    // Check that the value is a multiple of stepSize given the offset of valueFrom.
    return isMultipleOfStepSize(value - valueFrom);
}

Minimal sample app repro: https://github.com/Park-SM/material-components-android/tree/reproduced_branch

Android API version: Android API 33

Material Library version: 1.9.0

Device: Galaxy Z Flip4

Park-SM avatar Jan 08 '24 08:01 Park-SM

also see https://github.com/material-components/material-components-android/pull/3979

Park-SM avatar Jan 08 '24 08:01 Park-SM

Fixed in ac77b4cfb5ac15b37240fd455233cbca237e103f

paulfthomas avatar Mar 15 '24 15:03 paulfthomas