.NET MAUI - Issue with Gestures while Canvas is Invalidated
In a basic .NET MAUI application, when a user tries to perform a gesture on a page containing a GraphicsView while the canvas is (re)drawn leads to a "unmanaged exception". After several attempts to identify the source of the problem, the following steps were taken to reproduce the issue (tested only on Win 11):
- Create a basic page and add any implementation of GraphicsView with any IDrawable that implements the "Draw" method (for example, canvas.DrawImage(...) with a MemoryStream).
- Trigger the "Draw" method by calling Invalidate() on the view to force a refresh. This can be done through a timer or any other method.
- Then, perform a gesture on the screen (drag, drop, pan, etc.) even if there is no event handled.
- It seems that if the "Invalidate()" causing refresh occurs While the gesture, the app crashes.
Another way to get the same issue is to react on PanGestureRecognizer_PanUpdated, when GestureStatus.Running and call Invalidate() to refresh the canvas. It seems this issue occurs when the "Invalidate()" causing a refresh occurs while a gesture is being performed
This randomly leads to a "Win32 non managed exception." It is believed that this is because the component is "reset" during the Invalidate() on a start/stop interaction. This is a real problem if the view needs to be refreshed because the user is actually drawing on it.
Can anyone provide help with this issue? Is there a way to refresh the canvas content while actually drawing on it ?
Any sample for a basic "paint" app ?
Thanks in advance for any explanation.