Skip to content

Commit

Permalink
Revert QE for ReactFeatureFlags.reduceDeleteCreateMutation (#42339)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #42339

This diff cleans up the code added in D41900201 to run QE: https://fburl.com/qe2/ovgxlayy

More context: https://fb.workplace.com/groups/react.technologies.discussions/permalink/3479283292303384/

Changelog:
[Android][Internal] - Revert internal optimizations

Reviewed By: mdvacca

Differential Revision: D52750975

fbshipit-source-id: 675a3d0bb05094e35e47b35e6840fb2e5a24b9a1
  • Loading branch information
Xin Chen authored and facebook-github-bot committed Jan 22, 2024
1 parent 4e92f87 commit 0e90cd4
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 46 deletions.
1 change: 0 additions & 1 deletion packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,6 @@ public class com/facebook/react/config/ReactFeatureFlags {
public static field enableViewRecycling Z
public static field excludeYogaFromRawProps Z
public static field fixStoppedSurfaceTagSetLeak Z
public static field reduceDeleteCreateMutation Z
public static field reduceDeleteCreateMutationLayoutAnimation Z
public static field rejectTurboModulePromiseOnNativeError Z
public static field traceTurboModulePromiseRejections Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ public class ReactFeatureFlags {
*/
public static boolean reduceDeleteCreateMutationLayoutAnimation = true;

/**
* Allow fix to drop delete...create mutations which could cause missing view state in Fabric
* SurfaceMountingManager.
*/
public static boolean reduceDeleteCreateMutation = false;

/** Report mount operations from the host platform to notify mount hooks. */
public static boolean enableMountHooks = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,10 @@

namespace facebook::react {

constexpr static auto kReactFeatureFlagsJavaDescriptor =
"com/facebook/react/config/ReactFeatureFlags";

static bool getFeatureFlagValue(const char* name) {
static const auto reactFeatureFlagsClass =
jni::findClassStatic(kReactFeatureFlagsJavaDescriptor);
const auto field = reactFeatureFlagsClass->getStaticField<jboolean>(name);
return reactFeatureFlagsClass->getStaticFieldValue(field);
}

FabricMountingManager::FabricMountingManager(
std::shared_ptr<const ReactNativeConfig>& config,
jni::global_ref<JFabricUIManager::javaobject>& javaUIManager)
: javaUIManager_(javaUIManager),
reduceDeleteCreateMutation_(
getFeatureFlagValue("reduceDeleteCreateMutation")) {}
: javaUIManager_(javaUIManager) {}

void FabricMountingManager::onSurfaceStart(SurfaceId surfaceId) {
std::lock_guard lock(allocatedViewsMutex_);
Expand Down Expand Up @@ -288,30 +276,6 @@ void FabricMountingManager::executeMount(
case ShadowViewMutation::Create: {
bool shouldCreateView =
!allocatedViewTags.contains(newChildShadowView.tag);
if (reduceDeleteCreateMutation_) {
// Detect DELETE...CREATE situation on the same node and do NOT push
// back to the mount items. This is an edge case that may happen
// when for example animation runs while commit happened, and we
// want to filter them out here to capture all possible sources of
// such mutations. The re-ordering logic here assumes no
// DELETE...CREATE in the mutations, as we will re-order mutations
// and batch all DELETE instructions in the end.
auto it = std::remove_if(
cppDeleteMountItems.begin(),
cppDeleteMountItems.end(),
[&](auto& deletedMountItem) -> bool {
return deletedMountItem.oldChildShadowView.tag ==
newChildShadowView.tag;
});
bool hasDeletedViewsWithSameTag = it != cppDeleteMountItems.end();
cppDeleteMountItems.erase(it, cppDeleteMountItems.end());

if (hasDeletedViewsWithSameTag) {
shouldCreateView = false;
LOG(ERROR)
<< "XIN: Detect DELETE...CREATE on the same tag from mutations in the same batch. The DELETE and CREATE mutations are removed before sending to the native platforms";
}
}

if (shouldCreateView) {
cppCommonMountItems.push_back(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ class FabricMountingManager final {
allocatedViewRegistry_{};
std::recursive_mutex allocatedViewsMutex_;

const bool reduceDeleteCreateMutation_{false};

jni::local_ref<jobject> getProps(
const ShadowView& oldShadowView,
const ShadowView& newShadowView);
Expand Down

0 comments on commit 0e90cd4

Please sign in to comment.