Timeline tab

694 views
Skip to first unread message

Mandy

unread,
May 24, 2011, 7:25:12 AM5/24/11
to Google Chrome Developer Tools
Hi,

Do we have any API exposed of these developer tools? Is it possible to
hook this for programmatically executed actions on a website. By doing
to I wish to capture timelines by executing set of pages repeatedly.

Andrey Kosyakov

unread,
May 24, 2011, 7:46:21 AM5/24/11
to google-chrome-...@googlegroups.com
No at the moment, but there's work in progress to expose timeline data through chrome.experimental.devtools.timeline API:

Andrey Kosyakov

unread,
May 24, 2011, 8:54:20 AM5/24/11
to google-chrome-...@googlegroups.com
Apologies, there's actually another API that may fit your use case well and already provides timeline -- basically, we expose entire DevTools protocol as an extension API:


Here's timeline-related protocol description: http://code.google.com/chrome/devtools/docs/protocol/timeline.html

masoomeh Rudafshani

unread,
Jun 7, 2011, 6:57:33 PM6/7/11
to Google Chrome Developer Tools

Hi,
I'm using chrome.experimental.debugger extension to get the CPU
profile of a page. However, nothing is generated in the onEvent
function.
Here is the code for sending the request and also onEvent function.


chrome.experimental.debugger.sendRequest(tabId,"Profiler.enable",
null, onResponse);
chrome.experimental.debugger.sendRequest(tabId,"Profiler.start", null,
onResponse);
chrome.experimental.debugger.sendRequest(tabId, "Profiler.getProfile",
{"type": "CPU", "uid": 1}, onResponseGet);

function onEvent(tabId, method, params) {
var params_str = JSON.stringify(params);
console.log(method);
console.log(params_str);
}

Just to add that I attached to the page in advance using
chrome.experimental.debugger.attach function. This is just part of the
code.
In addition, when I want to take a heap snapshot using the following
commands:

chrome.experimental.debugger.sendRequest(tabId,
"Profiler.takeHeapSnapshot", {"detailed": true}, onResponse);

It works, but, I don't get notification for functions such as
"addHeapSnapshotChunk".
I just get notification for "addProfileHeader" and
"reportHeapSnapshotProgress".

My goal is to take the same data as those generated by chrome
developer tools.

Thanks


On May 24, 8:54 am, Andrey Kosyakov <ca...@chromium.org> wrote:
> Apologies, there's actually another API that may fit your use case well and
> already provides timeline -- basically, we expose entire DevTools protocol
> as an extension API:
>
> http://code.google.com/chrome/extensions/dev/experimental.debugger.html
>
> Here's timeline-related protocol description:http://code.google.com/chrome/devtools/docs/protocol/timeline.html
>
> On Tue, May 24, 2011 at 3:46 PM, Andrey Kosyakov <ca...@chromium.org> wrote:
> > No at the moment, but there's work in progress to expose timeline data
> > through chrome.experimental.devtools.timeline API:
>
> >https://bugs.webkit.org/show_bug.cgi?id=61098
>

Mikhail Naganov

unread,
Jun 8, 2011, 2:09:41 AM6/8/11
to google-chrome-...@googlegroups.com, masoomeh....@gmail.com
Hi Masoomeh,

Can you please describe your setup? If you are running two instances
of Chrome, are you using separate profiles for them, as described
here: http://blog.chromium.org/2011/05/remote-debugging-with-chrome-developer.html?

Masoomeh Rudafshani

unread,
Jun 8, 2011, 9:43:13 AM6/8/11
to mnag...@chromium.org, google-chrome-...@googlegroups.com

I'm just running one instance of Chromium. Actually if it were two instances then I guess I had received error when attaching or sending request. But, it's working, just the output is not what I expect.
You can see the extension code attached.

Thanks
debug2.tgz

pfeldman

unread,
Jun 8, 2011, 10:00:39 AM6/8/11
to Google Chrome Developer Tools
Our Profiler domain API is provisional, it is not yet documented at
http://code.google.com/chrome/devtools/docs/remote-debugging.html. In
either case, http://trac.webkit.org/browser/trunk/Source/WebCore/inspector/Inspector.json
contains the source interface description that is used both for code
and documentation generation. Check out new Profiler commands syntax
there. When in doubt, you can sniff for the messages that are being
sent by the DevTools itself in the remote debugging scenario (the one
that uses socket) and act alike both when using socket or when using
chrome.experimental.debugger.

Tell me if it helps, otherwise I'll get deeper look into your
extension code.

Regards
Pavel

masoomeh Rudafshani

unread,
Jun 8, 2011, 12:17:22 PM6/8/11
to Google Chrome Developer Tools
Hi Pavel,

Thanks for your reply.

As profiler is not documented well, so, I'm using the ones that are
documented and also the Inspector.json which describes the commands
and notifications for Profiler.

