Use nanoTime instead of currentTimeMillis for events
Summary: Public We wanted to do this before, but couldn't because touch events had timestamps set by the system (and matched System.currentTimeMillis), but now we set those timestamps! The idea behind this change is that System.currentTimeMillis is unreliable, but nanoTime isn't, and it also guarantees that we will never have two events with the same timestamp. We're still seeing crashes with touch events not ending correctly in JS, this might be the cause of that. Reviewed By: foghina Differential Revision: D2953917
This commit is contained in:
parent
3e30b70e29
commit
addd233d31
|
@ -9,16 +9,15 @@
|
||||||
|
|
||||||
package com.facebook.react.flat;
|
package com.facebook.react.flat;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.SystemClock;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -26,8 +25,9 @@ import android.view.ViewParent;
|
||||||
|
|
||||||
import com.facebook.react.bridge.ReactContext;
|
import com.facebook.react.bridge.ReactContext;
|
||||||
import com.facebook.react.bridge.SoftAssertions;
|
import com.facebook.react.bridge.SoftAssertions;
|
||||||
import com.facebook.react.touch.ReactInterceptingViewGroup;
|
import com.facebook.react.common.SystemClock;
|
||||||
import com.facebook.react.touch.OnInterceptTouchEventListener;
|
import com.facebook.react.touch.OnInterceptTouchEventListener;
|
||||||
|
import com.facebook.react.touch.ReactInterceptingViewGroup;
|
||||||
import com.facebook.react.uimanager.PointerEvents;
|
import com.facebook.react.uimanager.PointerEvents;
|
||||||
import com.facebook.react.uimanager.ReactCompoundView;
|
import com.facebook.react.uimanager.ReactCompoundView;
|
||||||
import com.facebook.react.uimanager.ReactPointerEventsView;
|
import com.facebook.react.uimanager.ReactPointerEventsView;
|
||||||
|
@ -68,7 +68,7 @@ import com.facebook.react.views.image.ImageLoadEvent;
|
||||||
ReactContext reactContext = ((ReactContext) view.getContext());
|
ReactContext reactContext = ((ReactContext) view.getContext());
|
||||||
UIManagerModule uiManagerModule = reactContext.getNativeModule(UIManagerModule.class);
|
UIManagerModule uiManagerModule = reactContext.getNativeModule(UIManagerModule.class);
|
||||||
uiManagerModule.getEventDispatcher().dispatchEvent(
|
uiManagerModule.getEventDispatcher().dispatchEvent(
|
||||||
new ImageLoadEvent(reactTag, SystemClock.uptimeMillis(), imageLoadEvent));
|
new ImageLoadEvent(reactTag, SystemClock.nanoTime(), imageLoadEvent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ import com.facebook.react.views.image.ImageLoadEvent;
|
||||||
// height is 0. This is because invalidate() has an optimization where it will not invalidate
|
// height is 0. This is because invalidate() has an optimization where it will not invalidate
|
||||||
// empty Views at all. A quick fix is to invalidate a slightly larger region to make sure we
|
// empty Views at all. A quick fix is to invalidate a slightly larger region to make sure we
|
||||||
// never hit that optimization.
|
// never hit that optimization.
|
||||||
//
|
//
|
||||||
// Another thing to note is that this may not work correctly with software rendering because
|
// Another thing to note is that this may not work correctly with software rendering because
|
||||||
// in software, Android tracks dirty regions to redraw. We would need to collect information
|
// in software, Android tracks dirty regions to redraw. We would need to collect information
|
||||||
// about all children boundaries (recursively) to track dirty region precisely.
|
// about all children boundaries (recursively) to track dirty region precisely.
|
||||||
|
|
Loading…
Reference in New Issue