Glucose Range Picker causes crash using mmol/L and min or max values
Describe the bug When using mmol/L as glucoses units, all instances of GlucoseRangePicker (used to select normal correction range and premeal correction range) share a common bug: when setting the range to the lowest possible value to the lowest possible value OR the highest possible value to the highest possible value the app oftentimes crashes.
To Reproduce Steps to reproduce the behavior:
- Use mmol/L as glucose unit
- Adjust correction range to 4.4-4.4 or 10.0-10.0 in either onboarding or settings (likely chance of crash)
- Adjust premeal range to 4.4-4.4 or 10.0-10.0 in either onboarding or settings (likely chance of crash)
Expected behavior The app should accept these values
Phone
- Simulator, iOS 16.1
Loop Version
- Current dev workspace (9fd16c2) with the newest LoopKit/LoopKit submodule (7134679)
Why this happens From brief sleuthing, it appears to be due to a rounding error from mg/dL to mmol/L where the minValue is just higher than the maxValue of the range.
Thanks. I know someone else had reported this error, too, on facebook.
Probably don't need this, but I did it so here's the report. Phone wiped clean of Loop app and Health data from Loop. Set health units to mmol/L. Build with LoopWorkspace (08-Dec-22)
- 7d1989c Correction range crash fix, loop-not-looping message fix, improve OTP validation and logging
- onboard selecting min allowed Glucose safety and min and max allowed for Correction and Premeal.
I confirm the crash when trying to modify the glucose safety limit. The crash line is line 90 in SuspendThresholdEditor.swift
Coming in with a fresh build of Loop Master, prior settings were min and min/max for master
- I selected Glucose Safety limit of 3.8 mmol/L instead of 3.7.
- When I go to edit after onboarding is finished, the 3.7 shows on the picker but I cannot save it.
- I accepted the offered 4.8 to 10.0 for Correction Range
- At edit, change to 4.9 to 9.9
- Edit again, 4.8 to 10.0 can be selected and saved.
- Premeal gave me no issues - lower limit is 3.8 as expected
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Bounced into this on a fresh dev-branch (3.3.0 (57)) just recently. Same issue as describe above where selecting the max value (10.0 mmol/L as both min and max values.
This issue is stale because it has been open for 30 days with no activity.
Bump
This issue is stale because it has been open for 30 days with no activity.
Bump. Fixed in dev.
This issue can be closed. It is now fixed in main.