From f58a3b9ef46c52d5bd964a3ef855a5e9f2e03d2b Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 24 Sep 2021 18:09:46 -0700 Subject: [PATCH] Back out "Send UNIX timestamp along with JS touch events, instead of systemUptime" Summary: Original commit changeset: 0f2db726048f This original change was made in D26705430 (https://github.com/facebook/react-native/commit/b08362ade5d68af4b6c66d5cf0dab5f42a2ec894) and D26705429 (https://github.com/facebook/react-native/commit/69feed518d01a7d91f0c71509429c4388912131c). The intention was to change the timestamp definition to make touch telemetry easier, but this is (1) unnecessary and (2) causes other issues. Changelog: [internal] Reviewed By: mdvacca Differential Revision: D31183732 fbshipit-source-id: ddc6aafe95dd45fe847524eb65b8a00852381f6d --- .../facebook/react/uimanager/events/Event.java | 16 ---------------- .../react/uimanager/events/TouchesHelper.java | 2 +- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java index 37a79ac274a..b045cd8984f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java @@ -40,15 +40,6 @@ public abstract class Event { private long mTimestampMs; private int mUniqueID = sUniqueID++; - // Android native Event times use 'uptimeMillis', and historically we've used `uptimeMillis` - // throughout this Event class as the coalescing key for events, and for other purposes. - // To get an accurate(ish) absolute UNIX time for the event, we store the initial clock time here. - // uptimeMillis can then be added to this to get an accurate UNIX time. - // However, we still default to uptimeMillis: you must explicitly request UNIX time if you want - // that; see `getUnixTimestampMs`. - public static final long sInitialClockTimeUnixOffset = - SystemClock.currentTimeMillis() - SystemClock.uptimeMillis(); - protected Event() {} @Deprecated @@ -82,9 +73,7 @@ public abstract class Event { // At some point it would be great to pass the SurfaceContext here instead. mUIManagerType = (surfaceId == -1 ? UIManagerType.DEFAULT : UIManagerType.FABRIC); - // This is a *relative* time. See `getUnixTimestampMs`. mTimestampMs = SystemClock.uptimeMillis(); - mInitialized = true; } @@ -106,11 +95,6 @@ public abstract class Event { return mTimestampMs; } - /** @return the time at which the event happened as a UNIX timestamp, in milliseconds. */ - public final long getUnixTimestampMs() { - return sInitialClockTimeUnixOffset + mTimestampMs; - } - /** @return false if this Event can *never* be coalesced */ public boolean canCoalesce() { return true; diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java index b67f6e3eff0..187e6121160 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java @@ -64,7 +64,7 @@ public class TouchesHelper { touch.putDouble(LOCATION_Y_KEY, PixelUtil.toDIPFromPixel(locationY)); touch.putInt(TARGET_SURFACE_KEY, surfaceId); touch.putInt(TARGET_KEY, reactTarget); - touch.putDouble(TIMESTAMP_KEY, event.getUnixTimestampMs()); + touch.putDouble(TIMESTAMP_KEY, event.getTimestampMs()); touch.putDouble(POINTER_IDENTIFIER_KEY, motionEvent.getPointerId(index)); touches.pushMap(touch); }