Aperture UI
Content development

DevTools

The Chrome DevTools Protocol server in Aperture UI. What it lets you inspect and change, how a host starts it, and the included Windows SDK runtime.

Aperture UI includes a server that speaks the Chrome DevTools Protocol (CDP). A host starts it, points it at a view, and Chrome's DevTools can then attach to that view the way they attach to a page in a browser. Debugging covers the day-to-day workflow around it: logging, AperturePlayer and the common scenarios.

Included in the Windows SDK

The 26.08.0.1 Windows SDK includes a working CDP server in apertureuideveloperengine.dll, its network dependencies, and the Chrome DevTools frontend. Your host starts the server, selects a view, and calls DevToolsHost::Tick() on the main thread. Including the DLL does not open a port automatically. Custom PartialCore source builds can still select the stub network configuration; use NS_APUI_BUILD_UNREAL_SDK=ON for the network-enabled SDK configuration.

What it offers

Chrome's DevTools front end talks to the server over a WebSocket. The server answers these areas of the protocol.

AreaWhat you can do
DOMBrowse the element tree, read and edit attributes, edit an element's HTML, remove a node, query by selector, see the box model. Selecting a node highlights it over the page.
CSSSee the rules that match an element and its computed style. Edit an element's inline style, or replace the text of a stylesheet.
JavaScriptRun expressions in the page, set breakpoints, step, pause on exceptions, and take CPU and heap profiles. V8's own inspector backs the Runtime, Debugger, Profiler and HeapProfiler areas, so these behave as they do in Chrome.
Console and logsPage console output, and messages the host pushes with PushConsoleMessage.
NetworkRequests for scripts, stylesheets, images and SVG that the engine makes through your network provider, with their timing and response bodies. Files read through your file system, and requests from fetch() and XMLHttpRequest, are not listed.
PerformanceA trace with Layout, RecalcStyles, Paint, script and event timeline events, plus a metrics gauge. See Rendering.
AnimationsList the CSS animations as they start, with their targets and timing. The pause, speed and scrub controls do nothing in the provider that DevToolsHost uses.
LayersThe composited layers the painter created, which are the off-screen targets described in Rendering.
AccessibilityThe accessibility tree
EmulationOverride the viewport size
InputDispatch mouse and key events into the view

The server also answers commands of its own, under an Aperture domain: Aperture.reload (reload the document, or only the stylesheets) and Aperture.runLighthouse (run the engine's performance, accessibility and best-practice audits and return a report).

Accepted and ignored

Some commands are accepted but do nothing in the provider that DevToolsHost uses, so a panel control may appear to work and change nothing. APPlayer, in the engine source tree, has a provider of its own that implements more of them, such as animation scrubbing.

  • Forcing :hover, :focus or another pseudo-state from the Styles pane.
  • Adding a rule, or editing a rule's selector or media query. Replace the stylesheet text instead.
  • CSS rule-usage coverage.
  • Click-to-inspect mode and the frame-rate meter overlay.
  • Animation pause, speed and scrub controls, emulated media, touch input and CPU throttling.
  • Network throttling and header or user-agent overrides.
  • The flow recorder and its replay.
  • The Application panel's storage view. It is not connected to the page's localStorage.

Start it from your host

aperture::developer::DevToolsHost is the facade for embedders. It needs only its own header, DeveloperEngine/DevToolsHost.h, and publishes one inspected view at a time. There is one instance per process, and Create() returns nullptr while another is alive. Every method belongs on the main thread.

#include <DeveloperEngine/DevToolsHost.h>

aperture::developer::DevToolsHost* devTools = aperture::developer::DevToolsHost::Create();
if (devTools)
{
    aperture::developer::DevToolsHostConfig config; // 127.0.0.1:9222 by default
    config.m_authToken = "pick-a-token";            // empty disables the token check
    if (devTools->Start(config))
    {
        devTools->SetInspectedView(&view);
        devTools->SetReloadCallback(
            [](void* userData, bool cssOnly) { /* reload the document or its CSS */ }, nullptr);
    }
}

// Every frame, on the main thread. Without it, most commands time out.
if (devTools)
    devTools->Tick();
  • Tick() is required. It runs the commands that a client sends on its own thread, on the main thread. Without it, every command except those V8 answers fails after a timeout.
  • SetInspectedView(view) points the server at a view, or clears it with nullptr. The page title and URL that DevTools shows are read from the view.
  • SetReloadCallback receives a request to reload, from Aperture.reload. Only the host knows what the view was loaded from, so the host reloads it, and cssOnly says whether styles alone are enough. Call NotifyDocumentUpdated() after a reload so an attached client refreshes.
  • PushConsoleMessage(level, text) sends one console line to an attached client, with level 0 for verbose, 1 info, 2 warning and 3 error.
  • GetFrontendUrlRaw writes the address to open, http://host:port/.

The same code appears with the rest of the host setup in Your own C++ host. APPlayer, which is in the engine source tree, starts DevTools on 127.0.0.1:9222 when it launches.

Connect Chrome

Open the address in Chrome, or add it as a target in chrome://inspect (the steps are in Debugging). The package carries Chrome's DevTools front end in data/apdevtools/front_end, and the server finds it there.

If you set a token, a client must present it as an Authorization: Bearer header or as ?token= in the URL, on the HTTP endpoints and on the WebSocket. The server also rejects requests that come from another origin, and, when it listens on loopback, requests whose Host header is not loopback. Neither check depends on the token.

Keep it out of what players get

The server opens a debugging port that can run script in your game and read its pages. Start it only in builds that stay inside your team, bind it to loopback, and set a token when anyone else can reach the machine. Do not ship apertureuideveloperengine.dll to players.

Without the server

When your host leaves the server disabled, use the logging and page habits described in Debugging: page console calls reach your IAPCLoggingSystem, engine messages reach the same log once you call SetInternalEngineLogging(true), and the environment probes in Performance print timings to that log.

JavaScript exceptions reach the log and DevTools console. The window error and unhandledrejection events are not dispatched, so an addEventListener for them never fires. Use the log hook to collect these.

On this page