Skip to content
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

Releasing pointer capture while out of the window cause an error to be logged on WPF #16769

Open
dr1rrb opened this issue May 17, 2024 · 0 comments
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working platform/wpf 🪟 Categorizes an issue or PR as relevant to WPF project/pointers 🖱️ Categorizes an issue or PR as relevant to mouse/touch/pen pointers

Comments

@dr1rrb
Copy link
Member

dr1rrb commented May 17, 2024

Current behavior

When we release a pointer that has been captured out of the windows bounds on WPF cause this

if (this.Log().IsEnabled(LogLevel.Error))

This seems to be because when we invoke ReleaseCapture, WPF send us synchronously a pointer leave which cause to have a second pointer event (leave) being raised while still processing the release.

Expected behavior

No errors

How to reproduce it (as minimally and precisely as possible)

No response

Workaround

No response

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

No response

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

Stack trace:

---- DEBUG ASSERTION FAILED ----
---- Assert Short Message ----
A pointer is already being processed [Released] Mouse/1 while trying to raise [Leave] Mouse/1.
---- Assert Long Message ----

   at Uno.UI.Xaml.Core.InputManager.PointerManager.PointerDispatching..ctor(PointerManager manager, PointerEvent event, PointerRoutedEventArgs args) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Internal\InputManager.Pointers.Managed.cs:line 132
   at Uno.UI.Xaml.Core.InputManager.PointerManager.StartDispatch(PointerEvent& evt, PointerRoutedEventArgs& args) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Internal\InputManager.Pointers.Managed.cs:line 107
   at Uno.UI.Xaml.Core.InputManager.PointerManager.Raise(PointerEvent evt, UIElement originalSource, PointerRoutedEventArgs routedArgs) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Internal\InputManager.Pointers.Managed.cs:line 609
   at Uno.UI.Xaml.Core.InputManager.PointerManager.OnPointerExited(PointerEventArgs args) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Internal\InputManager.Pointers.Managed.cs:line 344
   at Uno.UI.Xaml.Core.InputManager.PointerManager.<Init>b__30_2(Object c, PointerEventArgs e) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Internal\InputManager.Pointers.Managed.cs:line 90
   at Uno.UI.XamlHost.Skia.Wpf.WpfCorePointerInputSource.HostOnMouseEvent(InputEventArgs args, TypedEventHandler`2 event, String eventName)
   at Uno.UI.XamlHost.Skia.Wpf.WpfCorePointerInputSource.HostOnMouseLeave(Object sender, MouseEventArgs args)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.ReverseInheritProperty.FirePropertyChangeInAncestry(DependencyObject element, Boolean oldValue, DeferredElementTreeState treeState, Action`2 originChangedAction)
   at System.Windows.ReverseInheritProperty.OnOriginValueChanged(DependencyObject oldOrigin, DependencyObject newOrigin, IList`1 otherOrigins, DeferredElementTreeState& oldTreeState, Action`2 originChangedAction)
   at System.Windows.Input.MouseDevice.ChangeMouseOver(IInputElement mouseOver, Int32 timestamp)
   at System.Windows.Input.MouseDevice.PreNotifyInput(Object sender, NotifyInputEventArgs e)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.MouseDevice.Synchronize()
   at System.Windows.Input.MouseDevice.ChangeMouseCapture(IInputElement mouseCapture, IMouseInputProvider providerCapture, CaptureMode captureMode, Int32 timestamp)
   at System.Windows.Input.MouseDevice.PreNotifyInput(Object sender, NotifyInputEventArgs e)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.SafeNativeMethods.SafeNativeMethodsPrivate.IntReleaseCapture()
   at MS.Win32.SafeNativeMethods.SafeNativeMethodsPrivate.IntReleaseCapture()
   at MS.Win32.SafeNativeMethods.ReleaseCapture()
   at System.Windows.Interop.HwndMouseInputProvider.System.Windows.Input.IMouseInputProvider.ReleaseMouseCapture()
   at System.Windows.Input.MouseDevice.Capture(IInputElement element, CaptureMode captureMode)
   at System.Windows.UIElement.ReleaseMouseCapture()
   at Uno.UI.XamlHost.Skia.Wpf.WpfCorePointerInputSource.ReleasePointerCapture(PointerIdentifier pointer)
   at Uno.UI.Xaml.Core.InputManager.PointerManager.ReleasePointerCapture(PointerIdentifier uniqueId) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Internal\InputManager.Pointers.Managed.cs:line 531
   at Uno.UI.Xaml.Core.PointerCapture.EnsureEffectiveCaptureState() in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Internal\PointerCapture.cs:line 305
   at Uno.UI.Xaml.Core.PointerCapture.RemoveCore(PointerCaptureTarget target, PointerCaptureKind kinds) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Internal\PointerCapture.cs:line 216
   at Uno.UI.Xaml.Core.PointerCapture.RemoveTarget(UIElement element, PointerCaptureKind kinds, PointerRoutedEventArgs& lastDispatched) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Internal\PointerCapture.cs:line 173
   at Microsoft.UI.Xaml.UIElement.Release(PointerCapture capture, PointerCaptureKind kinds, PointerRoutedEventArgs relatedArgs, Boolean muteEvent) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\UIElement.Pointers.cs:line 1534
   at Microsoft.UI.Xaml.UIElement.Release(PointerIdentifier pointer, PointerCaptureKind kinds, PointerRoutedEventArgs relatedArgs, Boolean muteEvent) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\UIElement.Pointers.cs:line 1528
   at Microsoft.UI.Xaml.UIElement.ReleasePointerCapture(PointerIdentifier pointer, Boolean muteEvent, PointerCaptureKind kinds) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\UIElement.Pointers.cs:line 1435
   at Microsoft.UI.Xaml.UIElement.ReleasePointerCapture(Pointer value) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\UIElement.Pointers.cs:line 1420
   at Microsoft.UI.Xaml.Controls.Primitives.Thumb.OnPointerReleased(PointerRoutedEventArgs args) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Controls\Primitives\Thumb.mux.cs:line 329
   at Microsoft.UI.Xaml.Controls.Control.<>c.<.cctor>b__386_10(Object sender, PointerRoutedEventArgs args) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Controls\Control\Control.cs:line 1028
   at Microsoft.UI.Xaml.UIElement.InvokeHandler(Object handler, RoutedEventArgs args) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\UIElement.RoutedEvents.cs:line 967
   at Microsoft.UI.Xaml.UIElement.InvokeHandlers(IList`1 handlers, RoutedEventArgs args, Boolean& isHandled) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\UIElement.RoutedEvents.cs:line 933
   at Microsoft.UI.Xaml.UIElement.RaiseEvent(RoutedEvent routedEvent, RoutedEventArgs args, BubblingContext ctx) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\UIElement.RoutedEvents.cs:line 627
   at Microsoft.UI.Xaml.UIElement.RaisePointerEvent(RoutedEvent evt, PointerRoutedEventArgs args, BubblingContext ctx) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\UIElement.Pointers.cs:line 1201
   at Microsoft.UI.Xaml.UIElement.SetPressed(PointerRoutedEventArgs args, Boolean isPressed, BubblingContext ctx) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\UIElement.Pointers.cs:line 1351
   at Microsoft.UI.Xaml.UIElement.OnPointerUp(PointerRoutedEventArgs args, BubblingContext ctx) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\UIElement.Pointers.cs:line 1078
   at Uno.UI.Xaml.Core.InputManager.PointerManager.<>c.<.cctor>b__64_10(UIElement elt, PointerRoutedEventArgs args, BubblingContext ctx) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Internal\InputManager.Pointers.Managed.cs:line 603
   at Uno.UI.Xaml.Core.InputManager.PointerManager.RaiseUsingCaptures(PointerEvent evt, UIElement originalSource, PointerRoutedEventArgs routedArgs, Boolean setCursor) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Internal\InputManager.Pointers.Managed.cs:line 675
   at Uno.UI.Xaml.Core.InputManager.PointerManager.OnPointerReleased(PointerEventArgs args) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Internal\InputManager.Pointers.Managed.cs:line 421
   at Uno.UI.Xaml.Core.InputManager.PointerManager.<Init>b__30_4(Object c, PointerEventArgs e) in C:\Src\GitHub\unoplatform\uno.4\src\Uno.UI\UI\Xaml\Internal\InputManager.Pointers.Managed.cs:line 92
   at Uno.UI.XamlHost.Skia.Wpf.WpfCorePointerInputSource.HostOnMouseEvent(InputEventArgs args, TypedEventHandler`2 event, String eventName)
   at Uno.UI.XamlHost.Skia.Wpf.WpfCorePointerInputSource.HostOnMouseUp(Object sender, MouseButtonEventArgs args)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at Uno.UI.Runtime.Skia.Wpf.WpfHost.RunLoop()
   at Uno.UI.Runtime.Skia.SkiaHost.RunCore()
   at Uno.UI.Runtime.Skia.SkiaHost.Run()
   at MvvmMaterialFrame.Program.Main(String[] args) in C:\Src\GitHub\unoplatform\uno.hotdesign\src\Samples\MvvmMaterialFrame\MvvmMaterialFrame\Platforms\Desktop\Program.cs:line 20
@dr1rrb dr1rrb added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels May 17, 2024
@Youssef1313 Youssef1313 added project/pointers 🖱️ Categorizes an issue or PR as relevant to mouse/touch/pen pointers platform/wpf 🪟 Categorizes an issue or PR as relevant to WPF labels May 17, 2024
@jeromelaban jeromelaban removed the triage/untriaged Indicates an issue requires triaging or verification label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working platform/wpf 🪟 Categorizes an issue or PR as relevant to WPF project/pointers 🖱️ Categorizes an issue or PR as relevant to mouse/touch/pen pointers
Projects
None yet
Development

No branches or pull requests

3 participants