Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<b7ef80c2c39c734ae511fe6457b89ce7>>
* @generated SignedSource<<d2d65cecfe7e05e7d4d04fc54c904e60>>
*/

/**
Expand Down Expand Up @@ -60,6 +60,12 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun disableEarlyViewCommandExecution(): Boolean = accessor.disableEarlyViewCommandExecution()

/**
* Stop re-arming the TIMERS_EVENTS Choreographer frame callback at vsync rate while the timer queue is empty on Android; createTimer re-arms it lazily
*/
@JvmStatic
public fun disableIdleTimersFrameCallbackRearmAndroid(): Boolean = accessor.disableIdleTimersFrameCallbackRearmAndroid()

/**
* Force disable view preallocation for images triggered from createNode off the main thread on Android
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<68aefd0293540d56f57e8badc0de04c8>>
* @generated SignedSource<<e601df5e10547f5a92e005f57c09a1b3>>
*/

/**
Expand All @@ -25,6 +25,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
private var cxxNativeAnimatedEnabledCache: Boolean? = null
private var defaultTextToOverflowHiddenCache: Boolean? = null
private var disableEarlyViewCommandExecutionCache: Boolean? = null
private var disableIdleTimersFrameCallbackRearmAndroidCache: Boolean? = null
private var disableImageViewPreallocationAndroidCache: Boolean? = null
private var disableMountItemReorderingAndroidCache: Boolean? = null
private var disableSubviewClippingAndroidCache: Boolean? = null
Expand Down Expand Up @@ -152,6 +153,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
return cached
}

override fun disableIdleTimersFrameCallbackRearmAndroid(): Boolean {
var cached = disableIdleTimersFrameCallbackRearmAndroidCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.disableIdleTimersFrameCallbackRearmAndroid()
disableIdleTimersFrameCallbackRearmAndroidCache = cached
}
return cached
}

override fun disableImageViewPreallocationAndroid(): Boolean {
var cached = disableImageViewPreallocationAndroidCache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<247f721796621af8615014477518bcd9>>
* @generated SignedSource<<e83d4ef1dff441f096e0e05f0762f47b>>
*/

/**
Expand Down Expand Up @@ -38,6 +38,8 @@ public object ReactNativeFeatureFlagsCxxInterop {

@DoNotStrip @JvmStatic public external fun disableEarlyViewCommandExecution(): Boolean

@DoNotStrip @JvmStatic public external fun disableIdleTimersFrameCallbackRearmAndroid(): Boolean

@DoNotStrip @JvmStatic public external fun disableImageViewPreallocationAndroid(): Boolean

@DoNotStrip @JvmStatic public external fun disableMountItemReorderingAndroid(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<33071257f9c96a8664c9af429e387061>>
* @generated SignedSource<<d329c4772411b7a603e4e106cac3b516>>
*/

/**
Expand Down Expand Up @@ -33,6 +33,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun disableEarlyViewCommandExecution(): Boolean = false

override fun disableIdleTimersFrameCallbackRearmAndroid(): Boolean = false

override fun disableImageViewPreallocationAndroid(): Boolean = false

override fun disableMountItemReorderingAndroid(): Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<f218220c66b8367211cae49adba46afc>>
* @generated SignedSource<<8c79cf348cdf6e6705d6b8dac2c8482a>>
*/

