Re: [Chrome DevTools] Remote Debugging Android WebViews

1,042 views
Skip to first unread message

Dmitry Zvorygin

unread,
Jan 17, 2014, 2:12:22 PM1/17/14
to Google Chrome Developer Tools
Hi Matt.

You can use found unix socket to send "GET /json HTTP/1.1\r\n\r\n" HTTP request as in https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/devtools/devtools_adb_bridge.cc&l=468

In response you may see webSocketDebuggerUrl field - there will be websocket url you are interested in.

WBR,
Dmitry.

On Fri, Jan 17, 2014 at 10:50 PM, <ma...@bootstraponline.com> wrote:
The device discovery logic for debugging Android KitKat webviews is not documented. Running cat /proc/net/unix will list webviews in this format: @webview_devtools_remote_159  The last number is a PID which can be used to look up the apk package:

`adb shell ps`.split("\r\n").reject { |l| ! l.include?(pid) }

I don't know how to identify the websocket address that's in use to send the appropriate debugging protocol messages. "chrome://inspect/#devices" works without issue so I'm not sure why device discovery isn't clearly explained somewhere. Any help with this is appreciated.

https://developers.google.com/chrome-developer-tools/docs/debugger-protocol
https://developers.google.com/chrome-developer-tools/docs/remote-debugging

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/1ea11f2c-8680-4a52-85df-9f33940f1293%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

ma...@bootstraponline.com

unread,
Jan 17, 2014, 3:27:28 PM1/17/14
to google-chrome-...@googlegroups.com, zvor...@google.com
Is adb forward required? I get ECONNRESET when trying to read the response from the server.

Num        RefCount Protocol Flags    Type St  Inode Path
"00000000: 00000002 00000000 00010000 0001 01  4558 @webview_devtools_remote_1709"

# local port, remote_abstract
# src/chrome/test/chromedriver/chrome/adb_impl.cc
adb forward tcp:8000 localabstract:4558

require 'socket'
s = TCPSocket.open('localhost', 8000);
s.write "GET /json HTTP/1.1\r\n\r\n"
s.read # Errno::ECONNRESET: Connection reset by peer

On Friday, January 17, 2014 2:12:22 PM UTC-5, Dmitry Zvorygin wrote:
Hi Matt.

You can use found unix socket to send "GET /json HTTP/1.1\r\n\r\n" HTTP request as in https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/devtools/devtools_adb_bridge.cc&l=468

In response you may see webSocketDebuggerUrl field - there will be websocket url you are interested in.

WBR,
Dmitry.

On Fri, Jan 17, 2014 at 10:50 PM, <ma...@bootstraponline.com> wrote:
The device discovery logic for debugging Android KitKat webviews is not documented. Running cat /proc/net/unix will list webviews in this format: @webview_devtools_remote_159  The last number is a PID which can be used to look up the apk package:

`adb shell ps`.split("\r\n").reject { |l| ! l.include?(pid) }

I don't know how to identify the websocket address that's in use to send the appropriate debugging protocol messages. "chrome://inspect/#devices" works without issue so I'm not sure why device discovery isn't clearly explained somewhere. Any help with this is appreciated.

https://developers.google.com/chrome-developer-tools/docs/debugger-protocol
https://developers.google.com/chrome-developer-tools/docs/remote-debugging

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.

Pavel Feldman

unread,
Jan 17, 2014, 11:45:12 PM1/17/14
to Google Chrome Developer Tools, zvorygin

What are you trying to do?

To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/8ff650e0-2e42-4300-ac48-519f5a45f29a%40googlegroups.com.

bootstrap online

unread,
Jan 18, 2014, 11:29:51 AM1/18/14
to google-chrome-...@googlegroups.com, zvorygin
I'm trying to use webkit_remote on my APK's webview in Android KitKat.

https://github.com/pwnall/webkit_remote
>>>> an email to google-chrome-develo...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/google-chrome-developer-tools/1ea11f2c-8680-4a52-85df-9f33940f1293%40googlegroups.com.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Chrome Developer Tools" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to google-chrome-develo...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/google-chrome-developer-tools/8ff650e0-2e42-4300-ac48-519f5a45f29a%40googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Google Chrome Developer Tools" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/google-chrome-developer-tools/duT3rO-lBBk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> google-chrome-develo...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-chrome-developer-tools/CAEX3KhYVDOHj4fuF19-hy2mTPWj8AhF28JMb-G-UkTy%2BT%3Dn%2Bzg%40mail.gmail.com.

Alejandro F. Reimondo

