Add inert Java plumbing for the Android pull model (#57580)

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

Java side of the pull model — dead code until the C++ wiring lands:
- `PullTransactionMountItem`: asks C++ (via `FabricUIManagerBinding.pullAndExecuteTransaction`) to pull the surface's pending transaction and apply it synchronously on the UI thread.
- `FabricUIManager.onTransactionAvailable` (JNI entry): enqueues a `PullTransactionMountItem`.
- `FabricUIManagerBinding.pullAndExecuteTransaction`: extern declaration.

One item is enqueued per notification, mirroring iOS; redundant items no-op in C++.

## Changelog:
[Android] [Added] - Add inert Java plumbing (`PullTransactionMountItem`, `FabricUIManager.onTransactionAvailable`) for the pull model

Reviewed By: rubennorte

Differential Revision: D112309050

fbshipit-source-id: 01a09018df9833c839687b66b289c67f9fc3b9d4
This commit is contained in:
Dawid Małecki authored and meta-codesync[bot] committed 2026-07-29 06:37:09 -07:00
1 parent 3fd02591bf
commit 6515647d94
3 files changed
+57

No files matched your search

@@ -27,6 +27,7 @@ import android.view.accessibility.AccessibilityEvent;
import androidx.annotation.AnyThread;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.VisibleForTesting;
import androidx.core.view.ViewCompat.FocusDirection;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
@@ -65,6 +66,7 @@ import com.facebook.react.fabric.mounting.mountitems.DispatchCommandMountItem;
import com.facebook.react.fabric.mounting.mountitems.MountItem;
import com.facebook.react.fabric.mounting.mountitems.MountItemFactory;
import com.facebook.react.fabric.mounting.mountitems.PrefetchResourcesMountItem;
import com.facebook.react.fabric.mounting.mountitems.PullTransactionMountItem;
import com.facebook.react.fabric.mounting.mountitems.SynchronousMountItem;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlags;
@@ -1011,6 +1013,26 @@ public class FabricUIManager
}
}
/**
* Pull model: called from C++ via JNI (usually on the commit thread) to signal that a transaction
* is available for {@code surfaceId}. Enqueues a PullTransactionMountItem so the UI thread pulls
* and applies the transaction itself, preserving mount-item ordering.
*/
@SuppressWarnings("unused")
@AnyThread
@ThreadConfined(ANY)
@VisibleForTesting
void onTransactionAvailable(int surfaceId) {
FabricUIManagerBinding binding = mBinding;
if (binding == null) {
return;
}
mMountItemDispatcher.addMountItem(new PullTransactionMountItem(surfaceId, binding));
if (UiThreadUtil.isOnUiThread()) {
mMountItemDispatcher.tryDispatchMountItems();
}
}
@SuppressWarnings("unused")
@AnyThread
@ThreadConfined(ANY)
@@ -85,6 +85,8 @@ internal class FabricUIManagerBinding : HybridClassBase() {
external fun reportMount(surfaceId: Int)
external fun pullAndExecuteTransaction(surfaceId: Int)
external fun mergeReactRevision(surfaceId: Int)
fun register(
@@ -0,0 +1,33 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.fabric.mounting.mountitems
import com.facebook.proguard.annotations.DoNotStripAny
import com.facebook.react.fabric.FabricUIManagerBinding
import com.facebook.react.fabric.mounting.MountingManager
/**
* Pull model mount item. Enqueued (on the commit thread) when C++ notifies that a transaction is
* available for a surface. When it executes on the UI thread it asks C++ to pull the surface's
* pending transaction and apply it synchronously, so the diff + batch construction happens on the
* UI thread instead of the commit thread (matching iOS).
*/
@DoNotStripAny
internal class PullTransactionMountItem(
private val surfaceId: Int,
private val binding: FabricUIManagerBinding,
) : MountItem {
override fun execute(mountingManager: MountingManager) {
binding.pullAndExecuteTransaction(surfaceId)
}
override fun getSurfaceId(): Int = surfaceId
override fun toString(): String = "PullTransactionMountItem [surfaceId: $surfaceId]"
}