Repository navigation
Conversation
Some touch digitizers (e.g. Surface Pro 9, Snapdragon ARM devices) report HID descriptors where Logical Maximum is less than Logical Minimum (commonly 0xFF interpreted as signed -1). The StylusPointPropertyInfo constructor throws an ArgumentException when maximum < minimum, crashing the application. Fix by swapping min/max when inverted at both call sites: - WM_POINTER stack: PointerStylusPointPropertyInfoHelper.CreatePropertyInfo - WISP stack: PenContext.InitStylusPointDescription Fixes dotnet#7069, dotnet#8435, dotnet#8826
|
@dotnet-policy-service agree [company="{Lumasoft LLC}"] |
There was a problem hiding this comment.
Pull request overview
Fixes a crash in WPF’s stylus/touch input stacks caused by some devices reporting inverted HID logical min/max values (logical maximum < logical minimum), which can trigger StylusPointPropertyInfo constructor validation and crash on first touch/stylus interaction.
Changes:
- WISP stack: swap
min/maxfromGetPacketPropertyInfowhen inverted before creatingStylusPointPropertyInfo. - WM_POINTER stack: swap
logicalMin/logicalMaxwhen inverted and use the corrected values for both resolution calculation andStylusPointPropertyInfoconstruction.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/PenContext.cs |
Normalizes inverted min/max from WISP packet properties to prevent StylusPointPropertyInfo exceptions. |
src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Pointer/PointerStylusPointPropertyInfoHelper.cs |
Normalizes inverted logical min/max from WM_POINTER device properties and ensures downstream computations use corrected values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@dotnet-policy-service agree |
|
@sleman I cherry-picked your code into my WpfRuntime repo, and the GitHub Actions CI build passed — the NuGet package is ready to go. You can now install the following package in your project to test or use your current fix: <PackageReference Include="WpfLab.WpfRuntime" Version="1.0.0.1-test.20260920112351.9ea088" />That's all you need to do — just install the NuGet package, no extra steps required. Then in any .NET 8+ WPF project you'll be running against the WPF framework build from the WpfRuntime repo. For more details, see WpfLab/WpfRuntime#28 I'd be honored if this NuGet package I built manages to pass your testing. And if you have any suggestions for WpfRuntime, I'd love to hear them |
Summary
WPF applications crash with an
ArgumentExceptioninStylusPointPropertyInfoon touch-enabled devices whose HID descriptors reportLogical Maximum < Logical Minimum(e.g.0xFFinterpreted as signed-1). This affects both the WM_POINTER and WISP stylus stacks, making touch input completely unusable on affected hardware.This is a common issue on Surface Pro devices with Snapdragon/ARM processors and other modern touch-enabled Windows devices.
Root cause
The
StylusPointPropertyInfoconstructor validatesmaximum >= minimumand throws if not. Both stylus stacks pass hardware-reported values directly to this constructor without checking the range:PointerStylusPointPropertyInfoHelper.CreatePropertyInfo()passesprop.logicalMin/prop.logicalMaxPenContext.InitStylusPointDescription()passesmin/maxfromGetPacketPropertyInfo()Fix
Swap
min/maxwhen the hardware reports them inverted, at both call sites. This preserves the range magnitude, avoids changing the public API, and allows touch input to function correctly.For the WM_POINTER stack, the resolution calculation is also updated to use the corrected values.
Affected devices
Logical Maximum < Logical MinimumAffected issues