Skip to content
Closed
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
4 changes: 0 additions & 4 deletions packages/react-native/React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,6 @@ - (RCTScheduler *)_createScheduler
CoreFeatures::enableGranularScrollViewStateUpdatesIOS = true;
}

if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:enable_mount_hooks_ios")) {
CoreFeatures::enableMountHooks = true;
}

if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:enable_cloneless_state_progression")) {
CoreFeatures::enableClonelessStateProgression = true;
}
Expand Down
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 @@ -1910,7 +1910,6 @@ public class com/facebook/react/config/ReactFeatureFlags {
public static field enableFabricPendingEventQueue Z
public static field enableFabricRenderer Z
public static field enableFabricRendererExclusively Z
public static field enableMountHooks Z
public static field enableRemoveDeleteTreeInstruction Z
public static field enableTextSpannableCache Z
public static field enableViewRecycling Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ public class ReactFeatureFlags {
*/
public static boolean enableRemoveDeleteTreeInstruction = false;

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

/** Use native view configs in bridgeless mode. */
public static boolean useNativeViewConfigsInBridgelessMode = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import com.facebook.react.fabric.mounting.mountitems.MountItem;
import com.facebook.react.fabric.mounting.mountitems.MountItemFactory;
import com.facebook.react.interfaces.fabric.SurfaceHandler;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import com.facebook.react.internal.interop.InteropEventEmitter;
import com.facebook.react.modules.core.ReactChoreographer;
import com.facebook.react.modules.i18nmanager.I18nUtil;
Expand All @@ -91,7 +92,6 @@
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;

/**
* We instruct ProGuard not to strip out any fields or methods, because many of these methods are
Expand Down Expand Up @@ -173,7 +173,8 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
@NonNull
private final CopyOnWriteArrayList<UIManagerListener> mListeners = new CopyOnWriteArrayList<>();

@NonNull private final AtomicBoolean mMountNotificationScheduled = new AtomicBoolean(false);
private boolean mMountNotificationScheduled = false;
private final List<Integer> mMountedSurfaceIds = new ArrayList<>();

@ThreadConfined(UI)
@NonNull
Expand Down Expand Up @@ -1203,54 +1204,57 @@ public Map<String, Long> getPerformanceCounters() {
}

private class MountItemDispatchListener implements MountItemDispatcher.ItemDispatchListener {
@UiThread
@ThreadConfined(UI)
@Override
public void willMountItems(@Nullable List<MountItem> mountItems) {
for (UIManagerListener listener : mListeners) {
listener.willMountItems(FabricUIManager.this);
}
}

@UiThread
@ThreadConfined(UI)
@Override
public void didMountItems(@Nullable List<MountItem> mountItems) {
for (UIManagerListener listener : mListeners) {
listener.didMountItems(FabricUIManager.this);
}

if (!ReactFeatureFlags.enableMountHooks) {
if (!ReactNativeFeatureFlags.enableMountHooksAndroid()
|| mountItems == null
|| mountItems.isEmpty()) {
return;
}

boolean mountNotificationScheduled = mMountNotificationScheduled.getAndSet(true);
if (!mountNotificationScheduled) {
// Collect surface IDs for all the mount items
for (MountItem mountItem : mountItems) {
if (mountItem != null && !mMountedSurfaceIds.contains(mountItem.getSurfaceId())) {
mMountedSurfaceIds.add(mountItem.getSurfaceId());
}
}

if (!mMountNotificationScheduled && !mMountedSurfaceIds.isEmpty()) {
// Notify mount when the effects are visible and prevent mount hooks to
// delay paint.
UiThreadUtil.getUiThreadHandler()
.postAtFrontOfQueue(
new Runnable() {
@Override
public void run() {
mMountNotificationScheduled.set(false);

if (mDestroyed) {
return;
}
mMountNotificationScheduled = false;

final @Nullable Binding binding = mBinding;
if (mountItems == null || binding == null) {
if (binding == null || mDestroyed) {
mMountedSurfaceIds.clear();
return;
}

// Collect surface IDs for all the mount items
List<Integer> surfaceIds = new ArrayList<>();
for (MountItem mountItem : mountItems) {
if (mountItem != null && !surfaceIds.contains(mountItem.getSurfaceId())) {
surfaceIds.add(mountItem.getSurfaceId());
}
}

for (int surfaceId : surfaceIds) {
for (int surfaceId : mMountedSurfaceIds) {
binding.reportMount(surfaceId);
}

mMountedSurfaceIds.clear();
}
});
}
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<<6d6fd79bdd221b3aeed0057ac756ee92>>
* @generated SignedSource<<a3cb24f7faddd86beb617c8314c1bfed>>
*/

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

/**
* Enables the notification of mount operations to mount hooks on Android.
*/
@JvmStatic
public fun enableMountHooksAndroid(): Boolean = accessor.enableMountHooksAndroid()

/**
* Uses new, deduplicated logic for constructing Android Spannables from text fragments
*/
Expand All @@ -82,6 +88,12 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun inspectorEnableModernCDPRegistry(): Boolean = accessor.inspectorEnableModernCDPRegistry()

/**
* This is a temporary flag to disable part of the mount hooks pipeline to investigate a crash.
*/
@JvmStatic
public fun skipMountHookNotifications(): Boolean = accessor.skipMountHookNotifications()

/**
* When enabled, it uses the modern fork of RuntimeScheduler that allows scheduling tasks with priorities from any thread.
*/
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<<45776de0416f833eed9bb84d6b7d1052>>
* @generated SignedSource<<8539cf7ba13ab52ca878efd2c4858d7a>>
*/

/**
Expand All @@ -26,9 +26,11 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var enableCustomDrawOrderFabricCache: Boolean? = null
private var enableFixForClippedSubviewsCrashCache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
private var enableMountHooksAndroidCache: Boolean? = null
private var enableSpannableBuildingUnificationCache: Boolean? = null
private var inspectorEnableCxxInspectorPackagerConnectionCache: Boolean? = null
private var inspectorEnableModernCDPRegistryCache: Boolean? = null
private var skipMountHookNotificationsCache: Boolean? = null
private var useModernRuntimeSchedulerCache: Boolean? = null

override fun commonTestFlag(): Boolean {
Expand Down Expand Up @@ -85,6 +87,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}

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

override fun enableSpannableBuildingUnification(): Boolean {
var cached = enableSpannableBuildingUnificationCache
if (cached == null) {
Expand Down Expand Up @@ -112,6 +123,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}

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

override fun useModernRuntimeScheduler(): Boolean {
var cached = useModernRuntimeSchedulerCache
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<<f9c16b18d93c786db2c5a90c0c4340f6>>
* @generated SignedSource<<cd7257d4b1414f7aacd02a79b9295a46>>
*/

/**
Expand Down Expand Up @@ -40,12 +40,16 @@ public object ReactNativeFeatureFlagsCxxInterop {

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

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

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

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

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

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

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

@DoNotStrip @JvmStatic public external fun override(provider: Any)
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<<4f72683fb2a832d5b77ee2cb37343526>>
* @generated SignedSource<<99263973c4a06fdc91e7c9edf4aa4e19>>
*/

/**
Expand Down Expand Up @@ -35,11 +35,15 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun enableMicrotasks(): Boolean = false

override fun enableMountHooksAndroid(): Boolean = false

override fun enableSpannableBuildingUnification(): Boolean = false

override fun inspectorEnableCxxInspectorPackagerConnection(): Boolean = false

override fun inspectorEnableModernCDPRegistry(): Boolean = false

override fun skipMountHookNotifications(): Boolean = false

override fun useModernRuntimeScheduler(): Boolean = false
}
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<<5fd54183222961f5557dbe0ac111a6ec>>
* @generated SignedSource<<e8550b0c2494b223b82e6fab0a827d53>>
*/

/**
Expand All @@ -30,9 +30,11 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var enableCustomDrawOrderFabricCache: Boolean? = null
private var enableFixForClippedSubviewsCrashCache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
private var enableMountHooksAndroidCache: Boolean? = null
private var enableSpannableBuildingUnificationCache: Boolean? = null
private var inspectorEnableCxxInspectorPackagerConnectionCache: Boolean? = null
private var inspectorEnableModernCDPRegistryCache: Boolean? = null
private var skipMountHookNotificationsCache: Boolean? = null
private var useModernRuntimeSchedulerCache: Boolean? = null

override fun commonTestFlag(): Boolean {
Expand Down Expand Up @@ -95,6 +97,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}

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

override fun enableSpannableBuildingUnification(): Boolean {
var cached = enableSpannableBuildingUnificationCache
if (cached == null) {
Expand Down Expand Up @@ -125,6 +137,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}

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

override fun useModernRuntimeScheduler(): Boolean {
var cached = useModernRuntimeSchedulerCache
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<<c4f4d28210d5437839616d49120eb921>>
* @generated SignedSource<<268a87860fea5f281567d2142f90b0d4>>
*/

/**
Expand Down Expand Up @@ -35,11 +35,15 @@ public interface ReactNativeFeatureFlagsProvider {

@DoNotStrip public fun enableMicrotasks(): Boolean

@DoNotStrip public fun enableMountHooksAndroid(): Boolean

@DoNotStrip public fun enableSpannableBuildingUnification(): Boolean

@DoNotStrip public fun inspectorEnableCxxInspectorPackagerConnection(): Boolean

@DoNotStrip public fun inspectorEnableModernCDPRegistry(): Boolean

@DoNotStrip public fun skipMountHookNotifications(): Boolean

@DoNotStrip public fun useModernRuntimeScheduler(): Boolean
}
Loading