Skip to content

Commit d72acd8

Browse files
committed
Wire up Fusebox InspectorPackagerConnection
Using the same inspector thread initialized in ReactNativeHost, this change wires up the InspectorPackagerConnectionDelegate to use when initializatng the InspectorPackagerConnection from ReactCommon and conditionally sets it for Hermes direct debugging when the appropriate feature flag is set.
1 parent fe37841 commit d72acd8

File tree

5 files changed

+37
-11
lines changed

5 files changed

+37
-11
lines changed

vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,10 @@ void ReactInstanceWin::InitializeBridgeless() noexcept {
619619

620620
if (devSettings->useDirectDebugger) {
621621
::Microsoft::ReactNative::GetSharedDevManager()->EnsureHermesInspector(
622-
devSettings->sourceBundleHost, devSettings->sourceBundlePort, DebugBundlePath());
622+
devSettings->sourceBundleHost,
623+
devSettings->sourceBundlePort,
624+
DebugBundlePath(),
625+
m_options.HostTargetSettings.InspectorThread);
623626
}
624627

625628
m_jsiRuntimeHolder = std::make_shared<Microsoft::ReactNative::HermesRuntimeHolder>(

vnext/Shared/DevSupportManager.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
#include <Shared/DevSettings.h>
1010

1111
#include <Executors/WebSocketJSExecutor.h>
12+
#include "FuseboxInspectorPackagerConnectionDelegate.h"
1213
#include "PackagerConnection.h"
1314

1415
#include "Unicode.h"
1516
#include "Utilities.h"
1617

1718
#include <Utils/CppWinrtLessExceptions.h>
19+
#include <jsinspector-modern/InspectorFlags.h>
1820
#include <winrt/Windows.Foundation.h>
1921
#include <winrt/Windows.Security.Cryptography.Core.h>
2022
#include <winrt/Windows.Security.Cryptography.h>
@@ -257,9 +259,10 @@ void DevSupportManager::StopPollingLiveReload() {
257259
void DevSupportManager::EnsureHermesInspector(
258260
[[maybe_unused]] const std::string &packagerHost,
259261
[[maybe_unused]] const uint16_t packagerPort,
260-
[[maybe_unused]] const std::string &jsBundleName) noexcept {
262+
[[maybe_unused]] const std::string &jsBundleName,
263+
[[maybe_unused]] const std::shared_ptr<Mso::DispatchQueue> &inspectorThread) noexcept {
261264
static std::once_flag once;
262-
std::call_once(once, [this, &packagerHost, packagerPort, &jsBundleName]() {
265+
std::call_once(once, [this, &packagerHost, packagerPort, &jsBundleName, &inspectorThread]() {
263266
// TODO: should we use the bundleAppId as the app param if available?
264267
std::string packageName("RNW");
265268
wchar_t fullName[PACKAGE_FULL_NAME_MAX_LENGTH]{};
@@ -276,11 +279,22 @@ void DevSupportManager::EnsureHermesInspector(
276279
}
277280

278281
const auto deviceId = GetDeviceId(jsBundleName);
279-
m_inspectorPackagerConnection = std::make_shared<InspectorPackagerConnection>(
280-
facebook::react::DevServerHelper::get_InspectorDeviceUrl(
281-
packagerHost, packagerPort, deviceName, packageName, deviceId),
282-
m_BundleStatusProvider);
283-
m_inspectorPackagerConnection->connectAsync();
282+
auto inspectorUrl = facebook::react::DevServerHelper::get_InspectorDeviceUrl(
283+
packagerHost, packagerPort, deviceName, packageName, deviceId);
284+
auto &inspectorFlags = jsinspector_modern::InspectorFlags::getInstance();
285+
if (inspectorFlags.getEnableCxxInspectorPackagerConnection()) {
286+
m_fuseboxInspectorPackagerConnection = std::make_unique<jsinspector_modern::InspectorPackagerConnection>(
287+
inspectorUrl,
288+
std::string{jsBundleName},
289+
std::make_unique<Microsoft::ReactNative::FuseboxInspectorPackagerConnectionDelegate>(inspectorThread));
290+
m_fuseboxInspectorPackagerConnection->connect();
291+
} else {
292+
m_inspectorPackagerConnection = std::make_shared<InspectorPackagerConnection>(
293+
facebook::react::DevServerHelper::get_InspectorDeviceUrl(
294+
packagerHost, packagerPort, deviceName, packageName, deviceId),
295+
m_BundleStatusProvider);
296+
m_inspectorPackagerConnection->connectAsync();
297+
}
284298
});
285299
}
286300

vnext/Shared/DevSupportManager.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <string>
1616

1717
#include <InspectorPackagerConnection.h>
18+
#include <jsinspector-modern/InspectorPackagerConnection.h>
1819

1920
namespace facebook {
2021
namespace react {
@@ -52,13 +53,15 @@ class DevSupportManager final : public facebook::react::IDevSupportManager {
5253
virtual void EnsureHermesInspector(
5354
const std::string &packagerHost,
5455
const uint16_t packagerPort,
55-
const std::string &jsBundleName) noexcept override;
56+
const std::string &jsBundleName,
57+
const std::shared_ptr<Mso::DispatchQueue> &inspectorThread) noexcept override;
5658
virtual void UpdateBundleStatus(bool isLastDownloadSuccess, int64_t updateTimestamp) noexcept override;
5759

5860
private:
5961
std::atomic_bool m_cancellation_token;
6062

6163
std::shared_ptr<InspectorPackagerConnection> m_inspectorPackagerConnection;
64+
std::unique_ptr<facebook::react::jsinspector_modern::InspectorPackagerConnection> m_fuseboxInspectorPackagerConnection;
6265

6366
struct BundleStatusProvider : public InspectorPackagerConnection::IBundleStatusProvider {
6467
virtual InspectorPackagerConnection::BundleStatus getBundleStatus() {

vnext/Shared/IDevSupportManager.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#pragma once
55

66
#include <cxxreact/JSExecutor.h>
7+
#include <dispatchQueue/dispatchQueue.h>
78
#include <functional>
89
#include <memory>
910
#include <string>
@@ -27,7 +28,8 @@ struct IDevSupportManager {
2728
virtual void EnsureHermesInspector(
2829
const std::string &packagerHost,
2930
const uint16_t packagerPort,
30-
const std::string &bundleName) noexcept = 0;
31+
const std::string &bundleName,
32+
const std::shared_ptr<Mso::DispatchQueue> &inspectorThread) noexcept = 0;
3133
virtual void UpdateBundleStatus(bool isLastDownloadSuccess, int64_t updateTimestamp) noexcept = 0;
3234
};
3335

vnext/Shared/OInstance.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ void LoadRemoteUrlScript(
121121

122122
const auto bundlePath = devSettings->debugBundlePath.empty() ? jsBundleRelativePath : devSettings->debugBundlePath;
123123
if (facebook::react::shouldStartHermesInspector(*devSettings)) {
124-
devManager->EnsureHermesInspector(devSettings->sourceBundleHost, devSettings->sourceBundlePort, bundlePath);
124+
devManager->EnsureHermesInspector(
125+
devSettings->sourceBundleHost,
126+
devSettings->sourceBundlePort,
127+
bundlePath,
128+
devSettings->hostTargetSettings.InspectorThread);
125129
}
126130

127131
auto [jsBundleString, success] = GetJavaScriptFromServer(

0 commit comments

Comments
 (0)