react-native 0.74.2 → 0.74.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/AppDelegate/RCTAppDelegate.mm +4 -1
- package/Libraries/AppDelegate/RCTRootViewFactory.h +8 -0
- package/Libraries/AppDelegate/RCTRootViewFactory.mm +11 -3
- package/Libraries/AppDelegate/React-RCTAppDelegate.podspec +2 -2
- package/Libraries/Blob/React-RCTBlob.podspec +1 -1
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Image/RCTImageLoader.mm +2 -6
- package/Libraries/Image/React-RCTImage.podspec +1 -1
- package/Libraries/LinkingIOS/React-RCTLinking.podspec +1 -1
- package/Libraries/NativeAnimation/React-RCTAnimation.podspec +1 -1
- package/Libraries/Network/RCTNetworkTask.mm +4 -3
- package/Libraries/Network/React-RCTNetwork.podspec +1 -1
- package/Libraries/PushNotificationIOS/React-RCTPushNotification.podspec +1 -1
- package/Libraries/Settings/React-RCTSettings.podspec +1 -1
- package/Libraries/Text/React-RCTText.podspec +1 -1
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.mm +6 -0
- package/Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h +1 -0
- package/Libraries/Text/TextInput/Singleline/RCTUITextField.mm +5 -0
- package/Libraries/TypeSafety/RCTTypeSafety.podspec +1 -1
- package/Libraries/Vibration/React-RCTVibration.podspec +1 -1
- package/React/Base/RCTVersion.m +1 -1
- package/React/CoreModules/React-CoreModules.podspec +1 -1
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +6 -1
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +4 -0
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +3 -2
- package/React/React-RCTFabric.podspec +1 -1
- package/React/Views/RCTComponentData.m +11 -3
- package/React-Core.podspec +1 -1
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +2 -4
- package/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.java +5 -2
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java +3 -1
- package/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.java +5 -0
- package/ReactApple/Libraries/RCTFoundation/RCTDeprecation/RCTDeprecation.podspec +1 -1
- package/ReactCommon/React-Fabric.podspec +1 -1
- package/ReactCommon/React-FabricImage.podspec +1 -1
- package/ReactCommon/React-Mapbuffer.podspec +1 -1
- package/ReactCommon/React-nativeconfig.podspec +1 -1
- package/ReactCommon/React-rncore.podspec +1 -1
- package/ReactCommon/ReactCommon.podspec +1 -1
- package/ReactCommon/cxxreact/React-cxxreact.podspec +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/hermes/React-hermes.podspec +1 -1
- package/ReactCommon/hermes/executor/React-jsitracing.podspec +1 -1
- package/ReactCommon/jsc/JSCRuntime.cpp +30 -2
- package/ReactCommon/jserrorhandler/React-jserrorhandler.podspec +1 -1
- package/ReactCommon/jsi/jsi/decorator.h +7 -0
- package/ReactCommon/jsi/jsi/jsi.h +7 -0
- package/ReactCommon/jsiexecutor/React-jsiexecutor.podspec +1 -1
- package/ReactCommon/jsinspector-modern/React-jsinspector.podspec +1 -1
- package/ReactCommon/react/debug/React-debug.podspec +1 -1
- package/ReactCommon/react/featureflags/React-featureflags.podspec +1 -1
- package/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp +53 -10
- package/ReactCommon/react/nativemodule/core/platform/ios/React-NativeModulesApple.podspec +1 -1
- package/ReactCommon/react/nativemodule/samples/ReactCommon-Samples.podspec +1 -1
- package/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm +4 -3
- package/ReactCommon/react/renderer/debug/React-rendererdebug.podspec +1 -1
- package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -1
- package/ReactCommon/react/renderer/imagemanager/platform/ios/React-ImageManager.podspec +1 -1
- package/ReactCommon/react/renderer/runtimescheduler/React-runtimescheduler.podspec +1 -1
- package/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp +0 -1
- package/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Legacy.cpp +3 -3
- package/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.cpp +28 -28
- package/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler_Modern.h +3 -3
- package/ReactCommon/react/renderer/runtimescheduler/Task.cpp +9 -7
- package/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp +46 -0
- package/ReactCommon/react/runtime/React-RuntimeCore.podspec +1 -1
- package/ReactCommon/react/runtime/React-RuntimeHermes.podspec +1 -1
- package/ReactCommon/react/runtime/platform/ios/React-RuntimeApple.podspec +1 -1
- package/ReactCommon/react/utils/React-utils.podspec +1 -1
- package/ReactCommon/reactperflogger/React-perflogger.podspec +1 -1
- package/package.json +11 -11
- package/scripts/cocoapods/helpers.rb +4 -0
- package/scripts/cocoapods/new_architecture.rb +10 -23
- package/scripts/cocoapods/privacy_manifest_utils.rb +11 -5
- package/scripts/cocoapods/utils.rb +12 -1
- package/scripts/codegen/generate-artifacts-executor.js +1 -1
- package/scripts/react_native_pods.rb +4 -0
- package/scripts/react_native_pods_utils/script_phases.sh +1 -1
- package/sdks/.hermesversion +1 -1
- package/sdks/hermes-engine/hermes-engine.podspec +2 -1
- package/sdks/hermes-engine/utils/build-apple-framework.sh +11 -5
- package/sdks/hermes-engine/utils/build-hermes-xcode.sh +11 -5
- package/sdks/hermes-engine/utils/build-ios-framework.sh +17 -5
- package/sdks/hermes-engine/utils/create-dummy-hermes-xcframework.sh +1 -1
- package/sdks/hermesc/osx-bin/hermes +0 -0
- package/sdks/hermesc/osx-bin/hermesc +0 -0
- package/sdks/hermesc/win64-bin/hermesc.exe +0 -0
- package/template/package.json +5 -5
- package/third-party-podspecs/RCT-Folly.podspec +1 -1
- package/third-party-podspecs/fmt.podspec +1 -1
- package/ReactCommon/react/renderer/runtimescheduler/ErrorUtils.h +0 -34
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
#include <atomic>
|
|
14
14
|
#include <condition_variable>
|
|
15
15
|
#include <cstdlib>
|
|
16
|
+
#include <deque>
|
|
16
17
|
#include <mutex>
|
|
17
|
-
#include <queue>
|
|
18
18
|
#include <sstream>
|
|
19
19
|
#include <thread>
|
|
20
20
|
|
|
@@ -51,6 +51,12 @@ class JSCRuntime : public jsi::Runtime {
|
|
|
51
51
|
const std::shared_ptr<const jsi::Buffer>& buffer,
|
|
52
52
|
const std::string& sourceURL) override;
|
|
53
53
|
|
|
54
|
+
// If we use this interface to implement microtasks in the host we need to
|
|
55
|
+
// polyfill `Promise` to use these methods, because JSC doesn't currently
|
|
56
|
+
// support providing a custom queue for its built-in implementation.
|
|
57
|
+
// Not doing this would result in a non-compliant behavior, as microtasks
|
|
58
|
+
// wouldn't execute in the order in which they were queued.
|
|
59
|
+
void queueMicrotask(const jsi::Function& callback) override;
|
|
54
60
|
bool drainMicrotasks(int maxMicrotasksHint = -1) override;
|
|
55
61
|
|
|
56
62
|
jsi::Object global() override;
|
|
@@ -265,6 +271,7 @@ class JSCRuntime : public jsi::Runtime {
|
|
|
265
271
|
std::atomic<bool> ctxInvalid_;
|
|
266
272
|
std::string desc_;
|
|
267
273
|
JSValueRef nativeStateSymbol_ = nullptr;
|
|
274
|
+
std::deque<jsi::Function> microtaskQueue_;
|
|
268
275
|
#ifndef NDEBUG
|
|
269
276
|
mutable std::atomic<intptr_t> objectCounter_;
|
|
270
277
|
mutable std::atomic<intptr_t> symbolCounter_;
|
|
@@ -380,6 +387,10 @@ JSCRuntime::JSCRuntime(JSGlobalContextRef ctx)
|
|
|
380
387
|
}
|
|
381
388
|
|
|
382
389
|
JSCRuntime::~JSCRuntime() {
|
|
390
|
+
// We need to clear the microtask queue to remove all references to the
|
|
391
|
+
// callbacks, so objectCounter_ would be 0 below.
|
|
392
|
+
microtaskQueue_.clear();
|
|
393
|
+
|
|
383
394
|
// On shutting down and cleaning up: when JSC is actually torn down,
|
|
384
395
|
// it calls JSC::Heap::lastChanceToFinalize internally which
|
|
385
396
|
// finalizes anything left over. But at this point,
|
|
@@ -436,7 +447,24 @@ jsi::Value JSCRuntime::evaluateJavaScript(
|
|
|
436
447
|
return createValue(res);
|
|
437
448
|
}
|
|
438
449
|
|
|
439
|
-
|
|
450
|
+
void JSCRuntime::queueMicrotask(const jsi::Function& callback) {
|
|
451
|
+
microtaskQueue_.emplace_back(
|
|
452
|
+
jsi::Value(*this, callback).asObject(*this).asFunction(*this));
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
bool JSCRuntime::drainMicrotasks(int /*maxMicrotasksHint*/) {
|
|
456
|
+
// Note that new jobs can be enqueued during the draining.
|
|
457
|
+
while (!microtaskQueue_.empty()) {
|
|
458
|
+
jsi::Function callback = std::move(microtaskQueue_.front());
|
|
459
|
+
|
|
460
|
+
// We need to pop before calling the callback because that might throw.
|
|
461
|
+
// When that happens, the host will call `drainMicrotasks` again to execute
|
|
462
|
+
// the remaining microtasks, and this one shouldn't run again.
|
|
463
|
+
microtaskQueue_.pop_front();
|
|
464
|
+
|
|
465
|
+
callback.call(*this);
|
|
466
|
+
}
|
|
467
|
+
|
|
440
468
|
return true;
|
|
441
469
|
}
|
|
442
470
|
|
|
@@ -36,7 +36,7 @@ Pod::Spec.new do |s|
|
|
|
36
36
|
s.source_files = "JsErrorHandler.{cpp,h}"
|
|
37
37
|
s.pod_target_xcconfig = {
|
|
38
38
|
"USE_HEADERMAP" => "YES",
|
|
39
|
-
"CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
39
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard()
|
|
40
40
|
}
|
|
41
41
|
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
|
|
42
42
|
|
|
@@ -126,6 +126,9 @@ class RuntimeDecorator : public Base, private jsi::Instrumentation {
|
|
|
126
126
|
const std::shared_ptr<const PreparedJavaScript>& js) override {
|
|
127
127
|
return plain().evaluatePreparedJavaScript(js);
|
|
128
128
|
}
|
|
129
|
+
void queueMicrotask(const jsi::Function& callback) override {
|
|
130
|
+
return plain().queueMicrotask(callback);
|
|
131
|
+
}
|
|
129
132
|
bool drainMicrotasks(int maxMicrotasksHint) override {
|
|
130
133
|
return plain().drainMicrotasks(maxMicrotasksHint);
|
|
131
134
|
}
|
|
@@ -544,6 +547,10 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
|
|
|
544
547
|
Around around{with_};
|
|
545
548
|
return RD::evaluatePreparedJavaScript(js);
|
|
546
549
|
}
|
|
550
|
+
void queueMicrotask(const Function& callback) override {
|
|
551
|
+
Around around{with_};
|
|
552
|
+
RD::queueMicrotask(callback);
|
|
553
|
+
}
|
|
547
554
|
bool drainMicrotasks(int maxMicrotasksHint) override {
|
|
548
555
|
Around around{with_};
|
|
549
556
|
return RD::drainMicrotasks(maxMicrotasksHint);
|
|
@@ -209,6 +209,13 @@ class JSI_EXPORT Runtime {
|
|
|
209
209
|
virtual Value evaluatePreparedJavaScript(
|
|
210
210
|
const std::shared_ptr<const PreparedJavaScript>& js) = 0;
|
|
211
211
|
|
|
212
|
+
/// Queues a microtask in the JavaScript VM internal Microtask (a.k.a. Job in
|
|
213
|
+
/// ECMA262) queue, to be executed when the host drains microtasks in
|
|
214
|
+
/// its event loop implementation.
|
|
215
|
+
///
|
|
216
|
+
/// \param callback a function to be executed as a microtask.
|
|
217
|
+
virtual void queueMicrotask(const jsi::Function& callback) = 0;
|
|
218
|
+
|
|
212
219
|
/// Drain the JavaScript VM internal Microtask (a.k.a. Job in ECMA262) queue.
|
|
213
220
|
///
|
|
214
221
|
/// \param maxMicrotasksHint a hint to tell an implementation that it should
|
|
@@ -33,7 +33,7 @@ Pod::Spec.new do |s|
|
|
|
33
33
|
s.source_files = "jsireact/*.{cpp,h}"
|
|
34
34
|
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
|
|
35
35
|
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/fmt/include\"",
|
|
36
|
-
"CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
36
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard() }
|
|
37
37
|
s.header_dir = "jsireact"
|
|
38
38
|
|
|
39
39
|
s.dependency "React-cxxreact", version
|
|
@@ -38,7 +38,7 @@ Pod::Spec.new do |s|
|
|
|
38
38
|
s.compiler_flags = folly_compiler_flags
|
|
39
39
|
s.pod_target_xcconfig = {
|
|
40
40
|
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/..\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/fmt/include\"",
|
|
41
|
-
"CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
41
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
42
42
|
"DEFINES_MODULE" => "YES"
|
|
43
43
|
}.merge!(use_frameworks ? {
|
|
44
44
|
"PUBLIC_HEADERS_FOLDER_PATH" => "#{module_name}.framework/Headers/#{header_dir}"
|
|
@@ -27,7 +27,7 @@ Pod::Spec.new do |s|
|
|
|
27
27
|
s.source = source
|
|
28
28
|
s.source_files = "**/*.{cpp,h}"
|
|
29
29
|
s.header_dir = "react/debug"
|
|
30
|
-
s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
30
|
+
s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
31
31
|
"DEFINES_MODULE" => "YES" }
|
|
32
32
|
|
|
33
33
|
if ENV['USE_FRAMEWORKS']
|
|
@@ -33,7 +33,7 @@ Pod::Spec.new do |s|
|
|
|
33
33
|
s.source = source
|
|
34
34
|
s.source_files = "*.{cpp,h}"
|
|
35
35
|
s.header_dir = "react/featureflags"
|
|
36
|
-
s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
36
|
+
s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
37
37
|
"HEADER_SEARCH_PATHS" => header_search_paths.join(' '),
|
|
38
38
|
"DEFINES_MODULE" => "YES" }
|
|
39
39
|
|
package/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp
CHANGED
|
@@ -86,6 +86,38 @@ struct JNIArgs {
|
|
|
86
86
|
std::vector<jobject> globalRefs_;
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
+
jsi::Value createJSRuntimeError(
|
|
90
|
+
jsi::Runtime& runtime,
|
|
91
|
+
const std::string& message) {
|
|
92
|
+
return runtime.global()
|
|
93
|
+
.getPropertyAsFunction(runtime, "Error")
|
|
94
|
+
.call(runtime, message);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
jsi::Value createRejectionError(jsi::Runtime& rt, const folly::dynamic& args) {
|
|
98
|
+
react_native_assert(
|
|
99
|
+
args.size() == 1 && "promise reject should has only one argument");
|
|
100
|
+
|
|
101
|
+
auto value = jsi::valueFromDynamic(rt, args[0]);
|
|
102
|
+
react_native_assert(value.isObject() && "promise reject should return a map");
|
|
103
|
+
|
|
104
|
+
const jsi::Object& valueAsObject = value.asObject(rt);
|
|
105
|
+
|
|
106
|
+
auto messageProperty = valueAsObject.getProperty(rt, "message");
|
|
107
|
+
auto jsError =
|
|
108
|
+
createJSRuntimeError(rt, messageProperty.asString(rt).utf8(rt));
|
|
109
|
+
|
|
110
|
+
auto jsErrorAsObject = jsError.asObject(rt);
|
|
111
|
+
auto propertyNames = valueAsObject.getPropertyNames(rt);
|
|
112
|
+
for (size_t i = 0; i < propertyNames.size(rt); ++i) {
|
|
113
|
+
auto propertyName = jsi::PropNameID::forString(
|
|
114
|
+
rt, propertyNames.getValueAtIndex(rt, i).asString(rt));
|
|
115
|
+
jsErrorAsObject.setProperty(
|
|
116
|
+
rt, propertyName, valueAsObject.getProperty(rt, propertyName));
|
|
117
|
+
}
|
|
118
|
+
return jsError;
|
|
119
|
+
}
|
|
120
|
+
|
|
89
121
|
auto createJavaCallback(
|
|
90
122
|
jsi::Runtime& rt,
|
|
91
123
|
jsi::Function&& function,
|
|
@@ -98,7 +130,6 @@ auto createJavaCallback(
|
|
|
98
130
|
LOG(FATAL) << "Callback arg cannot be called more than once";
|
|
99
131
|
return;
|
|
100
132
|
}
|
|
101
|
-
|
|
102
133
|
callback->call([args = std::move(args)](
|
|
103
134
|
jsi::Runtime& rt, jsi::Function& jsFunction) {
|
|
104
135
|
std::vector<jsi::Value> jsArgs;
|
|
@@ -112,6 +143,26 @@ auto createJavaCallback(
|
|
|
112
143
|
});
|
|
113
144
|
}
|
|
114
145
|
|
|
146
|
+
auto createJavaRejectCallback(
|
|
147
|
+
jsi::Runtime& rt,
|
|
148
|
+
jsi::Function&& function,
|
|
149
|
+
std::shared_ptr<CallInvoker> jsInvoker) {
|
|
150
|
+
std::optional<AsyncCallback<>> callback(
|
|
151
|
+
{rt, std::move(function), std::move(jsInvoker)});
|
|
152
|
+
return JCxxCallbackImpl::newObjectCxxArgs(
|
|
153
|
+
[callback = std::move(callback)](folly::dynamic args) mutable {
|
|
154
|
+
if (!callback) {
|
|
155
|
+
LOG(FATAL) << "Callback arg cannot be called more than once";
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
callback->call([args = std::move(args)](
|
|
159
|
+
jsi::Runtime& rt, jsi::Function& jsFunction) {
|
|
160
|
+
jsFunction.call(rt, createRejectionError(rt, args));
|
|
161
|
+
});
|
|
162
|
+
callback = std::nullopt;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
115
166
|
struct JPromiseImpl : public jni::JavaClass<JPromiseImpl> {
|
|
116
167
|
constexpr static auto kJavaDescriptor =
|
|
117
168
|
"Lcom/facebook/react/bridge/PromiseImpl;";
|
|
@@ -407,14 +458,6 @@ jsi::Value convertFromJMapToValue(JNIEnv* env, jsi::Runtime& rt, jobject arg) {
|
|
|
407
458
|
return jsi::valueFromDynamic(rt, result->cthis()->consume());
|
|
408
459
|
}
|
|
409
460
|
|
|
410
|
-
jsi::Value createJSRuntimeError(
|
|
411
|
-
jsi::Runtime& runtime,
|
|
412
|
-
const std::string& message) {
|
|
413
|
-
return runtime.global()
|
|
414
|
-
.getPropertyAsFunction(runtime, "Error")
|
|
415
|
-
.call(runtime, message);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
461
|
/**
|
|
419
462
|
* Creates JSError with current JS runtime stack and Throwable stack trace.
|
|
420
463
|
*/
|
|
@@ -855,7 +898,7 @@ jsi::Value JavaTurboModule::invokeJavaMethod(
|
|
|
855
898
|
runtime,
|
|
856
899
|
args[0].getObject(runtime).getFunction(runtime),
|
|
857
900
|
jsInvoker_);
|
|
858
|
-
auto reject =
|
|
901
|
+
auto reject = createJavaRejectCallback(
|
|
859
902
|
runtime,
|
|
860
903
|
args[1].getObject(runtime).getFunction(runtime),
|
|
861
904
|
jsInvoker_);
|
|
@@ -36,7 +36,7 @@ Pod::Spec.new do |s|
|
|
|
36
36
|
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
|
|
37
37
|
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/fmt/include\" \"$(PODS_ROOT)/Headers/Private/React-Core\"",
|
|
38
38
|
"USE_HEADERMAP" => "YES",
|
|
39
|
-
"CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
39
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
40
40
|
"GCC_WARN_PEDANTIC" => "YES" }
|
|
41
41
|
if ENV['USE_FRAMEWORKS']
|
|
42
42
|
s.header_mappings_dir = './'
|
|
@@ -47,7 +47,7 @@ Pod::Spec.new do |s|
|
|
|
47
47
|
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
|
|
48
48
|
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => header_search_paths,
|
|
49
49
|
"USE_HEADERMAP" => "YES",
|
|
50
|
-
"CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
50
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
51
51
|
"GCC_WARN_PEDANTIC" => "YES" }
|
|
52
52
|
if ENV['USE_FRAMEWORKS']
|
|
53
53
|
s.header_mappings_dir = './'
|
|
@@ -125,9 +125,10 @@ static const std::shared_ptr<void> constructCoordinator(
|
|
|
125
125
|
bridgeModuleDecorator = unwrapManagedObject(optionalModuleDecorator.value());
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
RCTComponentData *componentData =
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
RCTComponentData *componentData =
|
|
129
|
+
[[RCTComponentData alloc] initWithManagerClass:viewManagerClass
|
|
130
|
+
bridge:bridge != nil ? bridge : (RCTBridge *)bridgeProxy
|
|
131
|
+
eventDispatcher:eventDispatcher];
|
|
131
132
|
return wrapManagedObject([[RCTLegacyViewManagerInteropCoordinator alloc]
|
|
132
133
|
initWithComponentData:componentData
|
|
133
134
|
bridge:bridge
|
|
@@ -45,7 +45,7 @@ Pod::Spec.new do |s|
|
|
|
45
45
|
s.header_dir = "react/renderer/debug"
|
|
46
46
|
s.exclude_files = "tests"
|
|
47
47
|
s.pod_target_xcconfig = {
|
|
48
|
-
"CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
48
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
49
49
|
"HEADER_SEARCH_PATHS" => header_search_paths.join(' '),
|
|
50
50
|
"DEFINES_MODULE" => "YES"
|
|
51
51
|
}
|
|
@@ -57,7 +57,7 @@ Pod::Spec.new do |s|
|
|
|
57
57
|
s.pod_target_xcconfig = { "USE_HEADERMAP" => "NO",
|
|
58
58
|
"HEADER_SEARCH_PATHS" => header_search_paths.join(" "),
|
|
59
59
|
"DEFINES_MODULE" => "YES",
|
|
60
|
-
"CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
60
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard() }
|
|
61
61
|
|
|
62
62
|
s.dependency "glog"
|
|
63
63
|
s.dependency "RCT-Folly/Fabric", folly_version
|
|
@@ -50,7 +50,7 @@ Pod::Spec.new do |s|
|
|
|
50
50
|
s.pod_target_xcconfig = {
|
|
51
51
|
"USE_HEADERMAP" => "NO",
|
|
52
52
|
"HEADER_SEARCH_PATHS" => header_search_paths,
|
|
53
|
-
"CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
53
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
54
54
|
"DEFINES_MODULE" => "YES",
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -43,7 +43,7 @@ Pod::Spec.new do |s|
|
|
|
43
43
|
s.header_dir = "react/renderer/runtimescheduler"
|
|
44
44
|
s.exclude_files = "tests"
|
|
45
45
|
s.pod_target_xcconfig = {
|
|
46
|
-
"CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
46
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
47
47
|
"HEADER_SEARCH_PATHS" => header_search_paths.join(' ')}
|
|
48
48
|
|
|
49
49
|
if ENV['USE_FRAMEWORKS']
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
#include "RuntimeScheduler_Legacy.h"
|
|
9
9
|
#include "SchedulerPriorityUtils.h"
|
|
10
10
|
|
|
11
|
+
#include <cxxreact/ErrorUtils.h>
|
|
11
12
|
#include <react/renderer/debug/SystraceSection.h>
|
|
12
13
|
#include <utility>
|
|
13
|
-
#include "ErrorUtils.h"
|
|
14
14
|
|
|
15
15
|
namespace facebook::react {
|
|
16
16
|
|
|
@@ -136,7 +136,7 @@ void RuntimeScheduler_Legacy::callExpiredTasks(jsi::Runtime& runtime) {
|
|
|
136
136
|
executeTask(runtime, topPriorityTask, didUserCallbackTimeout);
|
|
137
137
|
}
|
|
138
138
|
} catch (jsi::JSError& error) {
|
|
139
|
-
|
|
139
|
+
handleJSError(runtime, error, true);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
currentPriority_ = previousPriority;
|
|
@@ -182,7 +182,7 @@ void RuntimeScheduler_Legacy::startWorkLoop(jsi::Runtime& runtime) {
|
|
|
182
182
|
executeTask(runtime, topPriorityTask, didUserCallbackTimeout);
|
|
183
183
|
}
|
|
184
184
|
} catch (jsi::JSError& error) {
|
|
185
|
-
|
|
185
|
+
handleJSError(runtime, error, true);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
currentPriority_ = previousPriority;
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
#include <react/featureflags/ReactNativeFeatureFlags.h>
|
|
13
13
|
#include <react/renderer/debug/SystraceSection.h>
|
|
14
14
|
#include <utility>
|
|
15
|
-
#include "ErrorUtils.h"
|
|
16
15
|
|
|
17
16
|
namespace facebook::react {
|
|
18
17
|
|
|
@@ -104,7 +103,7 @@ bool RuntimeScheduler_Modern::getShouldYield() const noexcept {
|
|
|
104
103
|
std::shared_lock lock(schedulingMutex_);
|
|
105
104
|
|
|
106
105
|
return syncTaskRequests_ > 0 ||
|
|
107
|
-
(!taskQueue_.empty() && taskQueue_.top() != currentTask_);
|
|
106
|
+
(!taskQueue_.empty() && taskQueue_.top().get() != currentTask_);
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
bool RuntimeScheduler_Modern::getIsSynchronous() const noexcept {
|
|
@@ -144,9 +143,8 @@ void RuntimeScheduler_Modern::executeNowOnTheSameThread(
|
|
|
144
143
|
auto priority = SchedulerPriority::ImmediatePriority;
|
|
145
144
|
auto expirationTime =
|
|
146
145
|
currentTime + timeoutForSchedulerPriority(priority);
|
|
147
|
-
auto task = std::make_shared<Task>(
|
|
148
|
-
priority, std::move(callback), expirationTime);
|
|
149
146
|
|
|
147
|
+
auto task = Task{priority, std::move(callback), expirationTime};
|
|
150
148
|
executeTask(runtime, task, currentTime);
|
|
151
149
|
|
|
152
150
|
isSynchronous_ = false;
|
|
@@ -231,21 +229,17 @@ void RuntimeScheduler_Modern::startWorkLoop(
|
|
|
231
229
|
|
|
232
230
|
auto previousPriority = currentPriority_;
|
|
233
231
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
auto topPriorityTask = selectTask(currentTime, onlyExpired);
|
|
232
|
+
while (syncTaskRequests_ == 0) {
|
|
233
|
+
auto currentTime = now_();
|
|
234
|
+
auto topPriorityTask = selectTask(currentTime, onlyExpired);
|
|
238
235
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
executeTask(runtime, topPriorityTask, currentTime);
|
|
236
|
+
if (!topPriorityTask) {
|
|
237
|
+
// No pending work to do.
|
|
238
|
+
// Events will restart the loop when necessary.
|
|
239
|
+
break;
|
|
246
240
|
}
|
|
247
|
-
|
|
248
|
-
|
|
241
|
+
|
|
242
|
+
executeTask(runtime, *topPriorityTask, currentTime);
|
|
249
243
|
}
|
|
250
244
|
|
|
251
245
|
currentPriority_ = previousPriority;
|
|
@@ -280,19 +274,19 @@ std::shared_ptr<Task> RuntimeScheduler_Modern::selectTask(
|
|
|
280
274
|
|
|
281
275
|
void RuntimeScheduler_Modern::executeTask(
|
|
282
276
|
jsi::Runtime& runtime,
|
|
283
|
-
|
|
277
|
+
Task& task,
|
|
284
278
|
RuntimeSchedulerTimePoint currentTime) {
|
|
285
|
-
auto didUserCallbackTimeout = task
|
|
279
|
+
auto didUserCallbackTimeout = task.expirationTime <= currentTime;
|
|
286
280
|
|
|
287
281
|
SystraceSection s(
|
|
288
282
|
"RuntimeScheduler::executeTask",
|
|
289
283
|
"priority",
|
|
290
|
-
serialize(task
|
|
284
|
+
serialize(task.priority),
|
|
291
285
|
"didUserCallbackTimeout",
|
|
292
286
|
didUserCallbackTimeout);
|
|
293
287
|
|
|
294
|
-
currentTask_ = task;
|
|
295
|
-
currentPriority_ = task
|
|
288
|
+
currentTask_ = &task;
|
|
289
|
+
currentPriority_ = task.priority;
|
|
296
290
|
|
|
297
291
|
executeMacrotask(runtime, task, didUserCallbackTimeout);
|
|
298
292
|
|
|
@@ -305,6 +299,8 @@ void RuntimeScheduler_Modern::executeTask(
|
|
|
305
299
|
// "Update the rendering" step.
|
|
306
300
|
updateRendering();
|
|
307
301
|
}
|
|
302
|
+
|
|
303
|
+
currentTask_ = nullptr;
|
|
308
304
|
}
|
|
309
305
|
|
|
310
306
|
/**
|
|
@@ -326,16 +322,20 @@ void RuntimeScheduler_Modern::updateRendering() {
|
|
|
326
322
|
|
|
327
323
|
void RuntimeScheduler_Modern::executeMacrotask(
|
|
328
324
|
jsi::Runtime& runtime,
|
|
329
|
-
|
|
325
|
+
Task& task,
|
|
330
326
|
bool didUserCallbackTimeout) const {
|
|
331
327
|
SystraceSection s("RuntimeScheduler::executeMacrotask");
|
|
332
328
|
|
|
333
|
-
|
|
329
|
+
try {
|
|
330
|
+
auto result = task.execute(runtime, didUserCallbackTimeout);
|
|
334
331
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
332
|
+
if (result.isObject() && result.getObject(runtime).isFunction(runtime)) {
|
|
333
|
+
// If the task returned a continuation callback, we re-assign it to the
|
|
334
|
+
// task and keep the task in the queue.
|
|
335
|
+
task.callback = result.getObject(runtime).getFunction(runtime);
|
|
336
|
+
}
|
|
337
|
+
} catch (jsi::JSError& error) {
|
|
338
|
+
handleJSError(runtime, error, true);
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
|
|
@@ -139,7 +139,7 @@ class RuntimeScheduler_Modern final : public RuntimeSchedulerBase {
|
|
|
139
139
|
TaskPriorityComparer>
|
|
140
140
|
taskQueue_;
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
Task* currentTask_{};
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* This protects the access to `taskQueue_` and `isWorkLoopScheduled_`.
|
|
@@ -168,12 +168,12 @@ class RuntimeScheduler_Modern final : public RuntimeSchedulerBase {
|
|
|
168
168
|
*/
|
|
169
169
|
void executeTask(
|
|
170
170
|
jsi::Runtime& runtime,
|
|
171
|
-
|
|
171
|
+
Task& task,
|
|
172
172
|
RuntimeSchedulerTimePoint currentTime);
|
|
173
173
|
|
|
174
174
|
void executeMacrotask(
|
|
175
175
|
jsi::Runtime& runtime,
|
|
176
|
-
|
|
176
|
+
Task& task,
|
|
177
177
|
bool didUserCallbackTimeout) const;
|
|
178
178
|
|
|
179
179
|
void updateRendering();
|
|
@@ -32,20 +32,22 @@ jsi::Value Task::execute(jsi::Runtime& runtime, bool didUserCallbackTimeout) {
|
|
|
32
32
|
return result;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
// We get the value of the callback and reset it immediately to avoid it being
|
|
36
|
+
// called more than once (including when the callback throws).
|
|
37
|
+
auto originalCallback = std::move(*callback);
|
|
38
|
+
callback.reset();
|
|
36
39
|
|
|
37
|
-
if (
|
|
40
|
+
if (originalCallback.index() == 0) {
|
|
38
41
|
// Callback in JavaScript is expecting a single bool parameter.
|
|
39
42
|
// React team plans to remove it in the future when a scheduler bug on web
|
|
40
43
|
// is resolved.
|
|
41
|
-
result =
|
|
42
|
-
|
|
44
|
+
result = std::get<jsi::Function>(originalCallback)
|
|
45
|
+
.call(runtime, {didUserCallbackTimeout});
|
|
43
46
|
} else {
|
|
44
47
|
// Calling a raw callback
|
|
45
|
-
std::get<RawCallback>(
|
|
48
|
+
std::get<RawCallback>(originalCallback)(runtime);
|
|
46
49
|
}
|
|
47
|
-
|
|
48
|
-
callback.reset();
|
|
50
|
+
|
|
49
51
|
return result;
|
|
50
52
|
}
|
|
51
53
|
|
|
@@ -1021,6 +1021,52 @@ TEST_P(RuntimeSchedulerTest, modernTwoThreadsRequestAccessToTheRuntime) {
|
|
|
1021
1021
|
EXPECT_EQ(stubQueue_->size(), 0);
|
|
1022
1022
|
}
|
|
1023
1023
|
|
|
1024
|
+
TEST_P(RuntimeSchedulerTest, errorInTaskShouldNotStopMicrotasks) {
|
|
1025
|
+
// Only for modern runtime scheduler
|
|
1026
|
+
if (!GetParam()) {
|
|
1027
|
+
return;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
auto microtaskRan = false;
|
|
1031
|
+
auto taskRan = false;
|
|
1032
|
+
|
|
1033
|
+
auto callback = createHostFunctionFromLambda([&](bool /* unused */) {
|
|
1034
|
+
taskRan = true;
|
|
1035
|
+
|
|
1036
|
+
auto microtaskCallback = jsi::Function::createFromHostFunction(
|
|
1037
|
+
*runtime_,
|
|
1038
|
+
jsi::PropNameID::forUtf8(*runtime_, "microtask1"),
|
|
1039
|
+
3,
|
|
1040
|
+
[&](jsi::Runtime& /*unused*/,
|
|
1041
|
+
const jsi::Value& /*unused*/,
|
|
1042
|
+
const jsi::Value* /*arguments*/,
|
|
1043
|
+
size_t /*unused*/) -> jsi::Value {
|
|
1044
|
+
microtaskRan = true;
|
|
1045
|
+
return jsi::Value::undefined();
|
|
1046
|
+
});
|
|
1047
|
+
|
|
1048
|
+
runtime_->queueMicrotask(microtaskCallback);
|
|
1049
|
+
|
|
1050
|
+
throw jsi::JSError(*runtime_, "Test error");
|
|
1051
|
+
|
|
1052
|
+
return jsi::Value::undefined();
|
|
1053
|
+
});
|
|
1054
|
+
|
|
1055
|
+
runtimeScheduler_->scheduleTask(
|
|
1056
|
+
SchedulerPriority::NormalPriority, std::move(callback));
|
|
1057
|
+
|
|
1058
|
+
EXPECT_EQ(taskRan, false);
|
|
1059
|
+
EXPECT_EQ(microtaskRan, false);
|
|
1060
|
+
EXPECT_EQ(stubQueue_->size(), 1);
|
|
1061
|
+
|
|
1062
|
+
stubQueue_->tick();
|
|
1063
|
+
|
|
1064
|
+
EXPECT_EQ(taskRan, 1);
|
|
1065
|
+
EXPECT_EQ(microtaskRan, 1);
|
|
1066
|
+
EXPECT_EQ(stubQueue_->size(), 0);
|
|
1067
|
+
EXPECT_EQ(stubErrorUtils_->getReportFatalCallCount(), 1);
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1024
1070
|
INSTANTIATE_TEST_SUITE_P(
|
|
1025
1071
|
UseModernRuntimeScheduler,
|
|
1026
1072
|
RuntimeSchedulerTest,
|
|
@@ -37,7 +37,7 @@ Pod::Spec.new do |s|
|
|
|
37
37
|
s.header_dir = "react/runtime"
|
|
38
38
|
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/Headers/Private/React-Core\" \"${PODS_TARGET_SRCROOT}/../..\"",
|
|
39
39
|
"USE_HEADERMAP" => "YES",
|
|
40
|
-
"CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
40
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
41
41
|
"GCC_WARN_PEDANTIC" => "YES" }
|
|
42
42
|
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
|
|
43
43
|
|
|
@@ -35,7 +35,7 @@ Pod::Spec.new do |s|
|
|
|
35
35
|
s.header_dir = "react/runtime/hermes"
|
|
36
36
|
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"${PODS_TARGET_SRCROOT}/../..\" \"${PODS_TARGET_SRCROOT}/../../hermes/executor\" \"$(PODS_ROOT)/boost\"",
|
|
37
37
|
"USE_HEADERMAP" => "YES",
|
|
38
|
-
"CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
38
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
39
39
|
"GCC_WARN_PEDANTIC" => "YES" }
|
|
40
40
|
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
|
|
41
41
|
|
|
@@ -42,7 +42,7 @@ Pod::Spec.new do |s|
|
|
|
42
42
|
s.header_dir = "ReactCommon"
|
|
43
43
|
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => header_search_paths,
|
|
44
44
|
"USE_HEADERMAP" => "YES",
|
|
45
|
-
"CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
45
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
46
46
|
"GCC_WARN_PEDANTIC" => "YES" }
|
|
47
47
|
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
|
|
48
48
|
|
|
@@ -39,7 +39,7 @@ Pod::Spec.new do |s|
|
|
|
39
39
|
s.compiler_flags = folly_compiler_flags
|
|
40
40
|
s.header_dir = "react/utils"
|
|
41
41
|
s.exclude_files = "tests"
|
|
42
|
-
s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
42
|
+
s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
|
|
43
43
|
"HEADER_SEARCH_PATHS" => header_search_paths.join(' '),
|
|
44
44
|
"DEFINES_MODULE" => "YES" }
|
|
45
45
|
|
|
@@ -32,5 +32,5 @@ Pod::Spec.new do |s|
|
|
|
32
32
|
s.source = source
|
|
33
33
|
s.source_files = "**/*.{cpp,h}"
|
|
34
34
|
s.header_dir = "reactperflogger"
|
|
35
|
-
s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" =>
|
|
35
|
+
s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard() }
|
|
36
36
|
end
|