Skip to content

Support modern React Native inspector#257

Merged
vmoroz merged 1 commit into
microsoft:mainfrom
vmoroz:PR/modern-debugger-support
Nov 1, 2025
Merged

Support modern React Native inspector#257
vmoroz merged 1 commit into
microsoft:mainfrom
vmoroz:PR/modern-debugger-support

Conversation

@vmoroz

@vmoroz vmoroz commented Nov 1, 2025

Copy link
Copy Markdown
Member

This PR introduces support for the modern React Native inspector (CDP-based debugger) to the hermes-windows project. It adds a new C-based API to enable an ABI-stable implementation for the new inspector.

The PR is built on top of the code that was originally created by @iamAbhi-916.

Changes:

  • New C-based Inspector API (hermes_api.h, hermes_api.cpp)

    • A new C-API is introduced for the modern inspector. All functions are exposed through a hermes_inspector_vtable struct, which is retrieved using the new hermes_get_inspector_vtable function.
    • This API provides functionality for:
      • CDP Debugger: Creating and managing the CDP debug API instance (create_cdp_debug_api).
      • Console: Adding console messages (add_console_message). To pass console arguments from the client, this function retrieves them from a temporary property on the JavaScript global object, which is then immediately cleared.
      • CDP Agent: Creating and managing a CDP agent (create_cdp_agent), handling commands (cdp_agent_handle_command), and enabling runtime and debugger domains.
      • Sampling Profiler: Enabling (enable_sampling_profiler), disabling (disable_sampling_profiler), and collecting profiling data (collect_sampling_profile) with detailed callbacks for samples and stack frames.
    • The API uses a callback-based approach for tasks like enqueuing runtime tasks, sending messages to the frontend, and efficiently streaming sampling profiler data.
  • Debugger Client Switching (InspectorProxy.cpp)

    • To allow hermes.dll to support both the legacy and modern debugger clients, a new global variable g_isOldInspectorInitialized has been added.
    • This flag is checked in the RuntimeWrapper constructor to determine whether to initialize the legacy inspector, ensuring that only one inspector is active at a time.
  • Code Refinements

    • HermesApi.cpp: Resolved a non-standard layout warning related to the use of offsetof and applied code formatting for improved readability.
    • NodeApiJsiRuntime.cpp: Fixed a compiler issue. This change is noted to be temporary and should be moved to the node-api-jsi repository.
Microsoft Reviewers: Open in CodeFlow

@vmoroz vmoroz requested a review from a team as a code owner November 1, 2025 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants