From ed6a3a6c74e2abc3c6dc911aa354bcd38458cd32 Mon Sep 17 00:00:00 2001 From: Emily Janzer Date: Fri, 20 Sep 2019 13:51:37 -0700 Subject: [PATCH] Remove timer proxy Summary: Fix for crash introduced by D17282188; doesn't cleanly revert, so just reverting this part Reviewed By: JoshuaGross, RSNara Differential Revision: D17505827 fbshipit-source-id: 3232285c0f15dabeb819f8806ad35d4ec83a1e53 --- .../react/modules/core/JavaTimerManager.java | 19 ++++++++------- .../react/modules/core/TimingModule.java | 24 +------------------ 2 files changed, 11 insertions(+), 32 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java b/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java index a0ddde70eb5..01799dd138b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java @@ -73,7 +73,7 @@ public class JavaTimerManager { } if (mTimersToCall != null) { - mJSTimers.callTimers(mTimersToCall); + mReactApplicationContext.getJSModule(JSTimers.class).callTimers(mTimersToCall); mTimersToCall = null; } @@ -131,7 +131,9 @@ public class JavaTimerManager { } if (sendIdleEvents) { - mJSTimers.callIdleCallbacks(absoluteFrameStartTime); + mReactApplicationContext + .getJSModule(JSTimers.class) + .callIdleCallbacks(absoluteFrameStartTime); } mCurrentIdleCallbackRunnable = null; @@ -143,7 +145,6 @@ public class JavaTimerManager { } private final ReactApplicationContext mReactApplicationContext; - private final JSTimers mJSTimers; private final ReactChoreographer mReactChoreographer; private final DevSupportManager mDevSupportManager; private final Object mTimerGuard = new Object(); @@ -161,11 +162,9 @@ public class JavaTimerManager { public JavaTimerManager( ReactApplicationContext reactContext, - JSTimers jsTimers, ReactChoreographer reactChoreographer, DevSupportManager devSupportManager) { mReactApplicationContext = reactContext; - mJSTimers = jsTimers; mReactChoreographer = reactChoreographer; mDevSupportManager = devSupportManager; @@ -318,9 +317,11 @@ public class JavaTimerManager { if (mDevSupportManager.getDevSupportEnabled()) { long driftTime = Math.abs(remoteTime - deviceTime); if (driftTime > 60000) { - mJSTimers.emitTimeDriftWarning( - "Debugger and device times have drifted by more than 60s. Please correct this by " - + "running adb shell \"date `date +%m%d%H%M%Y.%S`\" on your debugger machine."); + mReactApplicationContext + .getJSModule(JSTimers.class) + .emitTimeDriftWarning( + "Debugger and device times have drifted by more than 60s. Please correct this by " + + "running adb shell \"date `date +%m%d%H%M%Y.%S`\" on your debugger machine."); } } @@ -329,7 +330,7 @@ public class JavaTimerManager { if (duration == 0 && !repeat) { WritableArray timerToCall = Arguments.createArray(); timerToCall.pushInt(callbackID); - mJSTimers.callTimers(timerToCall); + mReactApplicationContext.getJSModule(JSTimers.class).callTimers(timerToCall); return; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.java index db9ed71c0b9..d656eb878d2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.java @@ -10,7 +10,6 @@ import com.facebook.react.bridge.LifecycleEventListener; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.WritableArray; import com.facebook.react.devsupport.interfaces.DevSupportManager; import com.facebook.react.jstasks.HeadlessJsTaskContext; import com.facebook.react.jstasks.HeadlessJsTaskEventListener; @@ -28,29 +27,8 @@ public final class TimingModule extends ReactContextBaseJavaModule public TimingModule(ReactApplicationContext reactContext, DevSupportManager devSupportManager) { super(reactContext); - JSTimers jsTimersProxy = - new JSTimers() { - @Override - public void callTimers(WritableArray timerIDs) { - getReactApplicationContext().getJSModule(JSTimers.class).callTimers(timerIDs); - } - - @Override - public void callIdleCallbacks(double frameTime) { - getReactApplicationContext().getJSModule(JSTimers.class).callIdleCallbacks(frameTime); - } - - @Override - public void emitTimeDriftWarning(String warningMessage) { - getReactApplicationContext() - .getJSModule(JSTimers.class) - .emitTimeDriftWarning(warningMessage); - } - }; - mJavaTimerManager = - new JavaTimerManager( - reactContext, jsTimersProxy, ReactChoreographer.getInstance(), devSupportManager); + new JavaTimerManager(reactContext, ReactChoreographer.getInstance(), devSupportManager); } @Override