My chrome version is this one: 13.0.778.0 (Developer Build 86834
Linux).

Also when I try to debug over the wire ( executing ./chrome --remote-
debugging-port=9222 and then connecting using http://localhost:9222 on
another window).
The other window just shows it's bringing the page, but it never
connects (I tested remote debugging using earlier version of chrome
and it was working).

As I understand, you are suggesting to go through what is described in
the "Debugging over the wire section"
in this page: http://code.google.com/chrome/devtools/docs/remote-debugging.html
and using WebSocket addresses, right?
However, I spent some time to learn how to work with the extension and
it's more convenient if this works. Actually I tried all the commands
in the Profiler to get the Notification, but some of them are not
generated.

The chrome version that I'm using is a debugger version (I compiled it
so that it prints debugging messages). Another difficulty is that it's
not possible to debug this extension using chrome developer tools
because two instances cannot connect at the same time.

Thanks,


On Jun 8, 10:00 am, pfeldman <pfeld...@chromium.org> wrote:
> Our Profiler domainAPIis provisional, it is not yet documented athttp://code.google.com/chrome/devtools/docs/remote-debugging.html. In
> either case,http://trac.webkit.org/browser/trunk/Source/WebCore/inspector/Inspect...

Mikhail Naganov

unread,
Jun 8, 2011, 2:52:02 PM6/8/11
to google-chrome-...@googlegroups.com
On Wed, Jun 8, 2011 at 20:17, masoomeh Rudafshani
<masoomeh....@gmail.com> wrote:
> Hi Pavel,
>
> Thanks for your reply.
>
> As profiler is not documented well, so, I'm using the ones that are
> documented and also the Inspector.json which describes the commands
> and notifications for Profiler.
>
> My chrome version is this one: 13.0.778.0 (Developer Build 86834
> Linux).
>
> Also when I try to debug over the wire ( executing ./chrome --remote-
> debugging-port=9222 and then connecting using http://localhost:9222 on
> another window).
> The other window just shows it's bringing the page, but it never
> connects (I tested remote debugging using earlier version of chrome
> and it was working).
>

This will not work. You need a separate Chrome instance. You can
either run Chrome + Chromium (they use separate profile dirs, so they
can co-exist), or specify --user-data-dir with some directory to the
second instance.

masoomeh Rudafshani

unread,
Jun 8, 2011, 3:24:37 PM6/8/11
to Google Chrome Developer Tools
Thanks Mikhail for your suggestion. That's working now (remote
debugging using another instance of browser). But I have still some
difficulties with the extension API, as explained in the previous
email. My goal is to get the data generated by developer tools without
having a user interface.

Thanks,

Mikhail Naganov

unread,
Jun 8, 2011, 3:51:09 PM6/8/11
to google-chrome-...@googlegroups.com, masoomeh....@gmail.com
As long as our protocol is experimental, the best approach by far is
sniffing interaction of remote debugging and mimicking it in your
application. I know people were successful at that.

Ilya Tikhonovsky

unread,
Jun 8, 2011, 3:51:59 PM6/8/11
to google-chrome-...@googlegroups.com
1) looks like you are trying to pass a JSON strings with space symbols. There is a bug here. Our json parser doesn't accept messages like {"id": 1} because there is space between : and 1.
2) You can sniff the protocol with help of DevTools for DevTools. For doing that you need to open another DevTools window for the first one with  help of shortcut or context menu. After that please open console in the second instance and write the next command. 
window.dumpInspectorProtocolMessages = 1;
From that moment all the traffic between first instance of DevTools and inspecting window will be dumped into second instance's console.

Regards,
Tim.

masoomeh Rudafshani

unread,
Jun 8, 2011, 5:01:45 PM6/8/11
to Google Chrome Developer Tools

Thanks for your helpful answers.

On Jun 8, 3:51 pm, Ilya Tikhonovsky <loi...@chromium.org> wrote:
> 1) looks like you are trying to pass a JSON strings with space symbols.
> There is a bug here. Our json parser doesn't accept messages like {"id": 1}
> because there is space between : and 1.
> 2) You can sniff the protocol with help of DevTools for DevTools. For doing
> that you need to open another DevTools window for the first one with  help
> of shortcut or context menu. After that please open console in the second
> instance and write the next command.
> window.dumpInspectorProtocolMessages = 1;
> From that moment all the traffic between first instance of DevTools and
> inspecting window will be dumped into second instance's console.
>
> Regards,
> Tim.
>
> On Wed, Jun 8, 2011 at 11:24 PM, masoomeh Rudafshani <
>

masoomeh Rudafshani

unread,
Jun 9, 2011, 12:37:48 PM6/9/11
to Google Chrome Developer Tools

Hi,
I'm trying to use websocket to connect to the browser and take the
data. Is there anything wrong with the following approach that it's
not working?

