Refactor touch event dispatch

Summary:
Updates touch events in Fabric to be dispatched through the same pipeline as the rest of events, instead of relying on custom dispatch behavior.

Previous method of handling touches was reusing Paper behavior which required:
1. Transform event into a Paper-compatible form of WritableArray and dispatch it to `RCTEventEmitter.receiveTouches`.
2. Intercept `receiveTouches` for Fabric and redirect it to `FabricEventEmitter`
3. Perform transformations copied from Paper JS renderer in Java, transform it to the final form and dispatch this event as usual after.

The new behavior uses emitter's `receiveEvent` method directly to dispatch events. Additionally, it should decrease allocations done when transforming events during step 3 above, as `WritableNativeMap`-based operations performed many re-allocations when reading/re-creating arrays.

Changelog:
[Android][Changed] - Added an experimental touch dispatch path

Reviewed By: JoshuaGross

Differential Revision: D31280052

fbshipit-source-id: 829c2646ac6b0ebff0f0106159e76d84324ac732
This commit is contained in:
Andrei Shikov
2021-10-14 05:19:17 -07:00
committed by Facebook GitHub Bot
parent 53fd0f4026
commit a2feaeb5f1
3 changed files with 143 additions and 6 deletions
@@ -103,4 +103,6 @@ public class ReactFeatureFlags {
public static boolean enableScrollViewSnapToAlignmentProp = true;
public static boolean useDispatchUniqueForCoalescableEvents = false;
public static boolean useUpdatedTouchPreprocessing = false;
}