Skip to content

Commit e204bbe

Browse files
javachemeta-codesync[bot]
authored andcommitted
Remove RuntimeSchedulerCallInvoker
Summary: Remove the deprecated `RuntimeSchedulerCallInvoker` implementation now that React instances expose their buffered `CallInvoker`. Make that invoker available through the runtime binding and migrate remaining consumers to use it. Changelog: [General][Breaking] - Remove the deprecated `RuntimeSchedulerCallInvoker` API Differential Revision: D123627753
1 parent 436ba5a commit e204bbe

14 files changed

Lines changed: 19 additions & 152 deletions

‎packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.cpp‎

Lines changed: 0 additions & 42 deletions
This file was deleted.

‎packages/react-native/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h‎

Lines changed: 0 additions & 40 deletions
This file was deleted.

‎packages/react-native/ReactCommon/react/runtime/CallInvokerImpl.cpp‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ void CallInvokerImpl::invokeAsync(CallFunc&& func) noexcept {
2121
// Held for the duration of the call: `BufferedRuntimeExecutor` reaches the
2222
// scheduler through a raw pointer, which is only safe while the instance that
2323
// owns it is alive. A CallInvoker outlives its instance routinely — a caller
24-
// can hold one across a reload — so the weak reference is what keeps this
25-
// from dispatching into a destroyed scheduler. Dropping the work matches what
26-
// `RuntimeSchedulerCallInvoker` does once its scheduler is gone.
24+
// can hold one across a reload — so guard dispatch with the weak scheduler.
25+
// If it has expired, there is no runtime left to receive the work.
2726
if (auto runtimeScheduler = runtimeScheduler_.lock()) {
28-
// No priority given, so this takes the executor's default — matching what
29-
// `RuntimeSchedulerCallInvoker` did via `scheduleWork`.
27+
// No priority was given, so use the executor's default.
3028
bufferedRuntimeExecutor_->execute(std::move(func));
3129
}
3230
}

‎packages/react-native/ReactCxxPlatform/react/runtime/ReactHost.cpp‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ struct ReactInstanceData {
5151
std::shared_ptr<NativeAnimatedNodesManagerProvider>
5252
animatedNodesManagerProvider;
5353
ReactInstance::BindingsInstallFunc bindingsInstallFunc;
54+
ReactHost::CallInvokerBindingsInstallFunc callInvokerBindingsInstallFunc;
5455
std::shared_ptr<AnimationChoreographer> animationChoreographer;
5556
};
5657

