Copy touch objects before consuming them in new touch path

Summary:
Ensures that copy of the native touch objects happens before consuming them.

The reverse order seems accidental after refactor, as copying objects doesn't consume them whereas adding to a native array does. This behavior didn't show up during testing in dev environment (only affects CANCEL events), and it seems to be the cause of high-firing crash on production.

Changelog: [Internal] Copy touch objects before consuming them in the new touch path.

Reviewed By: mdvacca

Differential Revision: D32112036

fbshipit-source-id: e9ec47689b7ceb0a40a23bab9f03367c4acb8632
This commit is contained in:
Andrei Shikov
2021-11-03 12:08:39 -07:00
committed by Facebook GitHub Bot
parent deb6fbd929
commit 5c045861b9
@@ -158,10 +158,11 @@ public class TouchesHelper {
break;
}
WritableArray touchesArray = getWritableArray(touches);
WritableArray changedTouchesArray = getWritableArray(/* copyObjects */ true, changedTouches);
for (WritableMap touchData : changedTouches) {
WritableMap eventData = touchData.copy();
WritableArray changedTouchesArray = getWritableArray(/* copyObjects */ true, changedTouches);
WritableArray touchesArray = getWritableArray(/* copyObjects */ true, touches);
for (WritableMap eventData : changedTouches) {
eventData.putArray(CHANGED_TOUCHES_KEY, changedTouchesArray);
eventData.putArray(TOUCHES_KEY, touchesArray);