var socket = new WebSocket("ws://localhost:9222/devtools/page/
6");

socket.onmessage = function(message)
{ console.log(message.data);}
socket.onerror = function(error) { console.error(error); }
socket.onopen = function() {
var MSG = {"method":"Profiler.start","id":84};
socket.send(JSON.stringify(MSG));
MSG = {"method":"Profiler.stop","id":85};
socket.send(JSON.stringify(MSG));
}

I started the browser using command line --remote-debugging-port=9222.
I expect to get the profiling results in onmessage, but it generates
nothing. Any help would be appreciated.


On Jun 8, 3:51 pm, Ilya Tikhonovsky <loi...@chromium.org> wrote:
> 1) looks like you are trying to pass a JSON strings with space symbols.
> There is a bug here. Our json parser doesn't accept messages like {"id": 1}
> because there is space between : and 1.
> 2) You can sniff the protocol with help of DevTools for DevTools. For doing
> that you need to open another DevTools window for the first one with  help
> of shortcut or context menu. After that please open console in the second
> instance and write the next command.
> window.dumpInspectorProtocolMessages = 1;
> From that moment all the traffic between first instance of DevTools and
> inspecting window will be dumped into second instance's console.
>
> Regards,
> Tim.
>
> On Wed, Jun 8, 2011 at 11:24 PM, masoomeh Rudafshani <
>
Message has been deleted
Message has been deleted

PhistucK

unread,
Jun 9, 2011, 2:04:34 PM6/9/11
to google-chrome-...@googlegroups.com
Please, avoid posting the same message multiple (3) times.

1. Make sure you are running two instances of Chrome (or an instance of Chrome and an instance of Chromium), meaning, make sure you use two distinct user profiles.
2. Do you see anything at all within the console? Are you sure the WebSocket connection was opened successfully? Are you sure the connection is active?
3. Add a console.log("I am open!") as the first line in the function which is assigned to the onopen event. Can you see this text within the console?
4. Where are you running this code? within a page from localhost:9222? within a page of your own, from a different host? You might be tripping because of web security here, I believe you cannot connect a WebSocket to a different origin than the origin of the page in which the script is run.
PhistucK

masoomeh Rudafshani

unread,
Jun 9, 2011, 2:42:02 PM6/9/11
to Google Chrome Developer Tools

> Please, avoid posting the same message multiple (3) times.
I did so because the page had a delay in showing the message. Sorry
about that.

1) I did so, I have two instance one with this directive --remote-
debugging-port=9222 and the other one in a different user profile/

> 2. Do you see anything at all within the console? Are you sure the WebSocket
> connection was opened successfully? Are you sure the connection is active?

I think so because I'm not getting any error.

> 3. Add a console.log("I am open!") as the first line in the function which
> is assigned to the onopen event. Can you see this text within the console?

YES.

> 4. Where are you running this code? within a page from localhost:9222?
> within a page of your own, from a different host? You might be tripping
> because of web security here, I believe you cannot connect a WebSocket to a
> different origin than the origin of the page in which the script is run.

I'm running the code inside an extension in the second instance of
chrome. the code I put here is in the background.html of the extension
and that's all.
The permission for the extension is:

"permissions": ["tabs", "http://*/" ]

Thanks


>
> On Thu, Jun 9, 2011 at 19:37, masoomeh Rudafshani <
>

masoomeh Rudafshani

unread,
Jun 9, 2011, 4:47:34 PM6/9/11
to Google Chrome Developer Tools

Just to add that when I replace "Profiler.start" with "Timeline.start"
everything works well and the message are generated as expected.
There must be something wrong in the chrome source code? any idea?

Thanks,


On Jun 9, 2:42 pm, masoomeh Rudafshani <masoomeh.rudafsh...@gmail.com>
wrote:

Mikhail Naganov

unread,
Jun 9, 2011, 5:11:29 PM6/9/11
to google-chrome-...@googlegroups.com
Profiler interaction is not very simple. After you finish profiling,
only profile header is sent to the front-end. Then you need to request
the profile. Have you tried sniffing messages between remote DevTools
and the host? Have you tried repeating sending the same messages from
your extension?

As long as the remote debugging scenario works, we assume our code is OK.

masoomeh Rudafshani

unread,
Jun 9, 2011, 5:55:39 PM6/9/11
to Google Chrome Developer Tools
Off course I sniffed the messages. I'll put part of it at the end. I'm
sending the same messages from my extension.

After sending "Profiler.start" and "Profiler.stop" and even
"Profiler.getProfile" I just get

"{"result":{},"id":109}"

while according to the sniffed messages I expect to receive

....Profiler.setRecordingProfile......

....Profiler.addProfileHeader.........

.....Profiler.setRecordingProfile....

etc.