@@ -67,7 +68,8 @@ ReactHost::ReactHost(
6768
std::shared_ptr<NativeAnimatedNodesManagerProvider>
6869
animatedNodesManagerProvider,
6970
ReactInstance::BindingsInstallFunc bindingsInstallFunc,
70-
std::shared_ptr<AnimationChoreographer> animationChoreographer)
71+
std::shared_ptr<AnimationChoreographer> animationChoreographer,
72+
CallInvokerBindingsInstallFunc callInvokerBindingsInstallFunc)
7173
: reactInstanceConfig_(std::move(reactInstanceConfig)) {
7274
auto componentRegistryFactory =
7375
mountingManager->getComponentRegistryFactory();
@@ -84,6 +86,8 @@ ReactHost::ReactHost(
8486
.logBoxSurfaceDelegate = logBoxSurfaceDelegate,
8587
.animatedNodesManagerProvider = animatedNodesManagerProvider,
8688
.bindingsInstallFunc = std::move(bindingsInstallFunc),
89+
.callInvokerBindingsInstallFunc =
90+
std::move(callInvokerBindingsInstallFunc),
8791
.animationChoreographer = std::move(animationChoreographer)});
8892
if (!reactInstanceData_->contextContainer
8993
->find<MessageQueueThreadFactory>(MessageQueueThreadFactoryKey)
@@ -278,6 +282,9 @@ void ReactHost::createReactInstance() {
278282
std::weak_ptr<IMountingManager>(reactInstanceData_->mountingManager),
279283
logger = reactInstanceData_->logger,
280284
bindingsInstallFunc = reactInstanceData_->bindingsInstallFunc,
285+
callInvokerBindingsInstallFunc =
286+
reactInstanceData_->callInvokerBindingsInstallFunc,
287+
jsInvoker,
281288
turboModuleManager =
282289
std::move(turboModuleManager)](jsi::Runtime& runtime) mutable {
283290
if (logger) {
@@ -299,6 +306,9 @@ void ReactHost::createReactInstance() {
299306
if (bindingsInstallFunc) {
300307
bindingsInstallFunc(runtime);
301308
}
309+
if (callInvokerBindingsInstallFunc) {
310+
callInvokerBindingsInstallFunc(runtime, jsInvoker);
311+
}
302312
});
303313
}
304314

‎packages/react-native/ReactCxxPlatform/react/runtime/ReactHost.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ struct ReactInstanceData;
4141

4242
class ReactHost {
4343
public:
44+
using CallInvokerBindingsInstallFunc =
45+
std::function<void(jsi::Runtime &runtime, std::shared_ptr<CallInvoker> callInvoker)>;
46+
4447
ReactHost(
4548
ReactInstanceConfig reactInstanceConfig,
4649
std::shared_ptr<IMountingManager> mountingManager,
@@ -53,7 +56,8 @@ class ReactHost {
5356
std::shared_ptr<SurfaceDelegate> logBoxSurfaceDelegate = nullptr,
5457
std::shared_ptr<NativeAnimatedNodesManagerProvider> animatedNodesManagerProvider = nullptr,
5558
ReactInstance::BindingsInstallFunc bindingsInstallFunc = nullptr,
56-
std::shared_ptr<AnimationChoreographer> animationChoreographer = nullptr);
59+
std::shared_ptr<AnimationChoreographer> animationChoreographer = nullptr,
60+
CallInvokerBindingsInstallFunc callInvokerBindingsInstallFunc = nullptr);
5761
ReactHost(const ReactHost &) = delete;
5862
ReactHost &operator=(const ReactHost &) = delete;
5963
ReactHost(ReactHost &&) noexcept = delete;

‎scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4470,13 +4470,6 @@ class facebook::react::RuntimeSchedulerBinding : public facebook::jsi::HostObjec
44704470
public virtual facebook::jsi::Value get(facebook::jsi::Runtime& runtime, const facebook::jsi::PropNameID& name) override;
44714471
}
44724472

4473-
class facebook::react::RuntimeSchedulerCallInvoker : public facebook::react::CallInvoker {
4474-
public RuntimeSchedulerCallInvoker(std::weak_ptr<facebook::react::RuntimeScheduler> runtimeScheduler);
4475-
public virtual void invokeAsync(facebook::react::CallFunc&& func) noexcept override;
4476-
public virtual void invokeAsync(facebook::react::SchedulerPriority priority, facebook::react::CallFunc&& func) noexcept override;
4477-
public virtual void invokeSync(facebook::react::CallFunc&& func) override;
4478-
}
4479-
44804473
class facebook::react::RuntimeSchedulerEventTimingDelegate {
44814474
public virtual void dispatchPendingEventTimingEntries(facebook::react::HighResTimeStamp taskEndTime, const std::unordered_set<facebook::react::SurfaceId>& surfaceIdsWithPendingRenderingUpdates) = 0;
44824475
public virtual ~RuntimeSchedulerEventTimingDelegate() = default;

‎scripts/cxx-api/api-snapshots/ReactAndroidNewarchCxx.api‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4314,13 +4314,6 @@ class facebook::react::RuntimeSchedulerBinding : public facebook::jsi::HostObjec
43144314
public virtual facebook::jsi::Value get(facebook::jsi::Runtime& runtime, const facebook::jsi::PropNameID& name) override;
43154315
}
43164316

4317-
class facebook::react::RuntimeSchedulerCallInvoker : public facebook::react::CallInvoker {
4318-
public RuntimeSchedulerCallInvoker(std::weak_ptr<facebook::react::RuntimeScheduler> runtimeScheduler);
4319-
public virtual void invokeAsync(facebook::react::CallFunc&& func) noexcept override;
4320-
public virtual void invokeAsync(facebook::react::SchedulerPriority priority, facebook::react::CallFunc&& func) noexcept override;
4321-
public virtual void invokeSync(facebook::react::CallFunc&& func) override;
4322-
}
4323-
43244317
class facebook::react::RuntimeSchedulerEventTimingDelegate {
43254318
public virtual void dispatchPendingEventTimingEntries(facebook::react::HighResTimeStamp taskEndTime, const std::unordered_set<facebook::react::SurfaceId>& surfaceIdsWithPendingRenderingUpdates) = 0;
43264319
public virtual ~RuntimeSchedulerEventTimingDelegate() = default;

‎scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4467,13 +4467,6 @@ class facebook::react::RuntimeSchedulerBinding : public facebook::jsi::HostObjec
44674467
public virtual facebook::jsi::Value get(facebook::jsi::Runtime& runtime, const facebook::jsi::PropNameID& name) override;
44684468
}
44694469

4470-
class facebook::react::RuntimeSchedulerCallInvoker : public facebook::react::CallInvoker {
4471-
public RuntimeSchedulerCallInvoker(std::weak_ptr<facebook::react::RuntimeScheduler> runtimeScheduler);
4472-
public virtual void invokeAsync(facebook::react::CallFunc&& func) noexcept override;
4473-
public virtual void invokeAsync(facebook::react::SchedulerPriority priority, facebook::react::CallFunc&& func) noexcept override;
4474-
public virtual void invokeSync(facebook::react::CallFunc&& func) override;
4475-
}
4476-
44774470
class facebook::react::RuntimeSchedulerEventTimingDelegate {
44784471
public virtual void dispatchPendingEventTimingEntries(facebook::react::HighResTimeStamp taskEndTime, const std::unordered_set<facebook::react::SurfaceId>& surfaceIdsWithPendingRenderingUpdates) = 0;
44794472
public virtual ~RuntimeSchedulerEventTimingDelegate() = default;

‎scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6628,13 +6628,6 @@ class facebook::react::RuntimeSchedulerBinding : public facebook::jsi::HostObjec
66286628
public virtual facebook::jsi::Value get(facebook::jsi::Runtime& runtime, const facebook::jsi::PropNameID& name) override;
66296629
}
66306630

6631-
class facebook::react::RuntimeSchedulerCallInvoker : public facebook::react::CallInvoker {
6632-
public RuntimeSchedulerCallInvoker(std::weak_ptr<facebook::react::RuntimeScheduler> runtimeScheduler);
6633-
public virtual void invokeAsync(facebook::react::CallFunc&& func) noexcept override;
6634-
public virtual void invokeAsync(facebook::react::SchedulerPriority priority, facebook::react::CallFunc&& func) noexcept override;
6635-
public virtual void invokeSync(facebook::react::CallFunc&& func) override;
6636-
}
6637-
66386631
class facebook::react::RuntimeSchedulerEventTimingDelegate {
66396632
public virtual void dispatchPendingEventTimingEntries(facebook::react::HighResTimeStamp taskEndTime, const std::unordered_set<facebook::react::SurfaceId>& surfaceIdsWithPendingRenderingUpdates) = 0;
66406633
public virtual ~RuntimeSchedulerEventTimingDelegate() = default;

‎scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6504,13 +6504,6 @@ class facebook::react::RuntimeSchedulerBinding : public facebook::jsi::HostObjec
65046504
public virtual facebook::jsi::Value get(facebook::jsi::Runtime& runtime, const facebook::jsi::PropNameID& name) override;
65056505
}
65066506

6507-
class facebook::react::RuntimeSchedulerCallInvoker : public facebook::react::CallInvoker {
6508-
public RuntimeSchedulerCallInvoker(std::weak_ptr<facebook::react::RuntimeScheduler> runtimeScheduler);
6509-
public virtual void invokeAsync(facebook::react::CallFunc&& func) noexcept override;
6510-
public virtual void invokeAsync(facebook::react::SchedulerPriority priority, facebook::react::CallFunc&& func) noexcept override;
6511-
public virtual void invokeSync(facebook::react::CallFunc&& func) override;
6512-
}
6513-
65146507
class facebook::react::RuntimeSchedulerEventTimingDelegate {
65156508
public virtual void dispatchPendingEventTimingEntries(facebook::react::HighResTimeStamp taskEndTime, const std::unordered_set<facebook::react::SurfaceId>& surfaceIdsWithPendingRenderingUpdates) = 0;
65166509
public virtual ~RuntimeSchedulerEventTimingDelegate() = default;

0 commit comments

Comments
 (0)