mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
0857238633
Summary: changelog: [internal] RuntimeScheduler's callbacks previously did not pass down argument `didUserCallbackTimeout`. This was intentionally left out because React team intended to remove it. But, as it turns out, it was not removed and it is needed for Offscreen to not enter infinite render loop. In React, it is used here: https://github.com/facebook/react/blob/main/packages/react-reconciler/src/ReactFiberWorkLoop.new.js#L1022-L1028 Reviewed By: ryancat Differential Revision: D40060377 fbshipit-source-id: c45719fbbd0275ab2bcf9a2bbf0191aaa96010cc
38 lines
1.0 KiB
C++
38 lines
1.0 KiB
C++
/*
|
|
* 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.
|
|
*/
|
|
|
|
#include "RuntimeScheduler.h"
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
Task::Task(
|
|
SchedulerPriority priority,
|
|
jsi::Function callback,
|
|
std::chrono::steady_clock::time_point expirationTime)
|
|
: priority(priority),
|
|
callback(std::move(callback)),
|
|
expirationTime(expirationTime) {}
|
|
|
|
jsi::Value Task::execute(jsi::Runtime &runtime, bool didUserCallbackTimeout) {
|
|
auto result = jsi::Value::undefined();
|
|
// Cancelled task doesn't have a callback.
|
|
if (callback) {
|
|
// Callback in JavaScript is expecting a single bool parameter.
|
|
// React team plans to remove it in the future when a scheduler bug on web
|
|
// is resolved.
|
|
result = callback.value().call(runtime, {didUserCallbackTimeout});
|
|
|
|
// Destroying callback to prevent calling it twice.
|
|
callback.reset();
|
|
}
|
|
return result;
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|