Skip to content

Commit 9834e7f

Browse files
hoxyqfacebook-github-bot
authored andcommitted
Scaffold implementation and lifecycle
Summary: # Changelog: [Internal] `RuntimeTarget` will have 2 new methods: - `stubConsoleCreateTask` - installs a `console.createTask` stub, so it is always available. - `installConsoleCreateTask` - installs the actual implementation, when there is a Fusebox client The implementation for these methods will be provided in a separate diff. Similarly, the lifecycle for installation / stub during the background tracing will be provided in a separate diff. Differential Revision: D85274859
1 parent de91719 commit 9834e7f

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

packages/react-native/ReactCommon/jsinspector-modern/RuntimeTarget.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ RuntimeTarget::RuntimeTarget(
5454
void RuntimeTarget::installGlobals() {
5555
// NOTE: RuntimeTarget::installConsoleHandler is in RuntimeTargetConsole.cpp
5656
installConsoleHandler();
57+
// NOTE: RuntimeTarget::stubConsoleCreateTask is in RuntimeTargetConsole.cpp
58+
stubConsoleCreateTask();
5759
// NOTE: RuntimeTarget::installDebuggerSessionObserver is in
5860
// RuntimeTargetDebuggerSessionObserver.cpp
5961
installDebuggerSessionObserver();
@@ -215,9 +217,9 @@ void RuntimeTarget::notifyDomainStateChanged(
215217
}
216218
case Domain::ReactNativeApplication: {
217219
if (domainStateChangedGlobally && enabled) {
218-
// installConsoleCreateTask();
220+
installConsoleCreateTask();
219221
} else if (domainStateChangedGlobally) {
220-
// stubConsoleCreateTask();
222+
stubConsoleCreateTask();
221223
}
222224

223225
break;

packages/react-native/ReactCommon/jsinspector-modern/RuntimeTarget.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,23 @@ class JSINSPECTOR_EXPORT RuntimeTarget
314314
*/
315315
void installConsoleHandler();
316316

317+
/*
318+
* Installs console.createTask stub, which is essentially a no-op, but follows
319+
* the semantics of actual API.
320+
*
321+
* The actual implementation is only installed when DevTools is opened or
322+
* during tracing in the background. This aligns with Chromium's
323+
* implementation.
324+
*/
325+
void stubConsoleCreateTask();
326+
327+
/*
328+
* Installs the actual console.createTask implementation. This should only
329+
* happen when DevTools is opened or during tracing in the background to avoid
330+
* paying the cost of capturing unnecessary stack traces.
331+
*/
332+
void installConsoleCreateTask();
333+
317334
/**
318335
* Installs __DEBUGGER_SESSION_OBSERVER__ object on the JavaScript's global
319336
* object, which later could be referenced from JavaScript side for

packages/react-native/ReactCommon/jsinspector-modern/RuntimeTargetConsole.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,4 +625,8 @@ void RuntimeTarget::installConsoleHandler() {
625625
});
626626
}
627627

628+
void RuntimeTarget::stubConsoleCreateTask() {}
629+
630+
void RuntimeTarget::installConsoleCreateTask() {}
631+
628632
} // namespace facebook::react::jsinspector_modern

0 commit comments

Comments
 (0)