JavaScript Remote Debugging with Google Chrome Developer Tools for Java

chrome tools

Everyone knows that WebKit Android port does not support JavaScript Remote Debugging. But we also know this function is crucial when it comes to developing a web application or website. Without this function, developers have to go through a very painstaking debugging process. Last month, we succeeded on debugging JavaScript code running on the Web Browser of a device from our desktop. We have ported necessary tools from Google Chrome and adopted on our WebKit Android NDK port.

The target device’s OS was Android. We used Google Chrome Developer Tools for Java for debugging from our desktop. The device and desktop were connected with a USB. Below video shows the results we have achieved when debugging JavaScript; it checks JavaScript code, uses breakpoint and checks stack trace. (In this video I used Android Emulator instead of a real device.

 

We adopted DevToolsAgent and DevToolsProtocolHandler from Google Chrome to our WebKit Android NDK port

In Google Chrome, important protocols for Google Chrome Developer Tools for Java are ChromeDevToolsProtocol and V8 Debugger Protocol which are processed by DevToolsProtocolHandler and DevToolsAgent repectively. We modified and reimplemented DevToolsProtocolHandler and DevToolsAgent using Java, because WebKit layer of WebKit Android NDK port used Java.

DevToolsProtocolHandler acts as a server. It opens and listens a port. If ChromeDevTools tries to connect to it, then it starts working. It receives and parses the ChromeDevToolsProtocol message, then it responds to ChromeDevTools for Java, and it calls DevToolsAgent functions with V8 Debugger Protocol messages that are in ChromeDevToolsProtocol messages.

DevToolsAgent is a part of WebView. Its lifecycle equals to WebView. Its main role is to pass V8 Debugger Protocol messages from DevToolsProtocolHandler to V8 engine, and vice versa. Another role is to serve as a handler of system messages when breakpoint stops V8 engine.

Google Chrome Developer Tools for Java

It provides an integrated environment for debugging a web application, or website that runs in Google Chrome. Google Chrome Developer Tools for Java is a part of Google Chrome Developer Tools. It enables you to debug JavaScript inside Google Chrome over the TCP/IP protocol.

Leave a Reply

Your email address will not be published. Required fields are marked *

8 + 18 =