Bug 46844 - Xamarin UWP Manipulate Messages not consistently being routed
Summary: Xamarin UWP Manipulate Messages not consistently being routed
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.3.2
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-11-11 22:37 UTC by Alan Anderson
Modified: 2017-06-22 01:29 UTC (History)
3 users (show)

Tags: pointermoved, ac, uwp
Is this bug a regression?: ---
Last known good build:

Sample projects for both Xamarin.Forms and native Windows UWP (5.95 KB, text/html)
2016-11-11 22:57 UTC, Alan Anderson

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 46844 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Alan Anderson 2016-11-11 22:37:19 UTC

Comment 1 Alan Anderson 2016-11-11 22:57:29 UTC
Created attachment 18435 [details]
Sample projects for both Xamarin.Forms and native Windows UWP


The above is a link to a OneDrive folder that contains a zip of the sample projects.
Comment 2 Alan Anderson 2016-11-11 22:58:56 UTC
Attached is a simple Xamarin.Forms app with a custom renderer (only the UWP project is important as others aren't implemented. In the GraphicDisplayView class I create handlers for ManipulationStarted, ManipulationDelta and ManipulationCompleted. If you use touch (or a mouse pointer) occasionally the messages will fire, there is Debug.WriteLine messages in the events - however more times than not the events aren't captured. I have yet to determine what sequence of events cause the messages to fire. This is using a custom renderer to display graphics on all the plaforms. 

I also created a native UWP app that has the same functionality (UWPSample), as you can tell the native UWP gets messages consistently using either the mouse or touch as you would expect. 

If the messages were never sent, I would assume the behavior was intended, but since instead the messages are sometimes routed correctly, there seems to be a problem with the message routing to the UWP Canvas derived class. 

I have provided cleaned samples for both the Xamarin.Forms and the native UWP. Here are messages that successfully were routed in the Xamarin.Forms app, however most of the time, they never reach the methods.

I'm trying to implement 3d graphics on all 3 platforms and provide zoom/pan and selection of objects, the GestureClasses are deficient for my needs since they are really manipulating the images and not causing the draw events to fire. I think maybe the view is losing the focus and not getting the messages? 

Let me know if you need more information, however if you build the two projects, run the Xamarin.Forms UWP , then run the native UWP you can see the issue. The output goes to the console, but also if the ManipulateStarted event fires I set the Opacity to you can tell it was hit, when it is completed the Opacity goes back to 1

Alan Anderson
Comment 3 Alan Anderson 2016-11-11 23:00:56 UTC
Here are messages from the XamarinUWP sample - when the events get through, which frankly aren't that often.

OnStart, Windows.UI.Xaml.Input.ManipulationStartedRoutedEventArgs
Translation 3.28818893432617, -1.53101003170013
Translation 11.2818880081177, -1.54854142665863
Translation 6.9165358543396, -1.39764010906219
Translation 3.2982771396637, -1.54833686351776
Translation 5.49921417236328, -1.5850795507431
Translation 6.5196852684021, -2.23723173141479
Translation 5.27244091033936, -3.40172553062439
Translation 4.81889772415161, -3.55244660377502
Translation 5.4425196647644, -3.37792468070984
Comment 4 Alan Anderson 2016-11-11 23:22:07 UTC
If you add a this.PointerMoved += OnPointerMoved in the GraphicDisplayView constructor

Then add

        private void OnPointerMoved(object sender, PointerRoutedEventArgs e)
            if (e.Pointer.IsInContact)
                Debug.WriteLine($"Pointer InContact Moved {e.GetCurrentPoint(this).Position.X}, {e.GetCurrentPoint(this).Position.Y}");


You can see that PointerMoved messages (when InContact) are routed successfully. 

Comment 5 Alan Anderson 2016-11-14 16:18:26 UTC
I think I figured out the issue, the messages go to the custom renderer and not to the Canvas derived class itself. If I add the events to the renderer, it gets all the messages correctly.

If this is the expected behavior, this bug can be closed.

Alan Anderson
Comment 6 Alan Anderson 2016-11-14 16:23:34 UTC
The comment 5 is premature, it still doesn't work consistently - added in the renderer or in the view.
Comment 7 Paul DiPietro [MSFT] 2017-03-14 17:29:26 UTC
I can see what you're referring to as it appears there might be some kind of delay in the cases where it occurs. This will require further investigation. Thank you for the reproduction project as well.