/**
Expand All @@ -29,6 +29,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
private var cxxNativeAnimatedEnabledCache: Boolean? = null
private var defaultTextToOverflowHiddenCache: Boolean? = null
private var disableEarlyViewCommandExecutionCache: Boolean? = null
private var disableIdleTimersFrameCallbackRearmAndroidCache: Boolean? = null
private var disableImageViewPreallocationAndroidCache: Boolean? = null
private var disableMountItemReorderingAndroidCache: Boolean? = null
private var disableSubviewClippingAndroidCache: Boolean? = null
Expand Down Expand Up @@ -161,6 +162,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
return cached
}

override fun disableIdleTimersFrameCallbackRearmAndroid(): Boolean {
var cached = disableIdleTimersFrameCallbackRearmAndroidCache
if (cached == null) {
cached = currentProvider.disableIdleTimersFrameCallbackRearmAndroid()
accessedFeatureFlags.add("disableIdleTimersFrameCallbackRearmAndroid")
disableIdleTimersFrameCallbackRearmAndroidCache = cached
}
return cached
}

override fun disableImageViewPreallocationAndroid(): Boolean {
var cached = disableImageViewPreallocationAndroidCache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<bad3dbaf92a0a869dfb91523ef4904f9>>
* @generated SignedSource<<a3427f1f1d9939d368b781e251cb8d03>>
*/

/**
Expand All @@ -23,6 +23,8 @@ public open class ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android :
// We could use JNI to get the defaults from C++,
// but that is more expensive than just duplicating the defaults here.

override fun disableIdleTimersFrameCallbackRearmAndroid(): Boolean = true

override fun enableFlexboxAutoMinSizeInStrictMode(): Boolean = true

override fun preventShadowTreeCommitExhaustion(): Boolean = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<915bf918212b9898319de61d4cadaa13>>
* @generated SignedSource<<2b86c6b4f9923a97602642ac2b11a58d>>
*/

/**
Expand Down Expand Up @@ -33,6 +33,8 @@ public interface ReactNativeFeatureFlagsProvider {

@DoNotStrip public fun disableEarlyViewCommandExecution(): Boolean

@DoNotStrip public fun disableIdleTimersFrameCallbackRearmAndroid(): Boolean

@DoNotStrip public fun disableImageViewPreallocationAndroid(): Boolean

@DoNotStrip public fun disableMountItemReorderingAndroid(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.facebook.react.common.SystemClock.nanoTime
import com.facebook.react.common.SystemClock.uptimeMillis
import com.facebook.react.common.annotations.internal.LegacyArchitecture
import com.facebook.react.devsupport.interfaces.DevSupportManager
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.jstasks.HeadlessJsTaskContext
import com.facebook.react.jstasks.HeadlessJsTaskEventListener
import java.util.PriorityQueue
Expand Down Expand Up @@ -186,6 +187,16 @@ public open class JavaTimerManager(
timers.add(timer)
timerIdsToTimers.put(timerId, timer)
}
if (ReactNativeFeatureFlags.disableIdleTimersFrameCallbackRearmAndroid() &&
!frameCallbackPosted &&
(!isPaused.get() || isRunningTasks.get())) {
// The timers frame callback disarms itself once the queue drains (see TimerFrameCallback);
// re-arm it lazily when a new timer arrives. setChoreographerCallback is UI-confined
// (ReactChoreographer must be driven from the UI looper) and idempotent, so hop to the UI
// thread. While the host is paused, only headless JS task execution may run timers —
// mirroring the guard in clearFrameCallback.
UiThreadUtil.runOnUiThread { setChoreographerCallback() }
}
}

/**
Expand Down Expand Up @@ -292,6 +303,7 @@ public open class JavaTimerManager(
return
}
val frameTimeMillis = frameTimeNanos / 1000000
var shouldRepost = true
synchronized(timerGuard) {
while (!timers.isEmpty() && timers.peek()!!.targetTime < frameTimeMillis) {
var timer = timers.poll()
Expand All @@ -309,12 +321,22 @@ public open class JavaTimerManager(
timerIdsToTimers.remove(timer.timerId)
}
}
if (ReactNativeFeatureFlags.disableIdleTimersFrameCallbackRearmAndroid()) {
// The timer queue is empty: disarm instead of re-posting this callback at vsync rate.
// createTimer re-arms the callback when a new timer arrives.
shouldRepost = timers.isNotEmpty()
if (!shouldRepost) {
frameCallbackPosted = false
}
}
}
timersToCall?.let { timers ->
javaScriptTimerExecutor.callTimers(timers)
timersToCall = null
}
reactChoreographer.postFrameCallback(ReactChoreographer.CallbackType.TIMERS_EVENTS, this)
if (shouldRepost) {
reactChoreographer.postFrameCallback(ReactChoreographer.CallbackType.TIMERS_EVENTS, this)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<177c5cc7f6e970a2d4454c32d7f777ef>>
* @generated SignedSource<<14d8d9fb09b9c47aa6efa35fd521699e>>
*/

