Do not use setNativeState in RuntimeScheduler::Task

Summary:
changelog: [internal]

`setNativeState` is not implemented in JSC. Let's stick to host objects for now.

Reviewed By: cipolleschi

Differential Revision: D46193786

fbshipit-source-id: 9d36801bb9faa5c144a461bcbe623762bf6947b1
This commit is contained in:
Samuel Susla
2023-05-26 10:14:45 +01:00
committed by Riccardo Cipolleschi
parent dc6a2c384d
commit c43bd7a73a
3 changed files with 21 additions and 2 deletions
@@ -94,6 +94,11 @@
*/
- (UIViewController *)createRootViewController;
/// This method controls whether the App will use RuntimeScheduler. Only applicable in the legacy architecture.
///
/// @return: `YES` to use RuntimeScheduler, `NO` to use JavaScript scheduler. The default value is `YES`.
- (BOOL)runtimeSchedulerEnabled;
#if RCT_NEW_ARCH_ENABLED
/// The TurboModule manager
@@ -134,11 +134,16 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
return [UIViewController new];
}
- (BOOL)runtimeSchedulerEnabled
{
return YES;
}
#pragma mark - RCTCxxBridgeDelegate
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
_runtimeScheduler = std::make_shared<facebook::react::RuntimeScheduler>(RCTRuntimeExecutorFromBridge(bridge));
#if RCT_NEW_ARCH_ENABLED
_runtimeScheduler = std::make_shared<facebook::react::RuntimeScheduler>(RCTRuntimeExecutorFromBridge(bridge));
std::shared_ptr<facebook::react::CallInvoker> callInvoker =
std::make_shared<facebook::react::RuntimeSchedulerCallInvoker>(_runtimeScheduler);
self.turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge delegate:self jsInvoker:callInvoker];
@@ -146,6 +151,9 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
_contextContainer->insert("RuntimeScheduler", _runtimeScheduler);
return RCTAppSetupDefaultJsExecutorFactory(bridge, self.turboModuleManager, _runtimeScheduler);
#else
if (self.runtimeSchedulerEnabled) {
_runtimeScheduler = std::make_shared<facebook::react::RuntimeScheduler>(RCTRuntimeExecutorFromBridge(bridge));
}
return RCTAppSetupJsExecutorFactoryForOldArch(bridge, _runtimeScheduler);
#endif
}
@@ -19,11 +19,17 @@ struct TaskWrapper : public jsi::HostObject {
std::shared_ptr<Task> task;
};
struct TaskWrapper : public jsi::HostObject {
TaskWrapper(std::shared_ptr<Task> const &task) : task(task) {}
std::shared_ptr<Task> task;
};
inline static jsi::Value valueFromTask(
jsi::Runtime &runtime,
std::shared_ptr<Task> task) {
return jsi::Object::createFromHostObject(
runtime, std::make_shared<TaskWrapper>(task));
runtime, std::make_shared<TaskWrapper>(task));
}
inline static std::shared_ptr<Task> taskFromValue(