From a7a06a483efbddfc84fa77bbb4e52bbc2cf1f4f9 Mon Sep 17 00:00:00 2001 From: Ryohei Ikegami Date: Wed, 7 Dec 2016 20:22:08 +0900 Subject: [PATCH 1/2] Record JavaScript calls in DevTools timeline on Node/ipc callback --- atom/common/node_bindings.cc | 11 +++++++++++ atom/renderer/atom_render_view_observer.cc | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index e869d2a7031c..25d9db4af9c3 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -17,6 +17,8 @@ #include "base/files/file_path.h" #include "base/message_loop/message_loop.h" #include "base/path_service.h" +#include "base/trace_event/trace_event.h" +#include "base/trace_event/trace_event_argument.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/content_paths.h" #include "native_mate/dictionary.h" @@ -239,8 +241,17 @@ void NodeBindings::UvRunOnce() { v8::MicrotasksScope script_scope(env->isolate(), v8::MicrotasksScope::kRunMicrotasks); + if (!is_browser_) + TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data", + std::unique_ptr( + new base::trace_event::TracedValue())); + // Deal with uv events. int r = uv_run(uv_loop_, UV_RUN_NOWAIT); + + if (!is_browser_) + TRACE_EVENT_END0("devtools.timeline", "FunctionCall"); + if (r == 0) message_loop_->QuitWhenIdle(); // Quit from uv. diff --git a/atom/renderer/atom_render_view_observer.cc b/atom/renderer/atom_render_view_observer.cc index 6ca8b3e1dc03..5e030b6285d6 100644 --- a/atom/renderer/atom_render_view_observer.cc +++ b/atom/renderer/atom_render_view_observer.cc @@ -18,6 +18,8 @@ #include "atom/renderer/atom_renderer_client.h" #include "base/command_line.h" #include "base/strings/string_number_conversions.h" +#include "base/trace_event/trace_event.h" +#include "base/trace_event/trace_event_argument.h" #include "content/public/renderer/render_view.h" #include "ipc/ipc_message_macros.h" #include "native_mate/dictionary.h" @@ -102,6 +104,9 @@ void AtomRenderViewObserver::EmitIPCEvent(blink::WebFrame* frame, v8::Local ipc; if (GetIPCObject(isolate, context, &ipc)) { + TRACE_EVENT1("devtools.timeline", "FunctionCall", "data", + std::unique_ptr( + new base::trace_event::TracedValue())); auto args_vector = ListValueToVector(isolate, args); // Insert the Event object, event.sender is ipc. mate::Dictionary event = mate::Dictionary::CreateEmpty(isolate); From 3796d7a6a1eb02421a6c87e869d48f88ca226eb0 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 12 Dec 2016 13:49:58 -0800 Subject: [PATCH 2/2] Use trace event with zero args --- atom/common/node_bindings.cc | 5 +---- atom/renderer/atom_render_view_observer.cc | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index 25d9db4af9c3..f97009f72b92 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -18,7 +18,6 @@ #include "base/message_loop/message_loop.h" #include "base/path_service.h" #include "base/trace_event/trace_event.h" -#include "base/trace_event/trace_event_argument.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/content_paths.h" #include "native_mate/dictionary.h" @@ -242,9 +241,7 @@ void NodeBindings::UvRunOnce() { v8::MicrotasksScope::kRunMicrotasks); if (!is_browser_) - TRACE_EVENT_BEGIN1("devtools.timeline", "FunctionCall", "data", - std::unique_ptr( - new base::trace_event::TracedValue())); + TRACE_EVENT_BEGIN0("devtools.timeline", "FunctionCall"); // Deal with uv events. int r = uv_run(uv_loop_, UV_RUN_NOWAIT); diff --git a/atom/renderer/atom_render_view_observer.cc b/atom/renderer/atom_render_view_observer.cc index 5e030b6285d6..edc7306b5df1 100644 --- a/atom/renderer/atom_render_view_observer.cc +++ b/atom/renderer/atom_render_view_observer.cc @@ -19,7 +19,6 @@ #include "base/command_line.h" #include "base/strings/string_number_conversions.h" #include "base/trace_event/trace_event.h" -#include "base/trace_event/trace_event_argument.h" #include "content/public/renderer/render_view.h" #include "ipc/ipc_message_macros.h" #include "native_mate/dictionary.h" @@ -104,9 +103,7 @@ void AtomRenderViewObserver::EmitIPCEvent(blink::WebFrame* frame, v8::Local ipc; if (GetIPCObject(isolate, context, &ipc)) { - TRACE_EVENT1("devtools.timeline", "FunctionCall", "data", - std::unique_ptr( - new base::trace_event::TracedValue())); + TRACE_EVENT0("devtools.timeline", "FunctionCall"); auto args_vector = ListValueToVector(isolate, args); // Insert the Event object, event.sender is ipc. mate::Dictionary event = mate::Dictionary::CreateEmpty(isolate);