Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 0b7ed4a

Browse files
author
Kaushik Iska
committed
copy motion event and re-use it as it gets mutated later
1 parent 144c06f commit 0b7ed4a

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

shell/platform/android/io/flutter/embedding/android/MotionEventTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private MotionEventTracker() {
5050
/** Tracks the event and returns a unique MotionEventId identifying the event. */
5151
public MotionEventId track(MotionEvent event) {
5252
MotionEventId eventId = MotionEventId.createUnique();
53-
eventById.put(eventId.id, event);
53+
eventById.put(eventId.id, MotionEvent.obtain(event));
5454
unusedEvents.add(eventId.id);
5555
return eventId;
5656
}

shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,10 @@ public MotionEvent toMotionEvent(
329329
.toArray(new PointerCoords[touch.pointerCount]);
330330

331331
if (!usingVirtualDiplays && trackedEvent != null) {
332-
// TODO (kaushikiska): investigate why we can not use the tracked
333-
// event directly.
334332
return MotionEvent.obtain(
335333
trackedEvent.getDownTime(),
336334
trackedEvent.getEventTime(),
337-
touch.action,
335+
trackedEvent.getAction(),
338336
touch.pointerCount,
339337
pointerProperties,
340338
pointerCoords,

0 commit comments

Comments
 (0)