microsoft / react-native-windows

A framework for building native Windows apps with React.
https://microsoft.github.io/react-native-windows/
Other
16.26k stars 1.14k forks source link

Can't direct debug Hermes when consuming the Microsoft.ReactNative nuget packages #11252

Open jonthysell opened 1 year ago

jonthysell commented 1 year ago

Problem Description

In order for Hermes direct debugging to work, the RNW code needs to set up the Hermes Inspector (which connects to Metro for source maps). However the code in Microsoft.ReactNative is #ifdef HERMES_ENABLE_DEBUGGER:

https://github.com/microsoft/react-native-windows/blob/8eee65d4bc2e086c7170be4ae29d6df664d5ced9/vnext/Shared/DevSupportManager.cpp#L243-L267

This compile time flag is set by the targets file for the hermes-windows nuget (when building debug or by setting a property to build in release flavor too):

https://github.com/microsoft/hermes-windows/blob/7606e2f393372b7018a734ac70c4b151ff7929e6/.ado/ReactNative.Hermes.Windows.targets#L26

However this means its only applied when building RNW from source. The RNW nuget packages are built in release flavor.

Note, this is blocked by the fact that you can't even use Hermes with the RNW nugets at all (see #11251) but even if that were fixed, there'd still be extra work to allow direct debugging since it's behind HERMES_ENABLE_DEBUGGER.

Steps To Reproduce

  1. Build a new RNW app with the experimental nugets and hermes
  2. Run the new app with direct debugging enabled

Expected Results

Able to connect a direct debugger.

CLI version

npx react-native --version

Environment

info Fetching system and libraries information...
System:
    OS: Windows 10 10.0.25300
    CPU: (24) x64 AMD Ryzen Threadripper PRO 3945WX 12-Cores
    Memory: 51.33 GB / 63.86 GB
  Binaries:
    Node: 16.15.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
    Windows SDK:
      AllowDevelopmentWithoutDevLicense: Enabled
      AllowAllTrustedApps: Enabled
      Versions: 10.0.18362.0, 10.0.19041.0, 10.0.22000.0, 10.0.22621.0
  IDEs:
    Android Studio: Not Found
    Visual Studio: 16.11.33214.272 (Visual Studio Enterprise 2019), 17.4.33213.308 (Visual Studio Enterprise 2022)
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: 0.71.0 => 0.71.0
    react-native-windows: 0.71.1 => 0.71.1
  npmGlobalPackages:
    *react-native*: Not Found

Target Platform Version

10.0.19041

Target Device(s)

Desktop

Visual Studio Version

Visual Studio 2022

Build Configuration

Debug

Snack, code example, screenshot, or link to a repository

No response

jonthysell commented 11 months ago

@vmoroz I don't see HERMES_ENABLE_DEBUGGER in the code anymore, does this issue still exist?