unread,
Jan 18, 2014, 9:39:10 AM1/18/14
to google-chrome-...@googlegroups.com, zvorygin
Hi!
I am in the same situation, no public documentation
and missing access at javascript level.
It is not easy for us (developers trying to use chrome
features to enable comfortable debugging of existing
systems) to adapt our systems to changes and/or extensions
that do not use existing APIs (and are not complete at
upper levels; e.g. implemented in chrome with native
functions that are not atomic).
All this said with the intention to provide feedback,
and with the hope to do not happen in the future.

In my case I use debug interface in a chrome extension
to debug S8 systems (S8 is a smalltalk dev. platform
that generate javascript dynamically; all development is
done at smalltalk level; and good debugging experience
is a must to be competitive to other smalltalk alternatives
for development). Remote debugging and changing of
smalltalk systems is used from early '90s and what
I have implemented is the minimal support to make
smalltalkers comfortable when debugging/mantaining
remote and cotinuously evolving systems (it includes
debugging, browsing and editing the remote systems
while running; for that it is requiered full GUI extension;
also the debugger system -another smalltalk instance-
can change and be customized for the maintenance
of other systems, e.g. realtime, running in phones).

We use the S8 platform to develop apps running (and
debugged multiplatform) on android and iOS, and
webview (native & cordova) in the context of open (MIT based)
and social development ( http://u8.smalltalking.net [**]).

I implemented our debugger as Chrome extension [*]
long time ago; and it is working of for desktop and
remote debug for android to debug browser pages
(running as chrome pages in android).

I want to detect webviews... BUT with MINIMAL effort
on my/javscript side.
What I would like to see as a detection API is,
a javascript API published to detect devtools
javascript runtimes, without complexity imposed by adb
(e.g. the same procedure requiring manual forwarding
as it exists for chrome pages).
I would suggest to extend "localabstract:chrome_devtools_remote"
or publish another namespace for multiple types of enviroment;
like localabstract:chrome_devtools_remote_runtimes
that expose same JSON from GET request, but returning
pages and webviews, each record tagged with "type"
page/webview).
mmm it should require changing/updating chrome
on android... but imho will make all much easy to mantain
for extension developers.

Meanwhile, I need to access webviews to implement
debug asap; with current undoccumented state of the
"detection API" :-)
I have made the following adb command (command line
mode on desktop/windows)
-------------------------------------------------
adb shell cat /proc/net/unix
adb forward tcp:9222 localabstract:webview_devtools_remote_5230
-------------------------------------------------

The "remote_5230" key has been got from shell /proc/net/unix
results...
And then, I tried to use my my existing debug interface to get JSON
fields...
It failed to get data from localhost:9222 :-(

If I run command
---------------------------------------------------
adb forward tcp:9222 localabstract:chrome_devtools_remote
---------------------------------------------------

It is working ok (I get json fields from chrome pages);
but not luck to access webviews running in my nexus 7 device.

Any guide, drafts or recomendations will be appreciated!
Thanks for reading this long email, and for trying to help us !
Ale.

[*] Debugger Ref:
http://u8.smalltalking.net/contribution.aspx?contributionId=273
[**] Dev. Environment (UI8=browser mode) Ref:
http://u8.smalltalking.net/contribution.aspx?contributionId=239
email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-chrome-developer-tools/1ea11f2c-8680-4a52-85df-9f33940f1293%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
You received this message because you are subscribed to the Google Groups
"Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-chrome-developer-tools/8ff650e0-2e42-4300-ac48-519f5a45f29a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups
"Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-chrome-developer-tools/CAEX3KhYVDOHj4fuF19-hy2mTPWj8AhF28JMb-G-UkTy%2BT%3Dn%2Bzg%40mail.gmail.com.

bootstrap online

unread,
Jan 18, 2014, 4:31:09 PM1/18/14
to google-chrome-...@googlegroups.com, zvorygin
Thanks. I was using the wrong value in localabstract.
> You received this message because you are subscribed to a topic in the
> Google Groups "Google Chrome Developer Tools" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/google-chrome-developer-tools/duT3rO-lBBk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> google-chrome-develo...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-chrome-developer-tools/AC6EFA41E3A74A9391E25C26EBDD7D54%40Aqueronte.

Pavel Feldman

unread,
Jan 21, 2014, 6:20:51 AM1/21/14
to Google Chrome Developer Tools
The only problem with this approach is that there is no Android service that manages remote debugging connections. Each process does it on its own.
So when there is no Chrome running, there is no process to expose "localabstract:chrome_devtools_remote" socket. This + the fact that adb is the only way to communicate with the device led us to present no-so-user-friendly design.

Regards
Pavel
 
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/1ea11f2c-8680-4a52-85df-9f33940f1293%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/8ff650e0-2e42-4300-ac48-519f5a45f29a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/AC6EFA41E3A74A9391E25C26EBDD7D54%40Aqueronte.
Reply all
Reply to author
Forward
0 new messages