New issue
Advanced search Search tips

Issue 661705 link

Starred by 7 users

Issue metadata

Status: Fixed
Owner:
Closed: Jan 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Feature



Sign in to add a comment

DevTools: Add async stacks support for channel API

Project Member Reported by lushnikov@chromium.org, Nov 2 2016

Issue description

As per requested by user in  crbug.com/272416#c79 :

------

Please add async support for Channel API[1]. 

Channel is currently used by default implementation of goog.async.nextTick[2] in Google Closure Library. We've grown to depend on it heavily in ClojureScript. For example popular core.async[3] library uses it internally to chain async operations.

I tried to work-around this limitation and monkey-patch goog.async.nextTick with a promise-based replacement[4]. It works technically, but the problem is that promises have slightly different timing characteristics (micro-tasks vs. tasks) and that caused issues for some[5].

Thanks for consideration.

[1] https://developer.mozilla.org/en-US/docs/Web/API/Channel_Messaging_API
[2] https://github.com/google/closure-library/blob/fd043939bde2de4cd0dae9272e3336fbc5f66962/closure/goog/async/nexttick.js#L217
[3] https://github.com/clojure/core.async
[4] https://github.com/binaryage/cljs-devtools/blob/master/docs/faq.md#what-is-the-async-feature
[5] https://github.com/binaryage/cljs-devtools/issues/20#issuecomment-257399432
 
Thank you.

Please note that we don't need complete support for async stacks support across different js-contexts (that might not even make sense). Closure Library does the trick of posting a message to itself. This way they achieve setTimeout-like behaviour but without the 4ms delay.

I want you to detect this special case and apply async stacks tagging there. Similar to window.postMessage.
Owner: kozy@chromium.org
Project Member

Comment 3 by bugdroid1@chromium.org, Nov 29 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/c30472b83e0c8ce92fa12810b173bf0079fb6da5

commit c30472b83e0c8ce92fa12810b173bf0079fb6da5
Author: Alexey Kozyatinskiy <kozyatinskiy@chromium.org>
Date: Wed Nov 29 23:29:55 2017

[inspector] external stack intrumentation can be called on one debugger

Some embedders primitive can trigger execution in current JavaScript
instance or in another (e.g. MessageChannel).
With this CL external async task can be local as well.

R=dgozman@chromium.org

Bug:  chromium:661705 
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I82c68a021c2c25bc67a706c4bfed8c1a2b2388c5
Reviewed-on: https://chromium-review.googlesource.com/792015
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49728}
[modify] https://crrev.com/c30472b83e0c8ce92fa12810b173bf0079fb6da5/src/inspector/v8-debugger-agent-impl.cc
[modify] https://crrev.com/c30472b83e0c8ce92fa12810b173bf0079fb6da5/src/inspector/v8-debugger-agent-impl.h
[modify] https://crrev.com/c30472b83e0c8ce92fa12810b173bf0079fb6da5/src/inspector/v8-debugger.cc
[modify] https://crrev.com/c30472b83e0c8ce92fa12810b173bf0079fb6da5/src/inspector/v8-debugger.h
[modify] https://crrev.com/c30472b83e0c8ce92fa12810b173bf0079fb6da5/test/inspector/debugger/external-stack-trace.js
[add] https://crrev.com/c30472b83e0c8ce92fa12810b173bf0079fb6da5/test/inspector/debugger/step-into-external-async-task-same-context-expected.txt
[add] https://crrev.com/c30472b83e0c8ce92fa12810b173bf0079fb6da5/test/inspector/debugger/step-into-external-async-task-same-context.js

Project Member

Comment 4 by bugdroid1@chromium.org, Jan 13 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/08e2be9a29ceeafdd89be831c20c160e7ca4b81d

commit 08e2be9a29ceeafdd89be831c20c160e7ca4b81d
Author: Alexey Kozyatinskiy <kozyatinskiy@chromium.org>
Date: Sat Jan 13 01:57:04 2018

[DevTools] instrumented MessageChannel

We need async stacks instrumentation for MessageChannel.postMessage.
To achieve this goal we capture stack trace at postMessage call and
send stack trace id to another iframe where is stack trace id is
used as async tail of current stack trace inside onmessage handler.

With instrumentation DevTools can trace onmessage handler to the
corresponded postMessage call inside another frame and it is possible
to make step-into action to go directly into onmessage handler from
postMessage call.

R=alph@chromium.org

Bug:  chromium:661705 
Change-Id: If4a8cd3a94f914a091b351c1607e5fd16b739b23
Reviewed-on: https://chromium-review.googlesource.com/792499
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Alexei Filippov <alph@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#529142}
[add] https://crrev.com/08e2be9a29ceeafdd89be831c20c160e7ca4b81d/third_party/WebKit/LayoutTests/inspector-protocol/debugger/message-channel-async-stack-expected.txt
[add] https://crrev.com/08e2be9a29ceeafdd89be831c20c160e7ca4b81d/third_party/WebKit/LayoutTests/inspector-protocol/debugger/message-channel-async-stack.js
[modify] https://crrev.com/08e2be9a29ceeafdd89be831c20c160e7ca4b81d/third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp
[modify] https://crrev.com/08e2be9a29ceeafdd89be831c20c160e7ca4b81d/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp
[modify] https://crrev.com/08e2be9a29ceeafdd89be831c20c160e7ca4b81d/third_party/WebKit/Source/core/inspector/ThreadDebugger.h
[modify] https://crrev.com/08e2be9a29ceeafdd89be831c20c160e7ca4b81d/third_party/WebKit/Source/core/messaging/BlinkCloneableMessage.h
[modify] https://crrev.com/08e2be9a29ceeafdd89be831c20c160e7ca4b81d/third_party/WebKit/Source/core/messaging/BlinkCloneableMessageStructTraits.cpp
[modify] https://crrev.com/08e2be9a29ceeafdd89be831c20c160e7ca4b81d/third_party/WebKit/Source/core/messaging/BlinkCloneableMessageStructTraits.h
[modify] https://crrev.com/08e2be9a29ceeafdd89be831c20c160e7ca4b81d/third_party/WebKit/Source/core/messaging/MessagePort.cpp
[modify] https://crrev.com/08e2be9a29ceeafdd89be831c20c160e7ca4b81d/third_party/WebKit/common/message_port/cloneable_message.h
[modify] https://crrev.com/08e2be9a29ceeafdd89be831c20c160e7ca4b81d/third_party/WebKit/common/message_port/cloneable_message_struct_traits.cc
[modify] https://crrev.com/08e2be9a29ceeafdd89be831c20c160e7ca4b81d/third_party/WebKit/common/message_port/cloneable_message_struct_traits.h
[modify] https://crrev.com/08e2be9a29ceeafdd89be831c20c160e7ca4b81d/third_party/WebKit/common/message_port/message_port.mojom

Comment 5 by kozy@chromium.org, Jan 13 2018

Status: Fixed (was: Assigned)

Sign in to add a comment