Skip to content

Commit 3e2acb4

Browse files
authored
[Android] Fix crash in GraphicsView when using TapGestureRecognizer (dotnet#34301)
### Description of Change Fixes a crash on Android when using `TapGestureRecognizer` with `GraphicsView`. ### Root Cause `PlatformTouchGraphicsView.TouchesMoved` assumed that `_lastMovedViewPoints` always contained at least one element. In certain touch event sequences (triggered when a TapGestureRecognizer is attached), `_lastMovedViewPoints` could be empty while `points.Length == 1`, leading to an IndexOutOfRangeException. ### Fix Added a length check before accessing `_lastMovedViewPoints[0]` to prevent out-of-range access. ### Verified Scenarios - TapGestureRecognizer no longer causes a crash - Tap events fire correctly - Drag interaction remains functional - Multitouch does not crash Fixes dotnet#34296
1 parent 2c6474f commit 3e2acb4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/Core/src/Platform/Android/PlatformTouchGraphicsView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void TouchesMoved(PointF[] points)
8989
{
9090
if (!_dragStarted)
9191
{
92-
if (points.Length == 1)
92+
if (points.Length == 1 && _lastMovedViewPoints.Length > 0)
9393
{
9494
float deltaX = _lastMovedViewPoints[0].X - points[0].X;
9595
float deltaY = _lastMovedViewPoints[0].Y - points[0].Y;

0 commit comments

Comments
 (0)