Re-enable CustomDrawOrder in RN Android (#42719)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42719

The task T175989432 started firing on October 30 2020, which correspond to the landing of D24512203. I believe disabling CustomDrawOrder could be a potential cause of T175989432, that's why in this diff I'm creating an experiment to understand what is the impact (negative or positive) of re-enabling CustomDrawOrder in RN Android

Original diff: D24512203

Changelog: [Internal] internal

Reviewed By: javache

Differential Revision: D53150292

fbshipit-source-id: f0abbc7d175c2cd717ce87bbe69aeaf3db0b0e5c
This commit is contained in:
David Vacca
2024-01-31 23:28:32 -08:00
committed by Facebook GitHub Bot
parent ebc2831d5b
commit 044b50b53d
22 changed files with 127 additions and 21 deletions
@@ -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<<82a7973a820b75c46977931a8b178493>>
* @generated SignedSource<<fccbff20f478efc0778ed7991065d189>>
*/
/**
@@ -58,6 +58,12 @@ object ReactNativeFeatureFlags {
@JvmStatic
fun enableSpannableBuildingUnification() = accessor.enableSpannableBuildingUnification()
/**
* When enabled, Fabric will use customDrawOrder in ReactViewGroup (similar to old architecture).
*/
@JvmStatic
fun enableCustomDrawOrderFabric() = accessor.enableCustomDrawOrderFabric()
/**
* Overrides the feature flags with the ones provided by the given provider
* (generally one that extends `ReactNativeFeatureFlagsDefaults`).
@@ -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<<881b7f9eb6b1765764b70719155a457c>>
* @generated SignedSource<<126de7eafa27c27df31d9d4e984ab96c>>
*/
/**
@@ -25,6 +25,7 @@ class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccessor {
private var enableMicrotasksCache: Boolean? = null
private var batchRenderingUpdatesInEventLoopCache: Boolean? = null
private var enableSpannableBuildingUnificationCache: Boolean? = null
private var enableCustomDrawOrderFabricCache: Boolean? = null
override fun commonTestFlag(): Boolean {
var cached = commonTestFlagCache
@@ -71,6 +72,15 @@ class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccessor {
return cached
}
override fun enableCustomDrawOrderFabric(): Boolean {
var cached = enableCustomDrawOrderFabricCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableCustomDrawOrderFabric()
enableCustomDrawOrderFabricCache = cached
}
return cached
}
override fun override(provider: ReactNativeFeatureFlagsProvider) =
ReactNativeFeatureFlagsCxxInterop.override(provider as Any)
@@ -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<<c4908662a6c752ef8dc85f7eb86d1df4>>
* @generated SignedSource<<7b01e2f777839812437c60503ebe321b>>
*/
/**
@@ -38,6 +38,8 @@ object ReactNativeFeatureFlagsCxxInterop {
@DoNotStrip @JvmStatic external fun enableSpannableBuildingUnification(): Boolean
@DoNotStrip @JvmStatic external fun enableCustomDrawOrderFabric(): Boolean
@DoNotStrip @JvmStatic external fun override(provider: Any)
@DoNotStrip @JvmStatic external fun dangerouslyReset()
@@ -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<<44159bbcf15dc403e40656c71d84516a>>
* @generated SignedSource<<53537c2dcc2f4e298822eaa92b5c507f>>
*/
/**
@@ -32,4 +32,6 @@ open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvider {
override fun batchRenderingUpdatesInEventLoop(): Boolean = false
override fun enableSpannableBuildingUnification(): Boolean = false
override fun enableCustomDrawOrderFabric(): Boolean = false
}
@@ -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<<85d0ebc43b7c390be7dd89c58f1b7a7a>>
* @generated SignedSource<<9ea3b9587aa49be565b990b4c2f4a870>>
*/
/**
@@ -29,6 +29,7 @@ class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAccessor {
private var enableMicrotasksCache: Boolean? = null
private var batchRenderingUpdatesInEventLoopCache: Boolean? = null
private var enableSpannableBuildingUnificationCache: Boolean? = null
private var enableCustomDrawOrderFabricCache: Boolean? = null
override fun commonTestFlag(): Boolean {
var cached = commonTestFlagCache
@@ -80,6 +81,16 @@ class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAccessor {
return cached
}
override fun enableCustomDrawOrderFabric(): Boolean {
var cached = enableCustomDrawOrderFabricCache
if (cached == null) {
cached = currentProvider.enableCustomDrawOrderFabric()
accessedFeatureFlags.add("enableCustomDrawOrderFabric")
enableCustomDrawOrderFabricCache = cached
}
return cached
}
override fun override(provider: ReactNativeFeatureFlagsProvider) {
if (accessedFeatureFlags.isNotEmpty()) {
val accessedFeatureFlagsStr = accessedFeatureFlags.joinToString(separator = ", ") { it }
@@ -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<<d5db40f4f25503513c4128892fd12e3f>>
* @generated SignedSource<<9abdc5010330b660feded87e9db882c4>>
*/
/**
@@ -32,4 +32,6 @@ interface ReactNativeFeatureFlagsProvider {
@DoNotStrip fun batchRenderingUpdatesInEventLoop(): Boolean
@DoNotStrip fun enableSpannableBuildingUnification(): Boolean
@DoNotStrip fun enableCustomDrawOrderFabric(): Boolean
}
@@ -32,6 +32,7 @@ import com.facebook.react.bridge.ReactNoCrashSoftException;
import com.facebook.react.bridge.ReactSoftExceptionLogger;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import com.facebook.react.modules.i18nmanager.I18nUtil;
import com.facebook.react.touch.OnInterceptTouchEventListener;
import com.facebook.react.touch.ReactHitSlopView;
@@ -496,7 +497,11 @@ public class ReactViewGroup extends ViewGroup
if (getId() == NO_ID) {
return false;
}
return ViewUtil.getUIManagerType(getId()) == UIManagerType.FABRIC;
if (ViewUtil.getUIManagerType(getId()) != UIManagerType.FABRIC) {
return false;
}
return !ReactNativeFeatureFlags.enableCustomDrawOrderFabric();
}
private void handleAddView(View view) {
@@ -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<<36acddfcb6c038dbf523ad669bcedeba>>
* @generated SignedSource<<1ba33b527792e241891e821b18b11000>>
*/
/**
@@ -48,6 +48,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableSpannableBuildingUnification(
return ReactNativeFeatureFlags::enableSpannableBuildingUnification();
}
bool JReactNativeFeatureFlagsCxxInterop::enableCustomDrawOrderFabric(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableCustomDrawOrderFabric();
}
void JReactNativeFeatureFlagsCxxInterop::override(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/,
jni::alias_ref<jobject> provider) {
@@ -80,6 +85,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"enableSpannableBuildingUnification",
JReactNativeFeatureFlagsCxxInterop::enableSpannableBuildingUnification),
makeNativeMethod(
"enableCustomDrawOrderFabric",
JReactNativeFeatureFlagsCxxInterop::enableCustomDrawOrderFabric),
});
}
@@ -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<<b903dab48f817589883d7f41cc5674f0>>
* @generated SignedSource<<c1e65591af5042353647d3afb4e181b4>>
*/
/**
@@ -45,6 +45,9 @@ class JReactNativeFeatureFlagsCxxInterop
static bool enableSpannableBuildingUnification(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool enableCustomDrawOrderFabric(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static void override(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>,
jni::alias_ref<jobject> provider);
@@ -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<<5f99c47d357e45524b359e6517d1f2eb>>
* @generated SignedSource<<47d7a81b555e133f79db174f599a1940>>
*/
/**
@@ -57,4 +57,10 @@ bool ReactNativeFeatureFlagsProviderHolder::enableSpannableBuildingUnification()
return method(javaProvider_);
}
bool ReactNativeFeatureFlagsProviderHolder::enableCustomDrawOrderFabric() {
static const auto method =
getJClass()->getMethod<jboolean()>("enableCustomDrawOrderFabric");
return method(javaProvider_);
}
} // namespace facebook::react
@@ -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<<6aaa06ae0c12de2f432374d0cd048460>>
* @generated SignedSource<<228921c4374aa45bdcd496f0f10d653a>>
*/
/**
@@ -40,6 +40,7 @@ class ReactNativeFeatureFlagsProviderHolder
bool enableMicrotasks() override;
bool batchRenderingUpdatesInEventLoop() override;
bool enableSpannableBuildingUnification() override;
bool enableCustomDrawOrderFabric() override;
private:
jni::global_ref<jobject> javaProvider_;
@@ -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<<809c23db6d36e18d448554900e462aa0>>
* @generated SignedSource<<a9ddd8a35e80c21c36fd57526a58ae84>>
*/
/**
@@ -41,6 +41,10 @@ bool ReactNativeFeatureFlags::enableSpannableBuildingUnification() {
return getAccessor().enableSpannableBuildingUnification();
}
bool ReactNativeFeatureFlags::enableCustomDrawOrderFabric() {
return getAccessor().enableCustomDrawOrderFabric();
}
void ReactNativeFeatureFlags::override(
std::unique_ptr<ReactNativeFeatureFlagsProvider> provider) {
getAccessor().override(std::move(provider));
@@ -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<<ea6c88fb2c3fcaa35b5886b8f8ceb769>>
* @generated SignedSource<<479f3a75128ee7e9ea60af544b69e0d7>>
*/
/**
@@ -57,6 +57,11 @@ class ReactNativeFeatureFlags {
*/
static bool enableSpannableBuildingUnification();
/**
* When enabled, Fabric will use customDrawOrder in ReactViewGroup (similar to old architecture).
*/
static bool enableCustomDrawOrderFabric();
/**
* Overrides the feature flags with the ones provided by the given provider
* (generally one that extends `ReactNativeFeatureFlagsDefaults`).
@@ -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<<15858c6ab96e90350aa5f29eb108b051>>
* @generated SignedSource<<dc95df7a5e58ca72e19a77e4d190225e>>
*/
/**
@@ -113,6 +113,23 @@ bool ReactNativeFeatureFlagsAccessor::enableSpannableBuildingUnification() {
return enableSpannableBuildingUnification_.value();
}
bool ReactNativeFeatureFlagsAccessor::enableCustomDrawOrderFabric() {
if (!enableCustomDrawOrderFabric_.has_value()) {
// Mark the flag as accessed.
static const char* flagName = "enableCustomDrawOrderFabric";
if (std::find(
accessedFeatureFlags_.begin(),
accessedFeatureFlags_.end(),
flagName) == accessedFeatureFlags_.end()) {
accessedFeatureFlags_.push_back(flagName);
}
enableCustomDrawOrderFabric_.emplace(currentProvider_->enableCustomDrawOrderFabric());
}
return enableCustomDrawOrderFabric_.value();
}
void ReactNativeFeatureFlagsAccessor::override(
std::unique_ptr<ReactNativeFeatureFlagsProvider> provider) {
if (!accessedFeatureFlags_.empty()) {
@@ -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<<938f1f3ad6aa3343beb3ad7707a49a87>>
* @generated SignedSource<<f85ebb4efba429a4c943dc26e5a70541>>
*/
/**
@@ -35,6 +35,7 @@ class ReactNativeFeatureFlagsAccessor {
bool enableMicrotasks();
bool batchRenderingUpdatesInEventLoop();
bool enableSpannableBuildingUnification();
bool enableCustomDrawOrderFabric();
void override(std::unique_ptr<ReactNativeFeatureFlagsProvider> provider);
@@ -47,6 +48,7 @@ class ReactNativeFeatureFlagsAccessor {
std::optional<bool> enableMicrotasks_;
std::optional<bool> batchRenderingUpdatesInEventLoop_;
std::optional<bool> enableSpannableBuildingUnification_;
std::optional<bool> enableCustomDrawOrderFabric_;
};
} // namespace facebook::react
@@ -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<<18dc9a1aa23d156bc94e426ee1864359>>
* @generated SignedSource<<10089e5b138ecb72a6d2b2de22496cb5>>
*/
/**
@@ -46,6 +46,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
bool enableSpannableBuildingUnification() override {
return false;
}
bool enableCustomDrawOrderFabric() override {
return false;
}
};
} // namespace facebook::react
@@ -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<<2828ad8eb7ea0a0ea9cb0240eadedeb8>>
* @generated SignedSource<<646e0d7982b7e72f9ff227c80d4c2a49>>
*/
/**
@@ -30,6 +30,7 @@ class ReactNativeFeatureFlagsProvider {
virtual bool enableMicrotasks() = 0;
virtual bool batchRenderingUpdatesInEventLoop() = 0;
virtual bool enableSpannableBuildingUnification() = 0;
virtual bool enableCustomDrawOrderFabric() = 0;
};
} // namespace facebook::react
@@ -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<<de38e5abc0430aedc0fe94f0c73fee3d>>
* @generated SignedSource<<1fc0f55ffba5d6a7be9bb8f7942d45a2>>
*/
/**
@@ -60,4 +60,9 @@ bool NativeReactNativeFeatureFlags::enableSpannableBuildingUnification(
return ReactNativeFeatureFlags::enableSpannableBuildingUnification();
}
bool NativeReactNativeFeatureFlags::enableCustomDrawOrderFabric(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::enableCustomDrawOrderFabric();
}
} // namespace facebook::react
@@ -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<<b6444bb426632dfb672312df3384127f>>
* @generated SignedSource<<1642f4bbd50bb535c369642dd3a647ad>>
*/
/**
@@ -39,6 +39,8 @@ class NativeReactNativeFeatureFlags
bool batchRenderingUpdatesInEventLoop(jsi::Runtime& runtime);
bool enableSpannableBuildingUnification(jsi::Runtime& runtime);
bool enableCustomDrawOrderFabric(jsi::Runtime& runtime);
};
} // namespace facebook::react
@@ -19,6 +19,10 @@
"enableSpannableBuildingUnification": {
"description": "Uses new, deduplicated logic for constructing Android Spannables from text fragments",
"defaultValue": false
},
"enableCustomDrawOrderFabric": {
"description": "When enabled, Fabric will use customDrawOrder in ReactViewGroup (similar to old architecture).",
"defaultValue": false
}
},
"jsOnly": {
@@ -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<<80726297990981a85ae106f8566ec662>>
* @generated SignedSource<<4617616de77a1e9255f727fdc8039d92>>
* @flow strict-local
*/
@@ -28,6 +28,7 @@ export interface Spec extends TurboModule {
+enableMicrotasks?: () => boolean;
+batchRenderingUpdatesInEventLoop?: () => boolean;
+enableSpannableBuildingUnification?: () => boolean;
+enableCustomDrawOrderFabric?: () => boolean;
}
const NativeReactNativeFeatureFlags: ?Spec = TurboModuleRegistry.get<Spec>(
@@ -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<<d68bc5fec0897ad698014c938e4ab21e>>
* @generated SignedSource<<c43dd1db78ac69ca3c39577d45a04071>>
* @flow strict-local
*/
@@ -44,6 +44,7 @@ export type ReactNativeFeatureFlags = {
enableMicrotasks: Getter<boolean>,
batchRenderingUpdatesInEventLoop: Getter<boolean>,
enableSpannableBuildingUnification: Getter<boolean>,
enableCustomDrawOrderFabric: Getter<boolean>,
}
/**
@@ -101,6 +102,10 @@ export const batchRenderingUpdatesInEventLoop: Getter<boolean> = createNativeFla
* Uses new, deduplicated logic for constructing Android Spannables from text fragments
*/
export const enableSpannableBuildingUnification: Getter<boolean> = createNativeFlagGetter('enableSpannableBuildingUnification', false);
/**
* When enabled, Fabric will use customDrawOrder in ReactViewGroup (similar to old architecture).
*/
export const enableCustomDrawOrderFabric: Getter<boolean> = createNativeFlagGetter('enableCustomDrawOrderFabric', false);
/**
* Overrides the feature flags with the provided methods.