react-native 0.84.0-nightly-20251106-de5141a3d → 0.84.0-nightly-20251108-7486a2bc5
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/Animated/createAnimatedComponent.js +1 -0
- package/Libraries/Blob/RCTBlobManager.mm +1 -4
- package/Libraries/Blob/RCTBlobPlugins.mm +14 -14
- package/Libraries/Blob/RCTFileReaderModule.mm +1 -4
- package/Libraries/Components/Button.js +0 -3
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Image/RCTBundleAssetImageLoader.mm +1 -4
- package/Libraries/Image/RCTGIFImageDecoder.mm +1 -4
- package/Libraries/Image/RCTImageEditingManager.mm +1 -4
- package/Libraries/Image/RCTImageLoader.mm +1 -4
- package/Libraries/Image/RCTImagePlugins.h +1 -0
- package/Libraries/Image/RCTImagePlugins.mm +30 -17
- package/Libraries/Image/RCTImageStoreManager.mm +1 -4
- package/Libraries/Image/RCTImageViewManager.mm +1 -4
- package/Libraries/Image/RCTLocalAssetImageLoader.mm +1 -4
- package/Libraries/LinkingIOS/RCTLinkingManager.mm +1 -4
- package/Libraries/LinkingIOS/RCTLinkingPlugins.mm +10 -13
- package/Libraries/LogBox/Data/LogBoxData.js +31 -4
- package/Libraries/NativeAnimation/RCTAnimationPlugins.mm +14 -14
- package/Libraries/NativeAnimation/RCTNativeAnimatedModule.mm +1 -4
- package/Libraries/NativeAnimation/RCTNativeAnimatedTurboModule.mm +1 -4
- package/Libraries/Network/RCTDataRequestHandler.mm +1 -4
- package/Libraries/Network/RCTFileRequestHandler.mm +1 -4
- package/Libraries/Network/RCTHTTPRequestHandler.mm +1 -4
- package/Libraries/Network/RCTNetworkPlugins.mm +22 -16
- package/Libraries/Network/RCTNetworking.mm +1 -4
- package/Libraries/PushNotificationIOS/RCTPushNotificationManager.mm +1 -4
- package/Libraries/PushNotificationIOS/RCTPushNotificationPlugins.mm +10 -13
- package/Libraries/Settings/RCTSettingsManager.mm +1 -4
- package/Libraries/Settings/RCTSettingsPlugins.mm +10 -13
- package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +2 -2
- package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +1 -1
- package/Libraries/StyleSheet/PlatformColorValueTypes.js.flow +4 -2
- package/Libraries/Text/BaseText/RCTBaseTextViewManager.mm +1 -4
- package/Libraries/Text/RawText/RCTRawTextViewManager.mm +1 -4
- package/Libraries/Text/Text/RCTTextViewManager.mm +1 -4
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.mm +1 -4
- package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.mm +1 -4
- package/Libraries/Text/TextInput/RCTInputAccessoryViewManager.mm +1 -4
- package/Libraries/Text/TextInput/Singleline/RCTSinglelineTextInputViewManager.mm +1 -4
- package/Libraries/Text/VirtualText/RCTVirtualTextViewManager.mm +1 -4
- package/Libraries/Vibration/RCTVibration.mm +1 -4
- package/Libraries/Vibration/RCTVibrationPlugins.mm +10 -13
- package/React/Base/RCTVersion.m +1 -1
- package/React/CoreModules/CoreModulesPlugins.mm +98 -35
- package/React/CoreModules/RCTAccessibilityManager.mm +1 -4
- package/React/CoreModules/RCTActionSheetManager.mm +1 -4
- package/React/CoreModules/RCTAlertManager.mm +1 -4
- package/React/CoreModules/RCTAppState.mm +1 -4
- package/React/CoreModules/RCTAppearance.mm +1 -4
- package/React/CoreModules/RCTClipboard.mm +1 -4
- package/React/CoreModules/RCTDevLoadingView.mm +1 -4
- package/React/CoreModules/RCTDevMenu.mm +1 -4
- package/React/CoreModules/RCTDevSettings.mm +1 -4
- package/React/CoreModules/RCTDevToolsRuntimeSettingsModule.mm +1 -5
- package/React/CoreModules/RCTDeviceInfo.mm +1 -4
- package/React/CoreModules/RCTEventDispatcher.mm +1 -4
- package/React/CoreModules/RCTExceptionsManager.mm +1 -4
- package/React/CoreModules/RCTI18nManager.mm +1 -4
- package/React/CoreModules/RCTKeyboardObserver.mm +1 -4
- package/React/CoreModules/RCTLogBox.mm +1 -4
- package/React/CoreModules/RCTPerfMonitor.mm +1 -4
- package/React/CoreModules/RCTPlatform.mm +1 -4
- package/React/CoreModules/RCTRedBox.mm +1 -4
- package/React/CoreModules/RCTSourceCode.mm +1 -4
- package/React/CoreModules/RCTStatusBarManager.mm +1 -4
- package/React/CoreModules/RCTTiming.mm +1 -4
- package/React/CoreModules/RCTWebSocketModule.mm +1 -4
- package/React/FBReactNativeSpec/FBReactNativeSpecJSI.h +16 -0
- package/React/Modules/RCTUIManager.mm +1 -4
- package/React/Views/RCTActivityIndicatorViewManager.m +1 -4
- package/React/Views/RCTDebuggingOverlayManager.m +1 -4
- package/React/Views/RCTModalHostViewManager.m +1 -4
- package/React/Views/RCTModalManager.m +1 -4
- package/React/Views/RCTSwitchManager.m +1 -4
- package/React/Views/RCTViewManager.m +1 -4
- package/React/Views/RefreshControl/RCTRefreshControlManager.m +1 -4
- package/React/Views/SafeAreaView/RCTSafeAreaViewManager.m +1 -4
- package/React/Views/ScrollView/RCTScrollContentViewManager.m +1 -4
- package/React/Views/ScrollView/RCTScrollViewManager.m +1 -4
- package/ReactAndroid/api/ReactAndroid.api +0 -13
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/ReactPackageTurboModuleManagerDelegate.kt +2 -3
- package/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java +2 -6
- package/ReactAndroid/src/main/java/com/facebook/react/bridge/ModuleHolder.kt +2 -2
- package/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModuleRegistry.kt +1 -16
- package/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt +13 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt +21 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt +5 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt +5 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt +23 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt +5 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/turbomodule/core/TurboModuleManager.kt +2 -35
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +4 -5
- package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/VirtualViewContainerStateExperimental.kt +7 -0
- package/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp +12 -0
- package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp +29 -1
- package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h +7 -1
- package/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp +3 -13
- package/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.h +1 -4
- package/ReactAndroid/src/main/jni/react/jni/CxxModuleWrapperBase.h +0 -24
- package/ReactAndroid/src/main/jni/react/jni/JavaModuleWrapper.cpp +0 -1
- package/ReactAndroid/src/main/jni/react/jni/ModuleRegistryBuilder.cpp +1 -29
- package/ReactAndroid/src/main/jni/react/jni/ModuleRegistryBuilder.h +1 -2
- package/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp +0 -2
- package/ReactAndroid/src/main/jni/react/runtime/jni/JReactHostInspectorTarget.cpp +8 -1
- package/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp +2 -1
- package/ReactAndroid/src/main/jni/react/turbomodule/ReactCommon/TurboModuleManager.cpp +1 -35
- package/ReactAndroid/src/main/jni/third-party/folly/CMakeLists.txt +1 -0
- package/ReactApple/RCTAnimatedModuleProvider/RCTAnimatedModuleProvider.mm +29 -4
- package/ReactCommon/cxxreact/ReactMarker.cpp +0 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/jsiexecutor/CMakeLists.txt +3 -1
- package/ReactCommon/jsiexecutor/React-jsiexecutor.podspec +2 -0
- package/ReactCommon/jsiexecutor/jsireact/JSIExecutor.cpp +0 -40
- package/ReactCommon/jsiexecutor/jsireact/JSIExecutor.h +1 -6
- package/ReactCommon/jsinspector-modern/ConsoleTask.cpp +27 -0
- package/ReactCommon/jsinspector-modern/ConsoleTask.h +38 -0
- package/ReactCommon/jsinspector-modern/ConsoleTaskContext.cpp +46 -0
- package/ReactCommon/jsinspector-modern/ConsoleTaskContext.h +102 -0
- package/ReactCommon/jsinspector-modern/ConsoleTaskOrchestrator.cpp +55 -0
- package/ReactCommon/jsinspector-modern/ConsoleTaskOrchestrator.h +48 -0
- package/ReactCommon/jsinspector-modern/HostTarget.h +8 -2
- package/ReactCommon/jsinspector-modern/HostTargetTraceRecording.cpp +6 -2
- package/ReactCommon/jsinspector-modern/HostTargetTraceRecording.h +15 -5
- package/ReactCommon/jsinspector-modern/HostTargetTracing.cpp +9 -5
- package/ReactCommon/jsinspector-modern/RuntimeAgent.cpp +3 -2
- package/ReactCommon/jsinspector-modern/RuntimeAgent.h +1 -1
- package/ReactCommon/jsinspector-modern/RuntimeTarget.cpp +12 -0
- package/ReactCommon/jsinspector-modern/RuntimeTarget.h +16 -13
- package/ReactCommon/jsinspector-modern/RuntimeTargetConsole.cpp +106 -1
- package/ReactCommon/jsinspector-modern/TracingAgent.cpp +19 -2
- package/ReactCommon/jsinspector-modern/tests/ConsoleCreateTaskTest.cpp +131 -0
- package/ReactCommon/jsinspector-modern/tests/ReactInstanceIntegrationTest.cpp +1 -0
- package/ReactCommon/jsinspector-modern/tests/TracingTest.cpp +59 -0
- package/ReactCommon/jsinspector-modern/tests/TracingTest.h +20 -7
- package/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp +32 -20
- package/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h +6 -2
- package/ReactCommon/jsinspector-modern/tracing/TargetTracingAgent.h +5 -0
- package/ReactCommon/jsinspector-modern/tracing/TraceEvent.h +2 -1
- package/ReactCommon/jsinspector-modern/tracing/TraceEventSerializer.cpp +2 -1
- package/ReactCommon/jsinspector-modern/tracing/TraceRecordingState.h +3 -0
- package/ReactCommon/jsinspector-modern/tracing/TracingCategory.h +126 -0
- package/ReactCommon/jsitooling/react/runtime/JSRuntimeBindings.cpp +54 -0
- package/ReactCommon/jsitooling/react/runtime/JSRuntimeBindings.h +20 -0
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp +9 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h +11 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp +113 -77
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h +6 -2
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h +9 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h +19 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +3 -1
- package/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm +0 -1
- package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp +11 -1
- package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +5 -1
- package/ReactCommon/react/nativemodule/samples/platform/ios/ReactCommon/RCTSampleTurboModule.mm +1 -4
- package/ReactCommon/react/performance/timeline/CMakeLists.txt +1 -0
- package/ReactCommon/react/performance/timeline/PerformanceEntryReporter.cpp +9 -1
- package/ReactCommon/react/performance/timeline/React-performancetimeline.podspec +1 -0
- package/ReactCommon/react/renderer/animated/NativeAnimatedNodesManager.cpp +24 -19
- package/ReactCommon/react/renderer/animated/NativeAnimatedNodesManagerProvider.cpp +11 -6
- package/ReactCommon/react/renderer/animationbackend/AnimationBackend.cpp +67 -32
- package/ReactCommon/react/renderer/animationbackend/AnimationBackend.h +14 -2
- package/ReactCommon/react/renderer/core/EventDispatcher.cpp +1 -1
- package/ReactCommon/react/renderer/core/EventQueueProcessor.cpp +3 -3
- package/ReactCommon/react/runtime/ReactInstance.cpp +8 -6
- package/ReactCommon/react/runtime/ReactInstance.h +0 -1
- package/ReactCommon/react/runtime/TimerManager.cpp +0 -54
- package/ReactCommon/react/runtime/TimerManager.h +0 -12
- package/flow/bom.js.flow +7 -0
- package/package.json +8 -8
- package/scripts/ios-configure-glog.sh +6 -1
- package/src/private/featureflags/ReactNativeFeatureFlags.js +11 -1
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +3 -1
- package/types_generated/Libraries/Components/Button.d.ts +1 -4
- package/types_generated/Libraries/StyleSheet/PlatformColorValueTypes.d.ts +3 -3
- package/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapper.kt +0 -25
- package/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapperBase.kt +0 -61
- package/ReactAndroid/src/main/jni/react/jni/CxxModuleWrapper.h +0 -37
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "StackTrace.h"
|
|
11
|
+
|
|
12
|
+
#include <folly/dynamic.h>
|
|
13
|
+
#include <jsi/jsi.h>
|
|
14
|
+
|
|
15
|
+
#include <cassert>
|
|
16
|
+
#include <functional>
|
|
17
|
+
#include <memory>
|
|
18
|
+
#include <string>
|
|
19
|
+
|
|
20
|
+
namespace facebook::react::jsinspector_modern {
|
|
21
|
+
|
|
22
|
+
class ConsoleTaskOrchestrator;
|
|
23
|
+
class RuntimeTargetDelegate;
|
|
24
|
+
|
|
25
|
+
class ConsoleTaskId {
|
|
26
|
+
public:
|
|
27
|
+
ConsoleTaskId() = default;
|
|
28
|
+
~ConsoleTaskId() = default;
|
|
29
|
+
|
|
30
|
+
ConsoleTaskId(const ConsoleTaskId &) = default;
|
|
31
|
+
ConsoleTaskId &operator=(const ConsoleTaskId &) = default;
|
|
32
|
+
|
|
33
|
+
ConsoleTaskId(ConsoleTaskId &&) = default;
|
|
34
|
+
ConsoleTaskId &operator=(ConsoleTaskId &&) = default;
|
|
35
|
+
|
|
36
|
+
bool operator==(const ConsoleTaskId &) const = default;
|
|
37
|
+
inline operator bool() const
|
|
38
|
+
{
|
|
39
|
+
return (bool)id_;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
explicit inline operator void *() const
|
|
43
|
+
{
|
|
44
|
+
return id_;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private:
|
|
48
|
+
explicit inline ConsoleTaskId(void *id) : id_(id)
|
|
49
|
+
{
|
|
50
|
+
assert(id_ != nullptr);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void *id_{nullptr};
|
|
54
|
+
|
|
55
|
+
friend class ConsoleTaskContext;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
class ConsoleTaskContext : public std::enable_shared_from_this<ConsoleTaskContext> {
|
|
59
|
+
public:
|
|
60
|
+
ConsoleTaskContext(jsi::Runtime &runtime, RuntimeTargetDelegate &runtimeTargetDelegate, std::string name);
|
|
61
|
+
~ConsoleTaskContext();
|
|
62
|
+
|
|
63
|
+
// Can't be moved or copied: the address of `ConsoleTaskContext` is used to
|
|
64
|
+
// identify this task and all corresponding invocations.
|
|
65
|
+
ConsoleTaskContext(const ConsoleTaskContext &) = delete;
|
|
66
|
+
ConsoleTaskContext &operator=(const ConsoleTaskContext &) = delete;
|
|
67
|
+
|
|
68
|
+
ConsoleTaskContext(ConsoleTaskContext &&) = delete;
|
|
69
|
+
ConsoleTaskContext &operator=(ConsoleTaskContext &&) = delete;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Unique identifier that is calculated based on the address of
|
|
73
|
+
* ConsoleTaskContext.
|
|
74
|
+
*/
|
|
75
|
+
ConsoleTaskId id() const;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Returns the serialized stack trace that was captured during the allocation
|
|
79
|
+
* of ConsoleTaskContext.
|
|
80
|
+
*/
|
|
81
|
+
std::optional<folly::dynamic> getSerializedStackTrace() const;
|
|
82
|
+
|
|
83
|
+
void schedule();
|
|
84
|
+
|
|
85
|
+
private:
|
|
86
|
+
RuntimeTargetDelegate &runtimeTargetDelegate_;
|
|
87
|
+
std::string name_;
|
|
88
|
+
ConsoleTaskOrchestrator &orchestrator_;
|
|
89
|
+
std::unique_ptr<StackTrace> stackTrace_;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
} // namespace facebook::react::jsinspector_modern
|
|
93
|
+
|
|
94
|
+
namespace std {
|
|
95
|
+
template <>
|
|
96
|
+
struct hash<facebook::react::jsinspector_modern::ConsoleTaskId> {
|
|
97
|
+
size_t operator()(const facebook::react::jsinspector_modern::ConsoleTaskId &id) const
|
|
98
|
+
{
|
|
99
|
+
return std::hash<void *>{}(static_cast<void *>(id));
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
} // namespace std
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include "ConsoleTaskOrchestrator.h"
|
|
9
|
+
|
|
10
|
+
namespace facebook::react::jsinspector_modern {
|
|
11
|
+
|
|
12
|
+
/* static */ ConsoleTaskOrchestrator& ConsoleTaskOrchestrator::getInstance() {
|
|
13
|
+
static ConsoleTaskOrchestrator instance;
|
|
14
|
+
return instance;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
void ConsoleTaskOrchestrator::scheduleTask(
|
|
18
|
+
ConsoleTaskId taskId,
|
|
19
|
+
std::weak_ptr<ConsoleTaskContext> taskContext) {
|
|
20
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
|
21
|
+
tasks_.emplace(taskId, taskContext);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
void ConsoleTaskOrchestrator::cancelTask(ConsoleTaskId id) {
|
|
25
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
|
26
|
+
tasks_.erase(id);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
void ConsoleTaskOrchestrator::startTask(ConsoleTaskId id) {
|
|
30
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
|
31
|
+
stack_.push(id);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
void ConsoleTaskOrchestrator::finishTask(ConsoleTaskId id) {
|
|
35
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
|
36
|
+
assert(stack_.top() == id);
|
|
37
|
+
|
|
38
|
+
stack_.pop();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
std::shared_ptr<ConsoleTaskContext> ConsoleTaskOrchestrator::top() const {
|
|
42
|
+
std::lock_guard<std::mutex> lock(mutex_);
|
|
43
|
+
if (stack_.empty()) {
|
|
44
|
+
return nullptr;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
auto it = tasks_.find(stack_.top());
|
|
48
|
+
if (it == tasks_.end()) {
|
|
49
|
+
return nullptr;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return it->second.lock();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
} // namespace facebook::react::jsinspector_modern
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <memory>
|
|
11
|
+
#include <mutex>
|
|
12
|
+
#include <stack>
|
|
13
|
+
|
|
14
|
+
#include "ConsoleTaskContext.h"
|
|
15
|
+
|
|
16
|
+
namespace facebook::react::jsinspector_modern {
|
|
17
|
+
|
|
18
|
+
class ConsoleTaskOrchestrator {
|
|
19
|
+
public:
|
|
20
|
+
static ConsoleTaskOrchestrator &getInstance();
|
|
21
|
+
|
|
22
|
+
~ConsoleTaskOrchestrator() = default;
|
|
23
|
+
|
|
24
|
+
ConsoleTaskOrchestrator(const ConsoleTaskOrchestrator &) = delete;
|
|
25
|
+
ConsoleTaskOrchestrator &operator=(const ConsoleTaskOrchestrator &) = delete;
|
|
26
|
+
|
|
27
|
+
ConsoleTaskOrchestrator(ConsoleTaskOrchestrator &&) = delete;
|
|
28
|
+
ConsoleTaskOrchestrator &operator=(ConsoleTaskOrchestrator &&) = delete;
|
|
29
|
+
|
|
30
|
+
void scheduleTask(ConsoleTaskId taskId, std::weak_ptr<ConsoleTaskContext> taskContext);
|
|
31
|
+
void cancelTask(ConsoleTaskId taskId);
|
|
32
|
+
|
|
33
|
+
void startTask(ConsoleTaskId taskId);
|
|
34
|
+
void finishTask(ConsoleTaskId taskId);
|
|
35
|
+
std::shared_ptr<ConsoleTaskContext> top() const;
|
|
36
|
+
|
|
37
|
+
private:
|
|
38
|
+
ConsoleTaskOrchestrator() = default;
|
|
39
|
+
|
|
40
|
+
std::stack<ConsoleTaskId> stack_;
|
|
41
|
+
std::unordered_map<ConsoleTaskId, std::weak_ptr<ConsoleTaskContext>> tasks_;
|
|
42
|
+
/**
|
|
43
|
+
* Protects the stack_ and tasks_ members.
|
|
44
|
+
*/
|
|
45
|
+
mutable std::mutex mutex_;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
} // namespace facebook::react::jsinspector_modern
|
|
@@ -17,8 +17,10 @@
|
|
|
17
17
|
#include "WeakList.h"
|
|
18
18
|
|
|
19
19
|
#include <optional>
|
|
20
|
+
#include <set>
|
|
20
21
|
#include <string>
|
|
21
22
|
|
|
23
|
+
#include <jsinspector-modern/tracing/TracingCategory.h>
|
|
22
24
|
#include <jsinspector-modern/tracing/TracingMode.h>
|
|
23
25
|
#include <jsinspector-modern/tracing/TracingState.h>
|
|
24
26
|
|
|
@@ -203,9 +205,11 @@ class HostTargetController final {
|
|
|
203
205
|
* Starts trace recording for this HostTarget.
|
|
204
206
|
*
|
|
205
207
|
* \param mode In which mode to start the trace recording.
|
|
208
|
+
* \param enabledCategories The set of categories to enable.
|
|
209
|
+
*
|
|
206
210
|
* \return false if already tracing, true otherwise.
|
|
207
211
|
*/
|
|
208
|
-
bool startTracing(tracing::Mode mode);
|
|
212
|
+
bool startTracing(tracing::Mode mode, std::set<tracing::Category> enabledCategories);
|
|
209
213
|
|
|
210
214
|
/**
|
|
211
215
|
* Stops previously started trace recording.
|
|
@@ -292,9 +296,11 @@ class JSINSPECTOR_EXPORT HostTarget : public EnableExecutorFromThis<HostTarget>
|
|
|
292
296
|
* Starts trace recording for this HostTarget.
|
|
293
297
|
*
|
|
294
298
|
* \param mode In which mode to start the trace recording.
|
|
299
|
+
* \param enabledCategories The set of categories to enable.
|
|
300
|
+
*
|
|
295
301
|
* \return false if already tracing, true otherwise.
|
|
296
302
|
*/
|
|
297
|
-
bool startTracing(tracing::Mode mode);
|
|
303
|
+
bool startTracing(tracing::Mode mode, std::set<tracing::Category> enabledCategories);
|
|
298
304
|
|
|
299
305
|
/**
|
|
300
306
|
* Stops previously started trace recording.
|
|
@@ -11,9 +11,12 @@
|
|
|
11
11
|
namespace facebook::react::jsinspector_modern {
|
|
12
12
|
|
|
13
13
|
HostTargetTraceRecording::HostTargetTraceRecording(
|
|
14
|
+
HostTarget& hostTarget,
|
|
14
15
|
tracing::Mode tracingMode,
|
|
15
|
-
|
|
16
|
-
:
|
|
16
|
+
std::set<tracing::Category> enabledCategories)
|
|
17
|
+
: hostTarget_(hostTarget),
|
|
18
|
+
tracingMode_(tracingMode),
|
|
19
|
+
enabledCategories_(std::move(enabledCategories)) {}
|
|
17
20
|
|
|
18
21
|
void HostTargetTraceRecording::setTracedInstance(
|
|
19
22
|
InstanceTarget* instanceTarget) {
|
|
@@ -32,6 +35,7 @@ void HostTargetTraceRecording::start() {
|
|
|
32
35
|
state_ = tracing::TraceRecordingState{
|
|
33
36
|
.mode = tracingMode_,
|
|
34
37
|
.startTime = HighResTimeStamp::now(),
|
|
38
|
+
.enabledCategories = enabledCategories_,
|
|
35
39
|
};
|
|
36
40
|
hostTracingAgent_ = hostTarget_.createTracingAgent(*state_);
|
|
37
41
|
}
|
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
#include "InstanceTarget.h"
|
|
13
13
|
|
|
14
14
|
#include <jsinspector-modern/tracing/TraceRecordingState.h>
|
|
15
|
+
#include <jsinspector-modern/tracing/TracingCategory.h>
|
|
15
16
|
|
|
16
17
|
#include <optional>
|
|
18
|
+
#include <set>
|
|
17
19
|
|
|
18
20
|
namespace facebook::react::jsinspector_modern {
|
|
19
21
|
|
|
@@ -28,7 +30,10 @@ namespace facebook::react::jsinspector_modern {
|
|
|
28
30
|
*/
|
|
29
31
|
class HostTargetTraceRecording {
|
|
30
32
|
public:
|
|
31
|
-
explicit HostTargetTraceRecording(
|
|
33
|
+
explicit HostTargetTraceRecording(
|
|
34
|
+
HostTarget &hostTarget,
|
|
35
|
+
tracing::Mode tracingMode,
|
|
36
|
+
std::set<tracing::Category> enabledCategories);
|
|
32
37
|
|
|
33
38
|
inline bool isBackgroundInitiated() const
|
|
34
39
|
{
|
|
@@ -61,14 +66,14 @@ class HostTargetTraceRecording {
|
|
|
61
66
|
|
|
62
67
|
private:
|
|
63
68
|
/**
|
|
64
|
-
* The
|
|
69
|
+
* The Host for which this Trace Recording is going to happen.
|
|
65
70
|
*/
|
|
66
|
-
|
|
71
|
+
HostTarget &hostTarget_;
|
|
67
72
|
|
|
68
73
|
/**
|
|
69
|
-
* The
|
|
74
|
+
* The mode in which this trace recording was initialized.
|
|
70
75
|
*/
|
|
71
|
-
|
|
76
|
+
tracing::Mode tracingMode_;
|
|
72
77
|
|
|
73
78
|
/**
|
|
74
79
|
* The state of the current Trace Recording.
|
|
@@ -81,6 +86,11 @@ class HostTargetTraceRecording {
|
|
|
81
86
|
* Only allocated if the recording is enabled.
|
|
82
87
|
*/
|
|
83
88
|
std::shared_ptr<HostTracingAgent> hostTracingAgent_;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The list of categories that are enabled for this recording.
|
|
92
|
+
*/
|
|
93
|
+
std::set<tracing::Category> enabledCategories_;
|
|
84
94
|
};
|
|
85
95
|
|
|
86
96
|
} // namespace facebook::react::jsinspector_modern
|
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
namespace facebook::react::jsinspector_modern {
|
|
14
14
|
|
|
15
|
-
bool HostTargetController::startTracing(
|
|
16
|
-
|
|
15
|
+
bool HostTargetController::startTracing(
|
|
16
|
+
tracing::Mode tracingMode,
|
|
17
|
+
std::set<tracing::Category> enabledCategories) {
|
|
18
|
+
return target_.startTracing(tracingMode, std::move(enabledCategories));
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
tracing::TraceRecordingState HostTargetController::stopTracing() {
|
|
@@ -27,7 +29,9 @@ std::shared_ptr<HostTracingAgent> HostTarget::createTracingAgent(
|
|
|
27
29
|
return agent;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
bool HostTarget::startTracing(
|
|
32
|
+
bool HostTarget::startTracing(
|
|
33
|
+
tracing::Mode tracingMode,
|
|
34
|
+
std::set<tracing::Category> enabledCategories) {
|
|
31
35
|
if (traceRecording_ != nullptr) {
|
|
32
36
|
if (traceRecording_->isBackgroundInitiated() &&
|
|
33
37
|
tracingMode == tracing::Mode::CDP) {
|
|
@@ -37,8 +41,8 @@ bool HostTarget::startTracing(tracing::Mode tracingMode) {
|
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
traceRecording_ =
|
|
41
|
-
std::
|
|
44
|
+
traceRecording_ = std::make_unique<HostTargetTraceRecording>(
|
|
45
|
+
*this, tracingMode, std::move(enabledCategories));
|
|
42
46
|
traceRecording_->setTracedInstance(currentInstance_.get());
|
|
43
47
|
traceRecording_->start();
|
|
44
48
|
|
|
@@ -152,13 +152,14 @@ RuntimeTracingAgent::RuntimeTracingAgent(
|
|
|
152
152
|
tracing::TraceRecordingState& state,
|
|
153
153
|
RuntimeTargetController& targetController)
|
|
154
154
|
: tracing::TargetTracingAgent(state), targetController_(targetController) {
|
|
155
|
-
if (state.
|
|
155
|
+
if (state.enabledCategories.contains(tracing::Category::JavaScriptSampling)) {
|
|
156
156
|
targetController_.enableSamplingProfiler();
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
RuntimeTracingAgent::~RuntimeTracingAgent() {
|
|
161
|
-
if (state_.
|
|
161
|
+
if (state_.enabledCategories.contains(
|
|
162
|
+
tracing::Category::JavaScriptSampling)) {
|
|
162
163
|
targetController_.disableSamplingProfiler();
|
|
163
164
|
auto profile = targetController_.collectSamplingProfile();
|
|
164
165
|
|
|
@@ -99,7 +99,7 @@ class RuntimeAgent final {
|
|
|
99
99
|
* Lifetime of this agent is bound to the lifetime of the Tracing session -
|
|
100
100
|
* HostTargetTraceRecording and to the lifetime of the RuntimeTarget.
|
|
101
101
|
*/
|
|
102
|
-
class RuntimeTracingAgent : tracing::TargetTracingAgent {
|
|
102
|
+
class RuntimeTracingAgent : public tracing::TargetTracingAgent {
|
|
103
103
|
public:
|
|
104
104
|
explicit RuntimeTracingAgent(tracing::TraceRecordingState &state, RuntimeTargetController &targetController);
|
|
105
105
|
|
|
@@ -248,6 +248,18 @@ bool RuntimeTarget::isDomainEnabled(Domain domain) const {
|
|
|
248
248
|
return threadSafeDomainStatus_[domain];
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
bool RuntimeTarget::isConsoleCreateTaskEnabled() const {
|
|
252
|
+
if (isDomainEnabled(Domain::Runtime)) {
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (auto tracingAgent = tracingAgent_.lock()) {
|
|
257
|
+
return tracingAgent->isRunningInBackgroundMode();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
|
|
251
263
|
RuntimeTargetController::RuntimeTargetController(RuntimeTarget& target)
|
|
252
264
|
: target_(target) {}
|
|
253
265
|
|
|
@@ -207,19 +207,6 @@ class JSINSPECTOR_EXPORT RuntimeTarget : public EnableExecutorFromThis<RuntimeTa
|
|
|
207
207
|
*/
|
|
208
208
|
std::shared_ptr<RuntimeTracingAgent> createTracingAgent(tracing::TraceRecordingState &state);
|
|
209
209
|
|
|
210
|
-
/**
|
|
211
|
-
* Start sampling profiler for a particular JavaScript runtime.
|
|
212
|
-
*/
|
|
213
|
-
void enableSamplingProfiler();
|
|
214
|
-
/**
|
|
215
|
-
* Stop sampling profiler for a particular JavaScript runtime.
|
|
216
|
-
*/
|
|
217
|
-
void disableSamplingProfiler();
|
|
218
|
-
/**
|
|
219
|
-
* Return recorded sampling profile for the previous sampling session.
|
|
220
|
-
*/
|
|
221
|
-
tracing::RuntimeSamplingProfile collectSamplingProfile();
|
|
222
|
-
|
|
223
210
|
private:
|
|
224
211
|
using Domain = RuntimeTargetController::Domain;
|
|
225
212
|
|
|
@@ -275,6 +262,18 @@ class JSINSPECTOR_EXPORT RuntimeTarget : public EnableExecutorFromThis<RuntimeTa
|
|
|
275
262
|
* session - HostTargetTraceRecording.
|
|
276
263
|
*/
|
|
277
264
|
std::weak_ptr<RuntimeTracingAgent> tracingAgent_;
|
|
265
|
+
/**
|
|
266
|
+
* Start sampling profiler for a particular JavaScript runtime.
|
|
267
|
+
*/
|
|
268
|
+
void enableSamplingProfiler();
|
|
269
|
+
/**
|
|
270
|
+
* Stop sampling profiler for a particular JavaScript runtime.
|
|
271
|
+
*/
|
|
272
|
+
void disableSamplingProfiler();
|
|
273
|
+
/**
|
|
274
|
+
* Return recorded sampling profile for the previous sampling session.
|
|
275
|
+
*/
|
|
276
|
+
tracing::RuntimeSamplingProfile collectSamplingProfile();
|
|
278
277
|
|
|
279
278
|
/**
|
|
280
279
|
* Adds a function with the given name on the runtime's global object, that
|
|
@@ -293,6 +292,10 @@ class JSINSPECTOR_EXPORT RuntimeTarget : public EnableExecutorFromThis<RuntimeTa
|
|
|
293
292
|
* Install the console API handler.
|
|
294
293
|
*/
|
|
295
294
|
void installConsoleHandler();
|
|
295
|
+
/**
|
|
296
|
+
* Returns whether console.createTask should actually capture stack traces.
|
|
297
|
+
*/
|
|
298
|
+
bool isConsoleCreateTaskEnabled() const;
|
|
296
299
|
|
|
297
300
|
/**
|
|
298
301
|
* Installs __DEBUGGER_SESSION_OBSERVER__ object on the JavaScript's global
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
#include "ConsoleTask.h"
|
|
9
|
+
#include "ConsoleTaskContext.h"
|
|
10
|
+
#include "ConsoleTaskOrchestrator.h"
|
|
11
|
+
|
|
8
12
|
#include <jsinspector-modern/RuntimeTarget.h>
|
|
9
13
|
#include <jsinspector-modern/tracing/PerformanceTracer.h>
|
|
10
14
|
|
|
@@ -477,8 +481,17 @@ void consoleTimeStamp(
|
|
|
477
481
|
}
|
|
478
482
|
|
|
479
483
|
if (performanceTracer.isTracing()) {
|
|
484
|
+
auto taskContext = ConsoleTaskOrchestrator::getInstance().top();
|
|
485
|
+
|
|
480
486
|
performanceTracer.reportTimeStamp(
|
|
481
|
-
label,
|
|
487
|
+
label,
|
|
488
|
+
start,
|
|
489
|
+
end,
|
|
490
|
+
trackName,
|
|
491
|
+
trackGroup,
|
|
492
|
+
color,
|
|
493
|
+
std::move(detail),
|
|
494
|
+
taskContext ? taskContext->getSerializedStackTrace() : nullptr);
|
|
482
495
|
}
|
|
483
496
|
|
|
484
497
|
if (ReactPerfettoLogger::isTracing()) {
|
|
@@ -521,6 +534,71 @@ void installConsoleTimeStamp(
|
|
|
521
534
|
})));
|
|
522
535
|
}
|
|
523
536
|
|
|
537
|
+
/**
|
|
538
|
+
* run method of the task object returned from console.createTask().
|
|
539
|
+
*/
|
|
540
|
+
jsi::Value consoleTaskRun(
|
|
541
|
+
jsi::Runtime& runtime,
|
|
542
|
+
const jsi::Value* args,
|
|
543
|
+
size_t count,
|
|
544
|
+
std::shared_ptr<ConsoleTaskContext> taskContext) {
|
|
545
|
+
if (count < 1 || !args[0].isObject()) {
|
|
546
|
+
throw JSError(runtime, "First argument must be a function");
|
|
547
|
+
}
|
|
548
|
+
auto fnObj = args[0].getObject(runtime);
|
|
549
|
+
if (!fnObj.isFunction(runtime)) {
|
|
550
|
+
throw JSError(runtime, "First argument must be a function");
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
ConsoleTask consoleTask{taskContext};
|
|
554
|
+
|
|
555
|
+
auto fn = fnObj.getFunction(runtime);
|
|
556
|
+
return fn.call(runtime);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* console.createTask. Non-standardized.
|
|
561
|
+
* https://developer.chrome.com/docs/devtools/console/api#createtask
|
|
562
|
+
*/
|
|
563
|
+
jsi::Value consoleCreateTask(
|
|
564
|
+
jsi::Runtime& runtime,
|
|
565
|
+
const jsi::Value* args,
|
|
566
|
+
size_t count,
|
|
567
|
+
RuntimeTargetDelegate& runtimeTargetDelegate,
|
|
568
|
+
bool enabled) {
|
|
569
|
+
if (count < 1 || !args[0].isString()) {
|
|
570
|
+
throw JSError(runtime, "First argument must be a non-empty string");
|
|
571
|
+
}
|
|
572
|
+
auto name = args[0].asString(runtime).utf8(runtime);
|
|
573
|
+
if (name.empty()) {
|
|
574
|
+
throw JSError(runtime, "First argument must be a non-empty string");
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
jsi::Object task{runtime};
|
|
578
|
+
std::shared_ptr<ConsoleTaskContext> taskContext = nullptr;
|
|
579
|
+
if (enabled) {
|
|
580
|
+
taskContext = std::make_shared<ConsoleTaskContext>(
|
|
581
|
+
runtime, runtimeTargetDelegate, name);
|
|
582
|
+
taskContext->schedule();
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
task.setProperty(
|
|
586
|
+
runtime,
|
|
587
|
+
"run",
|
|
588
|
+
jsi::Function::createFromHostFunction(
|
|
589
|
+
runtime,
|
|
590
|
+
jsi::PropNameID::forAscii(runtime, "run"),
|
|
591
|
+
0,
|
|
592
|
+
[taskContext](
|
|
593
|
+
jsi::Runtime& runtime,
|
|
594
|
+
const jsi::Value& /*thisVal*/,
|
|
595
|
+
const jsi::Value* args,
|
|
596
|
+
size_t count) {
|
|
597
|
+
return consoleTaskRun(runtime, args, count, taskContext);
|
|
598
|
+
}));
|
|
599
|
+
return task;
|
|
600
|
+
}
|
|
601
|
+
|
|
524
602
|
} // namespace
|
|
525
603
|
|
|
526
604
|
void RuntimeTarget::installConsoleHandler() {
|
|
@@ -624,6 +702,33 @@ void RuntimeTarget::installConsoleHandler() {
|
|
|
624
702
|
*/
|
|
625
703
|
installConsoleTimeStamp(runtime, originalConsole, console);
|
|
626
704
|
|
|
705
|
+
/**
|
|
706
|
+
* console.createTask
|
|
707
|
+
*/
|
|
708
|
+
console.setProperty(
|
|
709
|
+
runtime,
|
|
710
|
+
"createTask",
|
|
711
|
+
jsi::Function::createFromHostFunction(
|
|
712
|
+
runtime,
|
|
713
|
+
jsi::PropNameID::forAscii(runtime, "createTask"),
|
|
714
|
+
0,
|
|
715
|
+
[state, selfWeak](
|
|
716
|
+
jsi::Runtime& runtime,
|
|
717
|
+
const jsi::Value& /*thisVal*/,
|
|
718
|
+
const jsi::Value* args,
|
|
719
|
+
size_t count) {
|
|
720
|
+
jsi::Value task;
|
|
721
|
+
tryExecuteSync(selfWeak, [&](auto& self) {
|
|
722
|
+
task = consoleCreateTask(
|
|
723
|
+
runtime,
|
|
724
|
+
args,
|
|
725
|
+
count,
|
|
726
|
+
self.delegate_,
|
|
727
|
+
self.isConsoleCreateTaskEnabled());
|
|
728
|
+
});
|
|
729
|
+
return task;
|
|
730
|
+
}));
|
|
731
|
+
|
|
627
732
|
// Install forwarding console methods.
|
|
628
733
|
#define FORWARDING_CONSOLE_METHOD(name, type) \
|
|
629
734
|
installConsoleMethod(#name, console_##name);
|
|
@@ -59,8 +59,25 @@ bool TracingAgent::handleRequest(const cdp::PreparsedRequest& req) {
|
|
|
59
59
|
return true;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
/**
|
|
63
|
+
* This logic has to be updated with the next upgrade of Chrome
|
|
64
|
+
* DevTools Frotnend fork.
|
|
65
|
+
*
|
|
66
|
+
* At the moment of writing this, our fork uses categories field, which is
|
|
67
|
+
* marked as depreacted in CDP spec.
|
|
68
|
+
*
|
|
69
|
+
* Latest versions of Chrome DevTools in stable channel of Chromium are
|
|
70
|
+
* already using traceConfig field.
|
|
71
|
+
*/
|
|
72
|
+
std::set<tracing::Category> enabledCategories;
|
|
73
|
+
if (req.params.isObject() && req.params.count("categories") != 0 &&
|
|
74
|
+
req.params["categories"].isString()) {
|
|
75
|
+
enabledCategories = tracing::parseSerializedTracingCategories(
|
|
76
|
+
req.params["categories"].getString());
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
bool didNotHaveAlreadyRunningRecording = hostTargetController_.startTracing(
|
|
80
|
+
tracing::Mode::CDP, std::move(enabledCategories));
|
|
64
81
|
if (!didNotHaveAlreadyRunningRecording) {
|
|
65
82
|
frontendChannel_(
|
|
66
83
|
cdp::jsonError(
|