-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix get TransformToDevice in Stylus Input thread will throw the InvalidOperationException #6840
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?
Fix get TransformToDevice in Stylus Input thread will throw the InvalidOperationException #6840
Conversation
…idOperationException dotnet#6829
src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusLogic.cs
Outdated
Show resolved
Hide resolved
_transformToDeviceMatrices[hwndSource.CompositionTarget.CurrentDpiScale] = hwndSource.CompositionTarget.TransformToDevice; | ||
Debug.Assert(_transformToDeviceMatrices[hwndSource.CompositionTarget.CurrentDpiScale].HasInverse); | ||
DpiScale2 currentDpiScale = compositionTarget.CurrentDpiScale; | ||
toDevice.Scale(currentDpiScale.DpiScaleX, currentDpiScale.DpiScaleY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the transform not cached?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@miloush Do you think cache is fast than calculation? Thank you. I means that we should handle the cross thread issues when we cache it.
src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusLogic.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusLogic.cs
Outdated
Show resolved
Hide resolved
I am wondering why is the class a |
Hey @lindexi , Here is the code I am using:
|
@rchauhan18 Do you change the DPI? Please make sure the And could you debug and add the break point in |
@lindexi Yes, I am able to add a break point in |
@rchauhan18 How about multi-screen with different DPI configuration? Moving the app between the two screens. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
|
@LickBag Could you test my custom WPF version?
<PackageVersion Include="dotnetCampus.WPF.Resource" Version="6.0.4-alpha07-test06" />
|
Fixes #6829
Description
See #6829
The
Stylus Input
thread will enter the GetAndCacheTransformToDeviceMatrix method to get the Matrix. But after we change the DPI, theStylus Input
thread can not find the Matrix in_transformToDeviceMatrices
. It means that theStylus Input
thread should get the Matrix fromHwndTarget.TransformToDevice
property which only allow get from UI Thread.I fix it by dispatch to UI Thread. To improve performance, we will calculate it
CurrentDpiScale
property.Customer Impact
Fix tocuh in Window with StylusPlugIn may throw InvalidOperationException
Regression
Yes, see #2891
Testing
Just CI
And I pick the code to dotnet-campus/dotnetCampus.CustomWpf#21 to build the private version to test it by my application.
Risk
Low.
Microsoft Reviewers: Open in CodeFlow