Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Conditionally register WebSocket Cxx module (#12218)",
"packageName": "react-native-windows",
"email": "julio.rocha@microsoft.com",
"dependentChangeType": "patch"
}
3 changes: 3 additions & 0 deletions vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ void ReactInstanceWin::Initialize() noexcept {
auto omitNetCxxPropName = ReactPropertyBagHelper::GetName(nullptr, L"OmitNetworkingCxxModules");
auto omitNetCxxPropValue = m_options.Properties.Get(omitNetCxxPropName);
devSettings->omitNetworkingCxxModules = winrt::unbox_value_or(omitNetCxxPropValue, false);
auto useWebSocketTurboModulePropName = ReactPropertyBagHelper::GetName(nullptr, L"UseWebSocketTurboModule");
auto useWebSocketTurboModulePropValue = m_options.Properties.Get(useWebSocketTurboModulePropName);
devSettings->useWebSocketTurboModule = winrt::unbox_value_or(useWebSocketTurboModulePropValue, false);
auto bundleRootPath = devSettings->bundleRootPath;
auto instanceWrapper = facebook::react::CreateReactInstance(
std::shared_ptr<facebook::react::Instance>(strongThis->m_instance.Load()),
Expand Down
3 changes: 3 additions & 0 deletions vnext/Shared/DevSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ struct DevSettings {

// Transitory. Used to indicate whether or not to load networking types in the default Cxx module registry.
bool omitNetworkingCxxModules{false};

// OC:8368383 - Memory leak under investigation.
bool useWebSocketTurboModule{false};
};

} // namespace react
Expand Down
8 changes: 6 additions & 2 deletions vnext/Shared/OInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,14 +556,18 @@ std::vector<std::unique_ptr<NativeModule>> InstanceImpl::GetDefaultNativeModules
// If this code is enabled, we will have unused module instances.
// Also, MSRN has a different property bag mechanism incompatible with this method's transitionalProps variable.
#if (defined(_MSC_VER) && !defined(WINRT))
// Applications using the Windows ABI feature should loade the networking TurboModule variants instead.
if (!m_devSettings->omitNetworkingCxxModules) {

// OC:8368383 - Memory leak under investigation.
if (!m_devSettings->useWebSocketTurboModule) {
modules.push_back(std::make_unique<CxxNativeModule>(
m_innerInstance,
Microsoft::React::GetWebSocketModuleName(),
[transitionalProps]() { return Microsoft::React::CreateWebSocketModule(transitionalProps); },
nativeQueue));
}

// Applications using the Windows ABI feature should loade the networking TurboModule variants instead.
if (!m_devSettings->omitNetworkingCxxModules) {
// Use in case the host app provides its a non-Blob-compatilbe HTTP module.
if (!Microsoft::React::GetRuntimeOptionBool("Blob.DisableModule")) {
modules.push_back(std::make_unique<CxxNativeModule>(
Expand Down