To verify how an atomic service looks and behaves, you can run and debug it.
The procedure for running a HarmonyOS atomic service on a phone is the same as that on a tablet. You can use either USB or wireless debugging for connection.
For details, see Running Your App on a Local Real Device.
DevEco Studio includes the Emulator that mimics the essential features of real devices. This tool allows you to work more flexibly and efficiently when developing and debugging your atomic service, ultimately improving the overall development experience and productivity.
For details, see Running Your App on the Emulator.
Hot reload allows code changes to take effect in real time. After this feature is enabled in DevEco Studio, the debug device will automatically apply changes upon modification of page files (CSS, HXML, JS, or JSON) without additional steps. This significantly reduces recompilation and execution time while delivering a dramatic boost to development efficiency.
Connect to a device and select the device where the atomic service is running in DevEco Studio.
Select an entry with
from the run/debug configuration menu to enter the hot reload mode.

Click
to enable hot reloading. Wait until hot reload is enabled.

Modify and save the CSS, HXML, JS, and JSON files and view the effects on the device in real time.


ASCF runtime includes the view layer (Webview) and the logic layer (V8 engine), with both supporting local debugging.
The ASCF Plugin version must be 1.0.4.304 or later.
For versions earlier than DevEco Studio 6.0, the debugging page is opened in the browser.
Open the debugging page via View > Tool Windows > ASCF Debugger, or directly click
in the bottom-left tool window bar (new UI only). For DevEco Studio versions earlier than 6.0.0, you can click
in the tool window bar at the bottom to open it.

Run the atomic service in DevEco Studio. For details, see Running an Atomic Service on a Local Real Device.
Debugging covers two layers: the view layer (Webview) and the logic layer (V8 engine). For details, see Debugging and Running ASCF Source Code.
Click
in the ASCF Debugger, and logic layer (V8 engine) debugging will be initiated automatically in DevEco Studio, as shown in the figure below.

Open chrome://inspect/#devices in a browser to debug the view layer (Webview).
In debug mode, run the following commands in the root directory of the ASCF project to enable or disable debugging.
Enabling Webview debugging and V8 engine debugging:
ascf debugger start
After the command is executed successfully, open the debugger page in Chrome based on the log prompts.
Opening the V8 engine debugging page in the browser:
ascf debugger start -o
Disabling Webview debugging and V8 engine debugging:
ascf debugger stop
Enabling Webview debugging:
ascf debugger start-view
Disabling Webview debugging:
ascf debugger stop-view
Enabling V8 engine debugging:
ascf debugger start-service
Disabling V8 engine debugging:
ascf debugger stop-service
Checking the current debugging status:
ascf debugger status
When the device running HarmonyOS 5.0 or later is connected and the ascf debugger start -ct hdc command is executed, enter chrome://inspect/#devices in the address box of Chrome on the PC and open the page.
When the device running HarmonyOS 4 or earlier is connected and the ascf debugger start -ct adb command is executed, obtain the debug address by searching the logs for the keyword start debug server url, enter the debug address in the address box of Chrome on the PC, and open the page.
Configure the Chrome debugging tool.
The web page to be debugged needs to be discovered from the local TCP ports 9222 and 9229. Therefore, ensure that Discover network targets is selected. Then, configure the network. Port 9222 corresponds to the Webview debugging window, and port 9229 corresponds to the V8 engine debugging window.
(1) Click the Configure button.
(2) Add localhost:9222 and localhost:9229 to Target discovery settings.

Open Chrome DevTools and click Network. The panel displays the resources requested by has.download, has.upload, has.request, and has.getImageInfo. Click a request on the panel to view detailed network request information.
Currently, network debugging is supported only on devices running HarmonyOS 4 or earlier.

You can run the following command to obtain the help information about the parameters of the CLI tool debugging function:
ascf debugger start --help
Debugging
| Option | Function |
|---|---|
| --bundleName | Name of the ASCF package to debug. Example: ascf debugger start --bundleName com.atomicservice.1234568789 |
| --open [chrome|edge] | Browser to open the V8 engine debugging page. Chrome and Edge are supported. |
| --deviceId | ID of the device for debugging when the PC is connected to multiple devices. Example: ascf debugger start --deviceId 123456789 You can run the hdc list targets command to query all connected target devices. |
-ct --connectorType | Type of the device debugging tool. Both hdc and adb are supported. The default value is hdc. When debugging on a device running HarmonyOS 4 or earlier, you need to set the type to adb. |
If the preceding commands are not supported, upgrade ASCF Toolkit to 1.0.5 or later, or perform the following operations:
For details about how to enable Webview debugging, see Debugging Frontend Pages by Using DevTools.
To enable V8 engine debugging, set debug=true in manifest.json. You can configure "ascfDebugger": "brk" in ascf.config.json to enable breaking at the first executable line.
To manually enable V8 engine debugging, run the hdc fport tcp:9229 tcp:9225 command locally, visit http://localhost:9229/json, and use the URL in the devtoolsFrontendUrl field to open the debugging page via a browser.
If you encounter debugging activation failures (error: getDebugger[fport]error; [fport]: defaulting to 9222/9229) and cannot address them even after troubleshooting as prompted by the logs, this may be due to the ASCF Toolkit version being 1.0.9 or earlier, where the PC resolves localhost to an IPv6 address, causing ASCF Toolkit to fail to detect the port correctly. Upgrade the ASCF Toolkit to version 1.0.10 or later and try again.

To view logs from the ASCF Console and information about calls to the has APIs, you can configure {"enableDevtools": true} in the ascf.config.json file to enable the debug panel.
If
is displayed on the page, the debug panel is successfully enabled.
Enabling the debug console may affect the page loading duration. Therefore, you are advised not to enable it in production environments.
The debug console mainly provides the following functions:
In DevEco Studio, open the bottom log panel, select the atomic service you are developing, and search for the keywords 006F or ascf-app to check for any warnings or errors.

To develop with ASCF Assistant in VS Code and view the developer-printed logs, see Enabling HiLog.
If an error message contains "xxx is not defined," the corresponding API might not yet be implemented in the atomic service, and the API needs to be adapted.
Click the debug button at the bottom of VS Code to compile and run the atomic service and launch the debugging page.

Debugging covers two layers: the view layer (Webview) and the logic layer (V8 engine). For details, see Debugging and Running ASCF Source Code.
The logic layer (V8 engine) debugging will be initiated automatically in VS Code, as shown in the figure below.

Open chrome://inspect/#devices in a browser to debug the view layer (Webview).