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
8 changes: 8 additions & 0 deletions change/react-native-windows-2020-03-27-11-52-38-dd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "Fix direct debugging",
"packageName": "react-native-windows",
"email": "acoates@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-03-27T18:52:38.219Z"
}
33 changes: 17 additions & 16 deletions vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ void ReactInstanceWin::Initialize() noexcept {
devSettings->debuggerPort = m_options.DeveloperSettings.DebuggerPort;
devSettings->debuggerRuntimeName = m_options.DeveloperSettings.DebuggerRuntimeName;
devSettings->useWebDebugger = m_options.DeveloperSettings.UseWebDebugger;
devSettings->useFastRefresh = m_options.DeveloperSettings.UseFastRefresh;
// devSettings->memoryTracker = GetMemoryTracker();
devSettings->bundleRootPath =
m_options.BundleRootPath.empty() ? "ms-appx:///Bundle/" : m_options.BundleRootPath;
Expand Down Expand Up @@ -313,7 +314,22 @@ void ReactInstanceWin::LoadJSBundles() noexcept {
// The OnReactInstanceLoaded internally only accepts the first call and ignores others.
//

if (!m_options.DeveloperSettings.UseWebDebugger) {
if (m_options.DeveloperSettings.UseWebDebugger || m_options.DeveloperSettings.UseFastRefresh) {
// Getting bundle from the packager, so do everything async.
auto instanceWrapper = m_instanceWrapper.LoadWithLock();
instanceWrapper->loadBundle(Mso::Copy(m_options.Identity));

m_jsMessageThread.Load()->runOnQueue([
weakThis = Mso::WeakPtr{this},
loadCallbackGuard = Mso::MakeMoveOnCopyWrapper(LoadedCallbackGuard{*this})
]() noexcept {
if (auto strongThis = weakThis.GetStrongPtr()) {
if (strongThis->State() != ReactInstanceState::HasError) {
strongThis->OnReactInstanceLoaded(Mso::ErrorCode{});
}
}
});
} else {
m_jsMessageThread.Load()->runOnQueue([
weakThis = Mso::WeakPtr{this},
loadCallbackGuard = Mso::MakeMoveOnCopyWrapper(LoadedCallbackGuard{*this})
Expand All @@ -339,21 +355,6 @@ void ReactInstanceWin::LoadJSBundles() noexcept {
strongThis->OnReactInstanceLoaded(Mso::ErrorCode{});
}
});
} else {
// Web Debugging
auto instanceWrapper = m_instanceWrapper.LoadWithLock();
instanceWrapper->loadBundle(Mso::Copy(m_options.Identity));

m_jsMessageThread.Load()->runOnQueue([
weakThis = Mso::WeakPtr{this},
loadCallbackGuard = Mso::MakeMoveOnCopyWrapper(LoadedCallbackGuard{*this})
]() noexcept {
if (auto strongThis = weakThis.GetStrongPtr()) {
if (strongThis->State() != ReactInstanceState::HasError) {
strongThis->OnReactInstanceLoaded(Mso::ErrorCode{});
}
}
});
}
}

Expand Down
4 changes: 3 additions & 1 deletion vnext/Microsoft.ReactNative/Views/ReactRootControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ void ReactRootControl::ShowDeveloperMenu() noexcept {
winrt::auto_revoke, [this](auto const & /*sender*/, winrt::RoutedEventArgs const & /*args*/) noexcept {
DismissDeveloperMenu();
m_useWebDebugger = !m_useWebDebugger;
m_directDebugging = false; // Remote debugging is incompatible with direct debugging
ReloadHost();
});

Expand All @@ -527,11 +528,12 @@ void ReactRootControl::ShowDeveloperMenu() noexcept {
winrt::auto_revoke, [this](auto const & /*sender*/, winrt::RoutedEventArgs const & /*args*/) noexcept {
DismissDeveloperMenu();
m_directDebugging = !m_directDebugging;
m_useWebDebugger = false; // Remote debugging is incompatible with direct debugging
ReloadHost();
});

breakOnNextLineText.Text(m_breakOnNextLine ? L"Disable Break on First Line" : L"Enable Break on First Line");
m_breakOnNextLineRevoker = directDebugButton.Click(
m_breakOnNextLineRevoker = breakOnNextLineButton.Click(
winrt::auto_revoke, [this](auto const & /*sender*/, winrt::RoutedEventArgs const & /*args*/) noexcept {
DismissDeveloperMenu();
m_breakOnNextLine = !m_breakOnNextLine;
Expand Down
2 changes: 2 additions & 0 deletions vnext/ReactWindowsCore/DevSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ struct DevSettings {
/// is loaded.
bool useWebDebugger{false};

bool useFastRefresh{false};

// Enables ChakraCore console redirection to debugger
bool debuggerConsoleRedirection{false};

Expand Down
2 changes: 1 addition & 1 deletion vnext/Shared/OInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ void InstanceImpl::loadBundleInternal(std::string &&jsBundleRelativePath, bool s
m_devSettings->errorCallback(e.what());
return;
}
} else if (m_devSettings->liveReloadCallback != nullptr) {
} else if (m_devSettings->liveReloadCallback != nullptr || m_devSettings->useFastRefresh) {
auto jsBundleString = m_devManager->GetJavaScriptFromServer(
m_devSettings->debugHost, jsBundleRelativePath, m_devSettings->platformName);

Expand Down