mirror of
https://github.com/status-im/react-native.git
synced 2025-01-16 04:24:15 +00:00
RN: Increase Time Drift Threshold
Summary: Increases time drift threshold to reduce chance of false positives. Also, tweaked the error message to contain slightly more information. Reviewed By: frantic Differential Revision: D3450852 fbshipit-source-id: 7fbf3eb25543977f9767c7a57277db336006bd12
This commit is contained in:
parent
8ca3a0c91c
commit
a2f78825f2
@ -217,16 +217,27 @@ public final class Timing extends ReactContextBaseJavaModule implements Lifecycl
|
|||||||
final int duration,
|
final int duration,
|
||||||
final double jsSchedulingTime,
|
final double jsSchedulingTime,
|
||||||
final boolean repeat) {
|
final boolean repeat) {
|
||||||
|
long deviceTime = SystemClock.currentTimeMillis();
|
||||||
|
long remoteTime = (long) jsSchedulingTime;
|
||||||
|
|
||||||
// If the times on the server and device have drifted throw an exception to warn the developer
|
// If the times on the server and device have drifted throw an exception to warn the developer
|
||||||
// that things might not work or results may not be accurate. This is required only for
|
// that things might not work or results may not be accurate. This is required only for
|
||||||
// developer builds.
|
// developer builds.
|
||||||
if (mDevSupportManager.getDevSupportEnabled() && Math.abs(jsSchedulingTime - System.currentTimeMillis()) > 1000) {
|
if (mDevSupportManager.getDevSupportEnabled()) {
|
||||||
throw new RuntimeException("System and emulator/device times have drifted. Please correct this by running adb shell \"date `date +%m%d%H%M%Y.%S`\" on your dev machine");
|
long driftTime = Math.abs(remoteTime - deviceTime);
|
||||||
|
if (driftTime > 60000) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"Debugger and device times have drifted by " + driftTime + "ms. " +
|
||||||
|
"Please correct this by running adb shell " +
|
||||||
|
"\"date `date +%m%d%H%M%Y.%S`\" on your debugger machine.\n" +
|
||||||
|
"Debugger Time = " + remoteTime + "\n" +
|
||||||
|
"Device Time = " + deviceTime
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust for the amount of time it took for native to receive the timer registration call
|
// Adjust for the amount of time it took for native to receive the timer registration call
|
||||||
long adjustedDuration = (long) Math.max(
|
long adjustedDuration = Math.max(0, remoteTime - deviceTime + duration);
|
||||||
0,
|
|
||||||
jsSchedulingTime - SystemClock.currentTimeMillis() + duration);
|
|
||||||
if (duration == 0 && !repeat) {
|
if (duration == 0 && !repeat) {
|
||||||
WritableArray timerToCall = Arguments.createArray();
|
WritableArray timerToCall = Arguments.createArray();
|
||||||
timerToCall.pushInt(callbackID);
|
timerToCall.pushInt(callbackID);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user