-
Notifications
You must be signed in to change notification settings - Fork 123
Fix: Handle if RangeSelector min and max args are equal
#576
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
base: main
Are you sure you want to change the base?
Conversation
|
Should probably change the gallery app to prevent this as well (with the fix, gallery app would just crash) |
The same would happen in any app. The issue is in the |
|
But don't you need to handle the exception in the WCT gallery app? That's what I meant in my message in the dev-chat channel in uwpc |
|
@michael-hawker There seems to be some undefined behavior here. Should the control simply ignore when |
|
We should pattern off So, I think the best expected behavior is the same here; we should honor that same underlying contract. Therefore, we should understand what's not working in this scenario to enable that vs. just throwing a different exception. This would also be worth doing anyway, as we should root-cause the underlying issue; as we should file a platform bug around the DWM crash, as that shouldn't happen regardless. (I wonder if this repros on WinUI 3 as well...) @Lamparter is this still something you could/would be willing to help us with? |
|
Sure! |
|
@Lamparter thanks! Let us know if you need any assistance and how we can help support you. Once we understand the root cause of what's causing the underlying crash, we can open/raise a platform issue on the WinUI repo too with a minimal repro without the toolkit maybe. Then, we can hopefully just find a good workaround in our toolkit code here to prevent that scenario from occurring when the edge case bounds are setup, and add a test or two to help us ensure we don't regress in the future. |
RangeSelector min and max args are equalRangeSelector min and max args are equal
…where Maximum values less than Minimum would erroneously overwrite Minimum
|
I traced through the lineage of this component to find the reason why the
This exact line doesn't serve the specific feature implemented in that original commit, so presumably the Challenging this, I removed the Both UWP and Wasdk have this issue now too, not sure if pre-existing but it's related: Recording.2025-12-12.180606.mp4The issue here is that lowering Pushed in c28bc00, these errors are all fixed. New behavior in Wasdk: Recording.2025-12-12.191906.mp4New behavior in UWP: Recording.2025-12-12.192421.mp4@michael-hawker If this looks good to you, we can close PR |
…ly overwrite minimum, cleaned up duplicate logic Amends c28bc00
|
Looks like the tests are failing across a number of scenarios. Question is if they were coded against the observed behavior or defining the expected behavior. So needs to be investigated. Minor other comment would be if we can still show the thumb like slider in this edge case: #576 (comment) |
…ch other When RangeStart is set to a value that snaps beyond RangeEnd (or vice versa), the control now snaps to the nearest valid step that respects the constraint, rather than being clamped to a non-step value. Problem: With StepFrequency=40, RangeStart=40, RangeEnd=60, setting RangeStart=60 would: 1. Snap 60 → 80 (nearest step via Math.Round) 2. VerifyValues() clamps 80 → 60 (to not exceed RangeEnd) 3. Result: RangeStart=60, which is not on a valid step (valid steps: 0, 40, 80, 100) Solution: RangeMinToStepFrequency and RangeMaxToStepFrequency now handle the range constraint directly after step snapping: • RangeMinToStepFrequency: If snapped value exceeds RangeEnd, snap down to previous valid step using Math.Floor • RangeMaxToStepFrequency: If snapped value is below RangeStart, snap up to next valid step using Math.Ceiling This keeps MoveToStepFrequency as a pure step-snapping utility, while the range constraint logic lives in the methods that understand the relationship between the two range values. Note: The interaction between VerifyValues() (bounds clamping) and step frequency snapping remains complex and should be refactored in a future PR to clarify responsibilities.
|
It turns out that fixing the bounds check here has cascaded into a series of other bugs that lay dormant, especially around existing code allowing RangeStart to be greater than RangeEnd. I'll need to push to a separate branch and rewind this one to contain only the minimal fixes for the DWM crashes we've observed on 23H2 and 24H2. I've pushed to the branch Reverting this branch back to the absolute minimum needed to fix observed DWM issues. |
…d issue where Maximum values less than Minimum would erroneously overwrite Minimum" This reverts commit c28bc00.
|
Thanks @Arlodotexe, please file the tracking issue for 8.3 consideration and link back here to the discussion. We can merge this and then kick-off the 8.2 hotfix release then! |
|
intermittent test failure, rekicked |
|
Kicked again, still |
|
Finally actually got a clean test-pass, but @Arlodotexe this still causes test failures: Let's just fix this proper in 8.3, as it seems it's a mess right now to fix this. |

Fixes #366
PR Type: Bugfix
This PR fixes an issue where DWM crashes if the arguments for both min and max of the range selector control are equal.
What is the current behavior?
When the Maximum and Minimum arguments of
RangeSelectorare equal, DWM crashes. This can be reproduced by even the Toolkit gallery app.What is the new behavior?
If the max and min args of the range selector are equal, an exception will be thrown.
PR Checklist
Please check if your PR fulfills the following requirements: