Skip to content

Commit 8363184

Browse files
rubennortefacebook-github-bot
authored andcommitted
Permamently enable yielding in runtime scheduler
Summary: changelog: [internal] Reviewed By: RSNara Differential Revision: D36638658 fbshipit-source-id: 770d56abb2e2490684ab01e97e5cc7018f247fc8
1 parent c02b5b8 commit 8363184

File tree

5 files changed

+7
-49
lines changed

5 files changed

+7
-49
lines changed

React/Fabric/RCTSurfacePresenter.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ - (RCTScheduler *)_createScheduler
289289
auto weakRuntimeScheduler = _contextContainer->find<std::weak_ptr<RuntimeScheduler>>("RuntimeScheduler");
290290
auto runtimeScheduler = weakRuntimeScheduler.has_value() ? weakRuntimeScheduler.value().lock() : nullptr;
291291
if (runtimeScheduler) {
292-
runtimeScheduler->setEnableYielding(true);
293292
runtimeExecutor = [runtimeScheduler](std::function<void(jsi::Runtime & runtime)> &&callback) {
294293
runtimeScheduler->scheduleWork(std::move(callback));
295294
};

ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,6 @@ void Binding::installFabricUIManager(
401401
if (runtimeSchedulerHolder) {
402402
auto runtimeScheduler = runtimeSchedulerHolder->cthis()->get().lock();
403403
if (runtimeScheduler) {
404-
runtimeScheduler->setEnableYielding(config->getBool(
405-
"react_native_new_architecture:runtimescheduler_enable_yielding_android"));
406404
runtimeExecutor =
407405
[runtimeScheduler](
408406
std::function<void(jsi::Runtime & runtime)> &&callback) {

ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,13 @@ RuntimeScheduler::RuntimeScheduler(
2222

2323
void RuntimeScheduler::scheduleWork(
2424
std::function<void(jsi::Runtime &)> callback) const {
25-
if (enableYielding_) {
26-
runtimeAccessRequests_ += 1;
27-
runtimeExecutor_(
28-
[this, callback = std::move(callback)](jsi::Runtime &runtime) {
29-
runtimeAccessRequests_ -= 1;
30-
callback(runtime);
31-
startWorkLoop(runtime);
32-
});
33-
} else {
34-
runtimeExecutor_([callback = std::move(callback)](jsi::Runtime &runtime) {
35-
callback(runtime);
36-
});
37-
}
25+
runtimeAccessRequests_ += 1;
26+
runtimeExecutor_(
27+
[this, callback = std::move(callback)](jsi::Runtime &runtime) {
28+
runtimeAccessRequests_ -= 1;
29+
callback(runtime);
30+
startWorkLoop(runtime);
31+
});
3832
}
3933

4034
std::shared_ptr<Task> RuntimeScheduler::scheduleTask(
@@ -70,10 +64,6 @@ RuntimeSchedulerTimePoint RuntimeScheduler::now() const noexcept {
7064
return now_();
7165
}
7266

73-
void RuntimeScheduler::setEnableYielding(bool enableYielding) {
74-
enableYielding_ = enableYielding;
75-
}
76-
7767
void RuntimeScheduler::executeNowOnTheSameThread(
7868
std::function<void(jsi::Runtime &runtime)> callback) {
7969
runtimeAccessRequests_ += 1;

ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class RuntimeScheduler final {
105105
* Thread synchronization must be enforced externally.
106106
*/
107107
void callExpiredTasks(jsi::Runtime &runtime);
108-
void setEnableYielding(bool enableYielding);
109108

110109
private:
111110
mutable std::priority_queue<
@@ -144,15 +143,6 @@ class RuntimeScheduler final {
144143
*/
145144
mutable std::atomic_bool isWorkLoopScheduled_{false};
146145

147-
/*
148-
* Flag indicating if yielding is enabled.
149-
*
150-
* If set to true and Concurrent Mode is enabled on the surface,
151-
* React Native will ask React to yield in case any work has been scheduled.
152-
* Default value is false
153-
*/
154-
bool enableYielding_{false};
155-
156146
/*
157147
* This flag is set while performing work, to prevent re-entrancy.
158148
*/

ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class RuntimeSchedulerTest : public testing::Test {
4343

4444
runtimeScheduler_ =
4545
std::make_unique<RuntimeScheduler>(runtimeExecutor, stubNow);
46-
runtimeScheduler_->setEnableYielding(true);
4746
}
4847

4948
jsi::Function createHostFunctionFromLambda(
@@ -317,24 +316,6 @@ TEST_F(RuntimeSchedulerTest, getCurrentPriorityLevel) {
317316
SchedulerPriority::NormalPriority);
318317
}
319318

320-
TEST_F(RuntimeSchedulerTest, scheduleWork) {
321-
runtimeScheduler_->setEnableYielding(false);
322-
bool wasCalled = false;
323-
runtimeScheduler_->scheduleWork(
324-
[&](jsi::Runtime const &) { wasCalled = true; });
325-
326-
EXPECT_FALSE(wasCalled);
327-
328-
EXPECT_FALSE(runtimeScheduler_->getShouldYield());
329-
330-
EXPECT_EQ(stubQueue_->size(), 1);
331-
332-
stubQueue_->tick();
333-
334-
EXPECT_TRUE(wasCalled);
335-
EXPECT_EQ(stubQueue_->size(), 0);
336-
}
337-
338319
TEST_F(RuntimeSchedulerTest, scheduleWorkWithYielding) {
339320
bool wasCalled = false;
340321
runtimeScheduler_->scheduleWork(

0 commit comments

Comments
 (0)