Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds feature flag for onLayout event coalescing #46364

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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<<6cc52570dd571ddc792a0fd842c05dd9>>
* @generated SignedSource<<f6470a89519ac47c09bca5dd9353a1e4>>
*/

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

/**
* When enabled, the Fabric onLayout event will be coalesced by dispatching with dispatchUniqueEvent.
*/
@JvmStatic
public fun coalesceOnLayoutEvents(): Boolean = accessor.coalesceOnLayoutEvents()

/**
* Do not wait for a main-thread dispatch to complete init to start executing work on the JS 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<<eca842a1b1c823b72136c625b3bfd16e>>
* @generated SignedSource<<7f020c68199644e4ffa8b01bb40659d4>>
*/

/**
Expand All @@ -23,6 +23,7 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var commonTestFlagCache: Boolean? = null
private var allowRecursiveCommitsWithSynchronousMountOnAndroidCache: Boolean? = null
private var batchRenderingUpdatesInEventLoopCache: Boolean? = null
private var coalesceOnLayoutEventsCache: Boolean? = null
private var completeReactInstanceCreationOnBgThreadOnAndroidCache: Boolean? = null
private var destroyFabricSurfacesInReactInstanceManagerCache: Boolean? = null
private var enableAlignItemsBaselineOnFabricIOSCache: Boolean? = null
Expand Down Expand Up @@ -96,6 +97,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}

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

override fun completeReactInstanceCreationOnBgThreadOnAndroid(): Boolean {
var cached = completeReactInstanceCreationOnBgThreadOnAndroidCache
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<<ad54375c4ae3be2f377260887ae5aaf9>>
* @generated SignedSource<<ea9374ed3adaf5d41a8a1cd0569c35ac>>
*/

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

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

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

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

@DoNotStrip @JvmStatic public external fun destroyFabricSurfacesInReactInstanceManager(): 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<<2a0cd5a4875a54bb724e5765ffe7753e>>
* @generated SignedSource<<353196c285c62f4304d612a57417cb6a>>
*/

/**
Expand All @@ -29,6 +29,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun batchRenderingUpdatesInEventLoop(): Boolean = false

override fun coalesceOnLayoutEvents(): Boolean = false

override fun completeReactInstanceCreationOnBgThreadOnAndroid(): Boolean = false

override fun destroyFabricSurfacesInReactInstanceManager(): 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<<d02af2a8ef015c57d45aba8280539606>>
* @generated SignedSource<<3016538257cf64e360de0e6a0ed45ba2>>
*/

/**
Expand All @@ -27,6 +27,7 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var commonTestFlagCache: Boolean? = null
private var allowRecursiveCommitsWithSynchronousMountOnAndroidCache: Boolean? = null
private var batchRenderingUpdatesInEventLoopCache: Boolean? = null
private var coalesceOnLayoutEventsCache: Boolean? = null
private var completeReactInstanceCreationOnBgThreadOnAndroidCache: Boolean? = null
private var destroyFabricSurfacesInReactInstanceManagerCache: Boolean? = null
private var enableAlignItemsBaselineOnFabricIOSCache: Boolean? = null
Expand Down Expand Up @@ -103,6 +104,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}

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

override fun completeReactInstanceCreationOnBgThreadOnAndroid(): Boolean {
var cached = completeReactInstanceCreationOnBgThreadOnAndroidCache
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<<92b1214e3a526d7c67dcc7b0c2a131de>>
* @generated SignedSource<<34af2926e822628b1c6f3313b25db9fe>>
*/

/**
Expand All @@ -29,6 +29,8 @@ public interface ReactNativeFeatureFlagsProvider {

@DoNotStrip public fun batchRenderingUpdatesInEventLoop(): Boolean

@DoNotStrip public fun coalesceOnLayoutEvents(): Boolean

@DoNotStrip public fun completeReactInstanceCreationOnBgThreadOnAndroid(): Boolean

@DoNotStrip public fun destroyFabricSurfacesInReactInstanceManager(): 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<<c23b21fca18699470580e54b99de1126>>
* @generated SignedSource<<9a874be28601d8847c998cbd77a0159b>>
*/

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

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

bool completeReactInstanceCreationOnBgThreadOnAndroid() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("completeReactInstanceCreationOnBgThreadOnAndroid");
Expand Down Expand Up @@ -346,6 +352,11 @@ bool JReactNativeFeatureFlagsCxxInterop::batchRenderingUpdatesInEventLoop(
return ReactNativeFeatureFlags::batchRenderingUpdatesInEventLoop();
}

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

bool JReactNativeFeatureFlagsCxxInterop::completeReactInstanceCreationOnBgThreadOnAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::completeReactInstanceCreationOnBgThreadOnAndroid();
Expand Down Expand Up @@ -597,6 +608,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"batchRenderingUpdatesInEventLoop",
JReactNativeFeatureFlagsCxxInterop::batchRenderingUpdatesInEventLoop),
makeNativeMethod(
"coalesceOnLayoutEvents",
JReactNativeFeatureFlagsCxxInterop::coalesceOnLayoutEvents),
makeNativeMethod(
"completeReactInstanceCreationOnBgThreadOnAndroid",
JReactNativeFeatureFlagsCxxInterop::completeReactInstanceCreationOnBgThreadOnAndroid),
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<<89d0da3b2bb56a4ee3c887e6c57491b2>>
* @generated SignedSource<<1d8cfaa9b86400f61db540a2f8d25ebc>>
*/

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

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

static bool completeReactInstanceCreationOnBgThreadOnAndroid(
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<<6139aa47aac3e5682a453a416bc10236>>
* @generated SignedSource<<8987cb4c07891b8b5716d6ac18677a11>>
*/

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

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

bool ReactNativeFeatureFlags::completeReactInstanceCreationOnBgThreadOnAndroid() {
return getAccessor().completeReactInstanceCreationOnBgThreadOnAndroid();
}
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<<c8266eb27ec23aaa856fa95275503a81>>
* @generated SignedSource<<b891ab975bd5d25e6334f52be6b5ace2>>
*/

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

/**
* When enabled, the Fabric onLayout event will be coalesced by dispatching with dispatchUniqueEvent.
*/
RN_EXPORT static bool coalesceOnLayoutEvents();

/**
* Do not wait for a main-thread dispatch to complete init to start executing work on the JS thread on Android
*/
Expand Down
Loading
Loading