Just to add that I could get this message (....result....) by issuing
Profiler.enable before Profiler.start. Something that is not shown in
sniffed messages.

Masoomeh


1 [23397:23397:49229023012:INFO:CONSOLE(3843)] "frontend:
{"method":"Profiler.start","id":24}", source: http://localhost:9222/devtools/DevTools.js
(3843)
2 [23397:23397:49229155607:INFO:CONSOLE(3863)] "backend:
{"method":"Console.messageAdded","params":{"messageObj":
{"source":"javascript","type":"log","level":"log","line":0,"u
rl":"","repeatCount":1,"text":"Profile \"webkit-profile://CPU/
org.webkit.profiles.user-initiated.1#0\" started."}}}", source:
http://localhost:9222/devtools/DevTools.js (38 63)
3 [23397:23397:49229193399:INFO:CONSOLE(3863)] "backend:
{"method":"Profiler.setRecordingProfile","params":
{"isProfiling":true}}", source: http://localhost:9222/devtools/DevT
ools.js (3863)
4 [23397:23397:49229212350:INFO:CONSOLE(3863)] "backend: {"result":
{},"id":24}", source: http://localhost:9222/devtools/DevTools.js
(3863)
5 [23397:23397:49248126989:INFO:CONSOLE(3843)] "frontend:
{"method":"Profiler.stop","id":25}", source: http://localhost:9222/devtools/DevTools.js
(3843)
6 [23397:23397:49248136573:INFO:CONSOLE(3863)] "backend:
{"method":"Profiler.addProfileHeader","params":{"header":
{"title":"org.webkit.profiles.user-initiated.1","uid":1,"typ
eId":"CPU"}}}", source: http://localhost:9222/devtools/DevTools.js
(3863)
7 [23397:23397:49248193805:INFO:CONSOLE(3843)] "frontend:
{"method":"Profiler.getProfile","params":{"type":"CPU","uid":1},"id":
26}", source: http://localhost:9222/devtools/De vTools.js (3843)
8 [23397:23397:49248256118:INFO:CONSOLE(3863)] "backend:
{"method":"Console.messageAdded","params":{"messageObj":
{"source":"javascript","type":"log","level":"log","line":0,"u
rl":"","repeatCount":1,"text":"Profile \"webkit-profile://CPU/
org.webkit.profiles.user-initiated.1#1\" finished."}}}", source:
http://localhost:9222/devtools/DevTools.js (3 863)
9 [23397:23397:49248279872:INFO:CONSOLE(3863)] "backend:
{"method":"Profiler.setRecordingProfile","params":
{"isProfiling":false}}", source: http://localhost:9222/devtools/Dev
Tools.js (3863)
10 [23397:23397:49248282964:INFO:CONSOLE(3863)] "backend: {"result":
{},"id":25}", source: http://localhost:9222/devtools/DevTools.js
(3863)





On Jun 9, 5:11 pm, Mikhail Naganov <mnaga...@chromium.org> wrote:
> Profiler interaction is not very simple. After you finish profiling,
> only profile header is sent to the front-end. Then you need to request
> the profile. Have you tried sniffing messages between remote DevTools
> and the host? Have you tried repeating sending the same messages from
> your extension?
>
> As long as the remote debugging scenario works, we assume our code is OK.
>
> On Fri, Jun 10, 2011 at 00:47, masoomeh Rudafshani
>

Mikhail Naganov

unread,
Jun 10, 2011, 1:17:02 AM6/10/11
to google-chrome-...@googlegroups.com
OK, sorry for casting doubt on your approach. I'll take a closer look
at what happens on our side soon.

Mikhail Naganov

unread,
Jun 10, 2011, 1:26:10 AM6/10/11
to google-chrome-...@googlegroups.com
On Fri, Jun 10, 2011 at 01:55, masoomeh Rudafshani
<masoomeh....@gmail.com> wrote:
> Off course I sniffed the messages. I'll put part of it at the end. I'm
> sending the same messages from my extension.
>
> After sending "Profiler.start" and "Profiler.stop" and even
> "Profiler.getProfile" I just get
>
> "{"result":{},"id":109}"
>
> while according to the sniffed messages I expect to receive
>
> ....Profiler.setRecordingProfile......
>
> ....Profiler.addProfileHeader.........
>
> .....Profiler.setRecordingProfile....
>
> etc.
>
> Just to add that I could get this message (....result....) by issuing
> Profiler.enable before Profiler.start. Something that is not shown in
> sniffed messages.
>

Oh, by the way. I don't know, why it isn't shown, but DevTools
definitely invokes this operation (in DevTools, the setting
"Preferences.profilerAlwaysEnabled" is true):
http://codesearch.google.com/codesearch#OAMlx_jo-ck/src/third_party/WebKit/Source/WebCore/inspector/front-end/ProfilesPanel.js&l=138

Mikhail Naganov

unread,
Jun 10, 2011, 3:47:38 PM6/10/11
to google-chrome-...@googlegroups.com, masoomeh....@gmail.com
Hi Masoomeh,

I tried sniffing FE<>BE messages using the technique that Ilya has
proposed, and found that what you see isn't really a full log. The
initialization messages are skipped because you enable messages
logging _after_ the frontend has been initialized. To get a complete
dump from the beginning, I have done the following trick:
- do the usual setup (two Chrome instances, connect to DevTools from
a remote instance, then evaluate "window.dumpInspectorProtocolMessages
= 1" in the remote console);
- check that message logging works (do something in the debugged DevTools);
- now clean the remote console to get rid of previous messages;
- navigate to some other page (from another domain) in the tab that
you inspect with the debugger DevTools;
- now the backend will be re-initializing the frontend from scratch,
and you will be able to observe something similar to this:

backend: {"method":"Profiler.profilerWasEnabled"}
backend: {"method":"Profiler.resetProfiles"}
backend: {"method":"Network.requestWillBeSent","params":{"identifier":1,"frameId":"5029A00","loaderId":"380BE00","documentURL":"http://www.google.com/","request":{"url":"http://www.google.com/","method":"GET","headers":{"User-Agent":"Mozilla/5.0
(Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/535.1 (KHTML, like
Gecko) Chrome/14.0.785.0
Safari/535.1","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"}},"timestamp":1307734578.457265,"stackTrace":[]}}

... and so on.

As you see, profiler gets enabled from the very beginning. You were
just missing the corresponding messages in your log.
And, of course, without enabling the profiler, no profiles will be
collected at all. Commands are just being ignored by the profiler
agent.

masoomeh Rudafshani

unread,
Jun 11, 2011, 2:21:50 AM6/11/11
to Google Chrome Developer Tools
Hi,
Thanks for your reply. Just liked to add that I had enabled the
profiler.
My problem is with "Profiler.getProfile" command. No result is
generated for this command.
Thanks
> On Fri, Jun 10, 2011 at 09:26, Mikhail Naganov <mnaga...@chromium.org> wrote:
> > On Fri, Jun 10, 2011 at 01:55, masoomeh Rudafshani
> > <masoomeh.rudafsh...@gmail.com> wrote:
> >> Off course I sniffed the messages. I'll put part of it at the end. I'm
> >> sending the same messages from my extension.
>
> >> After sending "Profiler.start" and "Profiler.stop" and even
> >> "Profiler.getProfile" I just get
>
> >> "{"result":{},"id":109}"
>
> >> while according to the sniffed messages I expect to receive
>
> >> ....Profiler.setRecordingProfile......
>
> >> ....Profiler.addProfileHeader.........
>
> >> .....Profiler.setRecordingProfile....
>
> >> etc.
>
> >> Just to add that I could get this message (....result....) by issuing
> >> Profiler.enable before Profiler.start. Something that is not shown in
> >> sniffed messages.
>
> > Oh, by the way. I don't know, why it isn't shown, but DevTools
> > definitely invokes this operation (in DevTools, the setting
> > "Preferences.profilerAlwaysEnabled" is true):
> >http://codesearch.google.com/codesearch#OAMlx_jo-ck/src/third_party/W...
>
> >> Masoomeh
>
> >>  1 [23397:23397:49229023012:INFO:CONSOLE(3843)] "frontend:
> >> {"method":"Profiler.start","id":24}", source:http://localhost:9222/devtools/DevTools.js
> >> (3843)
> >>  2 [23397:23397:49229155607:INFO:CONSOLE(3863)] "backend:
> >> {"method":"Console.messageAdded","params":{"messageObj":
> >> {"source":"javascript","type":"log","level":"log","line":0,"u
> >> rl":"","repeatCount":1,"text":"Profile \"webkit-profile://CPU/
> >> org.webkit.profiles.user-initiated.1#0\" started."}}}", source:
> >>http://localhost:9222/devtools/DevTools.js(38    63)
> >>  3 [23397:23397:49229193399:INFO:CONSOLE(3863)] "backend:
> >> {"method":"Profiler.setRecordingProfile","params":
> >> {"isProfiling":true}}", source:http://localhost:9222/devtools/DevT
> >> ools.js (3863)
> >>  4 [23397:23397:49229212350:INFO:CONSOLE(3863)] "backend: {"result":
> >> {},"id":24}", source:http://localhost:9222/devtools/DevTools.js
> >> (3863)
> >>  5 [23397:23397:49248126989:INFO:CONSOLE(3843)] "frontend:
> >> {"method":"Profiler.stop","id":25}", source:http://localhost:9222/devtools/DevTools.js
> >> (3843)
> >>  6 [23397:23397:49248136573:INFO:CONSOLE(3863)] "backend:
> >> {"method":"Profiler.addProfileHeader","params":{"header":
> >> {"title":"org.webkit.profiles.user-initiated.1","uid":1,"typ
> >> eId":"CPU"}}}", source:http://localhost:9222/devtools/DevTools.js
> >> (3863)
> >>  7 [23397:23397:49248193805:INFO:CONSOLE(3843)] "frontend:
> >> {"method":"Profiler.getProfile","params":{"type":"CPU","uid":1},"id":
> >> 26}", source:http://localhost:9222/devtools/De   vTools.js (3843)
> >>  8 [23397:23397:49248256118:INFO:CONSOLE(3863)] "backend:
> >> {"method":"Console.messageAdded","params":{"messageObj":
> >> {"source":"javascript","type":"log","level":"log","line":0,"u
> >> rl":"","repeatCount":1,"text":"Profile \"webkit-profile://CPU/
> >> org.webkit.profiles.user-initiated.1#1\" finished."}}}", source:
> >>http://localhost:9222/devtools/DevTools.js(3    863)
> >>> >> > > > > difficulties with the extensionAPI, as explained in the previous
> >>> >> > > > > email. My goal is to get the data generated by developer tools without
> >>> >> > > > > having a user interface.
>
> ...
>
> read more »

Mikhail Naganov

unread,
Jun 11, 2011, 6:02:38 PM6/11/11
to google-chrome-...@googlegroups.com
Hi again,

Good news. I have found why the code wasn't working. Besides
"Profiler.enable", you were expected to invoke "Debugger.enable"
(although it may appear as if the debugger isn't needed here). I've
pasted my working 'background.html' version below.

Masoomeh: a couple of notes for you.
- you should wait for "setRecordingProfile" state change prior to
stopping profiling, and for "addProfileHeader" prior to trying to
retrieve the profile; as the things happen very asynchronously, you
may encounter a situation, when you are trying to act too early;
- there seems a bug that causes the renderer you open to crash if
you are trying to attach to it immediately after opening.

DevTools team:
- we need to investigate, why V8 crashes if we try to attach too
fast -- something wrong happens in EnterDebugger:

#4 0x0000000001897200 in CheckHelper (file=0x3abf0b3
"v8/src/objects-inl.h", line=2021,
source=0x3abf558 "object->IsSharedFunctionInfo()",
condition=false) at v8/src/checks.h:60
#5 0x00000000018b61f9 in v8::internal::SharedFunctionInfo::cast (object=0x0)
at v8/src/objects-inl.h:2021
#6 0x00000000018b6adf in v8::internal::JSFunction::shared (this=0x7f2f351a0291)
at v8/src/objects-inl.h:3179
#7 0x000000000193fc2c in
v8::internal::Heap::InitializeJSObjectFromMap (this=0x7f2f454d1098,
obj=0x7f2f36016601, properties=0x7f2f360165d1, map=0x7f2f14fa0af9)
at v8/src/heap.cc:3197
#8 0x000000000193fea1 in v8::internal::Heap::AllocateJSObjectFromMap
(this=0x7f2f454d1098,
map=0x7f2f14fa0af9, pretenure=v8::internal::NOT_TENURED) at
v8/src/heap.cc:3243
#9 0x000000000193ffa0 in v8::internal::Heap::AllocateJSObject
(this=0x7f2f454d1098,
constructor=0x7f2f351a0291, pretenure=v8::internal::NOT_TENURED)
at v8/src/heap.cc:3262
#10 0x000000000193f3df in
v8::internal::Heap::AllocateFunctionPrototype (this=0x7f2f454d1098,
function=0x7f2f351b0bf9) at v8/src/heap.cc:3002
#11 0x000000000190a7fd in v8::internal::Factory::NewFunctionPrototype
(this=0x7f2f454d1000, function=...)
at v8/src/factory.cc:378
#12 0x000000000190d9a3 in v8::internal::Factory::NewFunction
(this=0x7f2f454d1000, name=...,
type=v8::internal::JS_GLOBAL_OBJECT_TYPE, instance_size=48,
code=..., force_initial_map=true)
at v8/src/factory.cc:657
#13 0x00000000018c5120 in v8::internal::Genesis::CreateNewGlobals
(this=0x7fffbf185a50,
global_template=..., global_object=..., inner_global_out=0x7fffbf1859c0)
at v8/src/bootstrapper.cc:716
#14 0x00000000018cc4d5 in v8::internal::Genesis::Genesis
(this=0x7fffbf185a50, isolate=0x7f2f454d1000,
global_object=..., global_template=..., extensions=0x0) at
v8/src/bootstrapper.cc:2128
#15 0x00000000018c33da in
v8::internal::Bootstrapper::CreateEnvironment (this=0x7f2f454c1f00,
isolate=0x7f2f454d1000, global_object=..., global_template=...,
extensions=0x0)
at v8/src/bootstrapper.cc:291
#16 0x00000000018ece69 in v8::internal::Debug::Load
(this=0x7f2f454e3000) at v8/src/debug.cc:820
#17 0x00000000018f6047 in v8::internal::EnterDebugger::EnterDebugger
(this=0x7fffbf185c40)
at v8/src/debug.h:892

- and we need to set up debug events handler on profiler enable as
well, as the presence of handler is required for V8 to process
messages from the debugger queue. Perhaps, we can fix it in V8?

=========================

<script>

var tabId = null;

chrome.experimental.debugger.onEvent.addListener(eventHandler);
chrome.experimental.debugger.onDetach.addListener(detached);

function detached(eTabId)
{
console.log("Detached from " + eTabId);
}

chrome.tabs.create({url:"http://www.google.com"}, function(tab) {
tabId = tab.id;
chrome.experimental.debugger.attach(tabId);
// Note this: absense of a delay may crash the renderer!
setTimeout(attached, 1000);
});

function attached()
{
chrome.experimental.debugger.sendRequest(tabId, "Debugger.enable");
chrome.experimental.debugger.sendRequest(tabId, "Profiler.enable");
chrome.experimental.debugger.sendRequest(tabId, "Profiler.start",
null, callback);
function callback(result)
{
console.log(result);
}
}

function eventHandler(eTabId, method, params) {
if (eTabId !== tabId)
return;
if (method === "Profiler.setRecordingProfile") {
if (params.isProfiling)
stop();
} else if (method === "Profiler.addProfileHeader") {
getProfile(params.header.typeId, params.header.uid);
}
}

function stop()
{
chrome.experimental.debugger.sendRequest(tabId, "Profiler.stop");
}

function getProfile(type, uid)
{
chrome.experimental.debugger.sendRequest(tabId,
"Profiler.getProfile", {"type":type,"uid":uid}, response);
function response(profile)
{
console.log(profile);
}
}
</script>

masoomeh Rudafshani

unread,
Jun 11, 2011, 8:16:13 PM6/11/11
to Google Chrome Developer Tools
Hi Mikhail,

Thank you very much for your help. It's working now.

Masoomeh
> ...
>
> read more »

masoomeh Rudafshani

unread,
Jun 24, 2011, 10:21:39 AM6/24/11
to Google Chrome Developer Tools
Hi,
I'm about to process the heap profiler data, however, it's not
straightforward.
For example, from each snapshot, I'd like to get the number of
objects, retained size ( actually the same data that is show in
developer tool, but I need to access those data without a gui. I want
to process the result of getProfile and process it). Is there any idea
which part of code can be helpful?
I looked through the file HeapSnapshot.js, but as there is no comment,
it was hard to follow.
Do you have any idea?

Thanks,
Masoomeh

Mikhail Naganov

unread,
Jun 24, 2011, 10:32:05 AM6/24/11
to google-chrome-...@googlegroups.com, masoomeh....@gmail.com
Hi Masoomeh,

I'd advice you to use the following classes:

WebInspector.HeapSnapshotEdge
WebInspector.HeapSnapshotNode
WebInspector.HeapSnapshot

They provide a level of abstraction that is sufficient for most of the tasks.

Internally, heap snapshot is just a big array of heap nodes and edges.

You can look at the LayoutTests/inspector/profiler/heap-snapshot.html
test to get more insights.

masoomeh Rudafshani

unread,
Jul 4, 2011, 10:46:55 AM7/4/11
to Google Chrome Developer Tools
Hi,
The tests in LayoutTests/inspector/... gave me much insight. I was
wondering if there is anything similar for processing results of cpu
profiler or timeline data?

In addition, is there anything in chrome developer tools that give me
some information about CPU usage in total? I mean the CPU usage of a
whole page rather than the functions inside the pages?

Thanks,
Masoomeh

On Jun 24, 10:32 am, Mikhail Naganov <mnaga...@chromium.org> wrote:
> Hi Masoomeh,
>
> I'd advice you to use the following classes:
>
> WebInspector.HeapSnapshotEdge
> WebInspector.HeapSnapshotNode
> WebInspector.HeapSnapshot
>
> They provide a level of abstraction that is sufficient for most of the tasks.
>
> Internally, heap snapshot is just a big array of heap nodes and edges.
>
> You can look at the LayoutTests/inspector/profiler/heap-snapshot.html
> test to get more insights.
>
> On Fri, Jun 24, 2011 at 18:21, masoomeh Rudafshani
>

Mikhail Naganov

unread,
Jul 4, 2011, 5:03:25 PM7/4/11
to google-chrome-...@googlegroups.com
For CPU profiler, look at
LayoutTests/inspector/profiler/cpu-profiler-profiling* and
LayoutTests/fast/profiler (the latter tests are for JSC, but they use
the same API).
For timeline, there are LayoutTests/inspector/timeline tests.

What do you mean by "CPU usage of a whole page" -- parsing, rendering
and layout times? The only source currently is timeline (which doesn't
give CPU usage, only processing times).

masoomeh Rudafshani

unread,
Jul 4, 2011, 10:13:13 PM7/4/11
to Google Chrome Developer Tools
By "CPU usage of a whole page", I mean the same data that is provided
in CPU column of task manager. Are those data available using chrome
developer tools as well?
Thanks.

On Jul 4, 5:03 pm, Mikhail Naganov <mnaga...@chromium.org> wrote:
> For CPU profiler, look at
> LayoutTests/inspector/profiler/cpu-profiler-profiling* and
> LayoutTests/fast/profiler (the latter tests are for JSC, but they use
> the sameAPI).
> For timeline, there are LayoutTests/inspector/timeline tests.
>
> What do you mean by "CPU usage of a whole page" -- parsing, rendering
> and layout times? The only source currently is timeline (which doesn't
> give CPU usage, only processing times).
>
> On Mon, Jul 4, 2011 at 18:46, masoomeh Rudafshani
>

Mikhail Naganov

unread,
Jul 5, 2011, 1:17:45 AM7/5/11
to google-chrome-...@googlegroups.com
Unfortunately, not.

masoomeh Rudafshani

unread,
Jul 12, 2011, 6:23:41 PM7/12/11
to Google Chrome Developer Tools
Hi there,

I'm writing an extension using chrome remote debugging
functionalities. Inside the extension, I need to have access to a data
which is equivalent to WebInspector.mainResource? How can I determine
mainResource of a page inside my extension?

Thanks
Masoomeh

On Jul 5, 1:17 am, Mikhail Naganov <mnaga...@chromium.org> wrote:
> Unfortunately, not.
>
> On Tue, Jul 5, 2011 at 06:13, masoomeh Rudafshani
>

masoomeh Rudafshani

unread,
Jul 12, 2011, 6:23:48 PM7/12/11
to Google Chrome Developer Tools
Hi there,

I'm writing an extension using chrome remote debugging
functionalities. Inside the extension, I need to have access to a data
which is equivalent to WebInspector.mainResource? How can I determine
mainResource of a page inside my extension?

Thanks
Masoomeh

On Jul 5, 1:17 am, Mikhail Naganov <mnaga...@chromium.org> wrote:
> Unfortunately, not.
>
> On Tue, Jul 5, 2011 at 06:13, masoomeh Rudafshani
>

Andrey Kosyakov

unread,
Jul 13, 2011, 4:34:10 AM7/13/11
to google-chrome-...@googlegroups.com
Hi masoomeh,

You can have the URL of the main resource by examining parameters of Page.frameNavigated notification event: frame.parentId will be empty for the main resource and frame.url will provide you with the resource URL.
You'll need to maintain the map of URLs to resources that you populate either with Page.getResourceTree() or by listening for network events, depending on what information you need.

Best regards,
Andrey.

masoomeh Rudafshani

unread,
Jul 14, 2011, 10:30:56 AM7/14/11
to Google Chrome Developer Tools
Actually I need to process timeline records and I'm using the
TimelinePanel.js to help in processing data.
There is a variable called "WebInspector.mainResource.identifier"
inside the file which I need to access. Is it equal to the
Page.frame.id of the inspected page?



On Jul 13, 4:34 am, Andrey Kosyakov <ca...@chromium.org> wrote:
> Hi masoomeh,
>
> You can have the URL of the main resource by examining parameters of
> Page.frameNavigated notification event: frame.parentId will be empty for the
> main resource and frame.url will provide you with the resource URL.
> You'll need to maintain the map of URLs to resources that you populate
> either with Page.getResourceTree() or by listening for network events,
> depending on what information you need.
>
> Best regards,
> Andrey.
>
> On Wed, Jul 13, 2011 at 2:23 AM, masoomeh Rudafshani <
>
Message has been deleted

masoomeh Rudafshani

unread,
Jul 27, 2011, 11:57:13 AM7/27/11
to Google Chrome Developer Tools
Hi there,
Where can I get more documentation about chrome developer tools
internal design (I mean something with more details compared to the
one presented in Google I/O 2010).

Thanks,
Masoomeh

masoomeh Rudafshani

unread,
Jul 27, 2011, 11:47:51 PM7/27/11
to Google Chrome Developer Tools
In this page:
http://code.google.com/chrome/devtools/docs/remote-debugging.html
It is mentioned that "there are ways for third parties to bypass it
and start instrumenting browser pages explicitly". Can you please
explain how this instrumentation is done? Does this mean that the
instrumentation within the browser are activated or something is
injected into the page and instrument the page?

Thanks,


On Jul 27, 11:57 am, masoomeh Rudafshani
Reply all
Reply to author
Forward
0 new messages