/**
Expand Down Expand Up @@ -69,6 +69,12 @@ class ReactNativeFeatureFlagsJavaProvider
return method(javaProvider_);
}

bool disableIdleTimersFrameCallbackRearmAndroid() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("disableIdleTimersFrameCallbackRearmAndroid");
return method(javaProvider_);
}

bool disableImageViewPreallocationAndroid() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("disableImageViewPreallocationAndroid");
Expand Down Expand Up @@ -584,6 +590,11 @@ bool JReactNativeFeatureFlagsCxxInterop::disableEarlyViewCommandExecution(
return ReactNativeFeatureFlags::disableEarlyViewCommandExecution();
}

bool JReactNativeFeatureFlagsCxxInterop::disableIdleTimersFrameCallbackRearmAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::disableIdleTimersFrameCallbackRearmAndroid();
}

bool JReactNativeFeatureFlagsCxxInterop::disableImageViewPreallocationAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::disableImageViewPreallocationAndroid();
Expand Down Expand Up @@ -1035,6 +1046,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"disableEarlyViewCommandExecution",
JReactNativeFeatureFlagsCxxInterop::disableEarlyViewCommandExecution),
makeNativeMethod(
"disableIdleTimersFrameCallbackRearmAndroid",
JReactNativeFeatureFlagsCxxInterop::disableIdleTimersFrameCallbackRearmAndroid),
makeNativeMethod(
"disableImageViewPreallocationAndroid",
JReactNativeFeatureFlagsCxxInterop::disableImageViewPreallocationAndroid),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<eab10e240a16c8ef3f659bd8ded290f0>>
* @generated SignedSource<<5cc6a0602af0ce7ae394f41adde13ee0>>
*/

/**
Expand Down Expand Up @@ -45,6 +45,9 @@ class JReactNativeFeatureFlagsCxxInterop
static bool disableEarlyViewCommandExecution(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

static bool disableIdleTimersFrameCallbackRearmAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

static bool disableImageViewPreallocationAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<7b726d7483bb35062b79e582323f0d7e>>
* @generated SignedSource<<27db13f91b9672274086048a7a970362>>
*/

/**
Expand Down Expand Up @@ -46,6 +46,10 @@ bool ReactNativeFeatureFlags::disableEarlyViewCommandExecution() {
return getAccessor().disableEarlyViewCommandExecution();
}

bool ReactNativeFeatureFlags::disableIdleTimersFrameCallbackRearmAndroid() {
return getAccessor().disableIdleTimersFrameCallbackRearmAndroid();
}

bool ReactNativeFeatureFlags::disableImageViewPreallocationAndroid() {
return getAccessor().disableImageViewPreallocationAndroid();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<1e9009301b79f977132c4fa5599aebdd>>
* @generated SignedSource<<4850b4600168e52a55b10165de7dca48>>
*/

/**
Expand Down Expand Up @@ -66,6 +66,11 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool disableEarlyViewCommandExecution();

/**
* Stop re-arming the TIMERS_EVENTS Choreographer frame callback at vsync rate while the timer queue is empty on Android; createTimer re-arms it lazily
*/
RN_EXPORT static bool disableIdleTimersFrameCallbackRearmAndroid();

/**
* Force disable view preallocation for images triggered from createNode off the main thread on Android
*/
Expand Down
Loading