-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
inspector: overhaul JS binding implementation #15643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Sorry, I am not familiar with the AsyncWrap. One of the essential requirements for the inspector API is to be able to send messages (and receive responses) while V8 is suspended. Will AsyncWrap work in this scenario? |
src/inspector_agent.cc
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this still needs to be reset in the destructor? It doesn’t happen automatically when ~Persistent() is called, unfortunately…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice spot! It does indeed lead to a memory leak.
This only changes the code for the inspector JS bindings, so I don’t think that is an issue? The code in this PR calls into JS at the same times when there were calls into JS before. |
src/inspector_agent.cc
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can leave these out, they are indirectly included by node_internals anyway :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look like that is the case, unfortunately.
- Group all relevant methods/states into a C++ class. - Uses internal fields instead of the less efficient v8::External for storing the pointer to the C++ object. - Use AsyncWrap to allow instrumenting callback states. Refs: nodejs#13503
a6c4f41 to
6030094
Compare
|
CI: https://ci.nodejs.org/job/node-test-pull-request/10311/ Failures unrelated. |
trevnorris
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two style nits and one question about a #define. Nothing critical.
| Local<Function> callback) | ||
| : AsyncWrap(env, wrap, PROVIDER_INSPECTORJSBINDING), | ||
| delegate_(env, this), | ||
| callback_(env->isolate(), callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nit: mind changing the spacing of the initialization list to match that of NodeInspectorClient()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this was the predominant style for initializers, and I also prefer this style a bit more.
There are other places in the file where the initializer list is in this style. I'd be happy to make this consistent in a separate PR if you insist, but I think this change should get in now separated from stylistic changes..
| void SendMessageToFrontend(const v8_inspector::StringView& message) | ||
| override { | ||
| Isolate* isolate = env_->isolate(); | ||
| v8::HandleScope handle_scope(isolate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: no need for the v8::; already using v8::HandleScope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. This part of the code was just being moved around, but I'll fix it before landing.
| NODE_ASYNC_NON_CRYPTO_PROVIDER_TYPES(V) \ | ||
| NODE_ASYNC_CRYPTO_PROVIDER_TYPES(V) | ||
| NODE_ASYNC_CRYPTO_PROVIDER_TYPES(V) \ | ||
| NODE_ASYNC_INSPECTOR_PROVIDER_TYPES(V) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this end with a \?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, yes it should. Thanks for noticing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh oops, didn't realize it already had a \. I'd say it's good practice to always have a trailing backslash to reduce future diffs, but will remove.
PR-URL: nodejs#15643 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Group all relevant methods/states into a C++ class. - Uses internal fields instead of the less efficient v8::External for storing the pointer to the C++ object. - Use AsyncWrap to allow instrumenting callback states. PR-URL: nodejs#15643 Refs: nodejs#13503 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: nodejs/node#15643 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Group all relevant methods/states into a C++ class. - Uses internal fields instead of the less efficient v8::External for storing the pointer to the C++ object. - Use AsyncWrap to allow instrumenting callback states. PR-URL: nodejs/node#15643 Refs: nodejs/node#13503 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]>
|
ping re: backport |
Backport-PR-URL: nodejs#16071 PR-URL: nodejs#15643 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Group all relevant methods/states into a C++ class. - Uses internal fields instead of the less efficient v8::External for storing the pointer to the C++ object. - Use AsyncWrap to allow instrumenting callback states. Backport-PR-URL: nodejs#16071 PR-URL: nodejs#15643 Refs: nodejs#13503 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]>
Backport-PR-URL: #16071 PR-URL: #15643 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Group all relevant methods/states into a C++ class. - Uses internal fields instead of the less efficient v8::External for storing the pointer to the C++ object. - Use AsyncWrap to allow instrumenting callback states. Backport-PR-URL: #16071 PR-URL: #15643 Refs: #13503 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: James M Snell <[email protected]>
|
Should this be backported to |
The first two commits of this PR are identical to #14710. However, the last two commits fixed the GC problem pointed out by @bnoordhuis in #14710 (review), and makes
Connectionan AsyncWrap for async hooks support.With
and appropriate async hooks, whereas before this PR it looked like
after it
with proper instrumentation.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
inspector