diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 12cd26ec4bad92..72e4d9f4da80ab 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -3306,7 +3306,6 @@ public final class com/facebook/react/modules/core/TimingModule : com/facebook/f public fun createTimer (DDDZ)V public fun deleteTimer (D)V public fun emitTimeDriftWarning (Ljava/lang/String;)V - public fun initialize ()V public fun invalidate ()V public fun setSendIdleEvents (Z)V } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.kt index ecce67478dd9d0..8b6571698fc5dd 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.kt @@ -65,6 +65,7 @@ public open class JavaTimerManager( init { reactApplicationContext.addLifecycleEventListener(this) + HeadlessJsTaskContext.getInstance(reactApplicationContext).addTaskEventListener(this) } override fun onHostPause() { @@ -103,6 +104,7 @@ public open class JavaTimerManager( } public open fun onInstanceDestroy() { + HeadlessJsTaskContext.getInstance(reactApplicationContext).removeTaskEventListener(this) reactApplicationContext.removeLifecycleEventListener(this) clearFrameCallback() clearChoreographerIdleCallback() diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.kt index bfa0219acf2454..caf7846a322d86 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/TimingModule.kt @@ -12,7 +12,6 @@ import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.bridge.WritableArray import com.facebook.react.common.annotations.VisibleForTesting import com.facebook.react.devsupport.interfaces.DevSupportManager -import com.facebook.react.jstasks.HeadlessJsTaskContext import com.facebook.react.module.annotations.ReactModule /** Native module for JS timer execution. Timers fire on frame boundaries. */ @@ -24,11 +23,6 @@ public class TimingModule( private val javaTimerManager: JavaTimerManager = JavaTimerManager(reactContext, this, ReactChoreographer.getInstance(), devSupportManager) - override fun initialize() { - HeadlessJsTaskContext.getInstance(getReactApplicationContext()) - .addTaskEventListener(javaTimerManager) - } - override fun createTimer( callbackIDDouble: Double, durationDouble: Double, @@ -68,8 +62,6 @@ public class TimingModule( } override fun invalidate() { - val headlessJsTaskContext = HeadlessJsTaskContext.getInstance(getReactApplicationContext()) - headlessJsTaskContext.removeTaskEventListener(javaTimerManager) javaTimerManager.onInstanceDestroy() }