Skip to content
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

Add the V8 Inspector API #57

Merged
merged 24 commits into from
Sep 18, 2023
Merged

Add the V8 Inspector API #57

merged 24 commits into from
Sep 18, 2023

Conversation

iddm
Copy link
Collaborator

@iddm iddm commented Sep 4, 2023

Adds the V8 Inspector wrapper and the Rust-idiomatic code to interact
with one from C++.
Also provides a WebSocket server for easier establishing the
remote debugging sessions.

@iddm iddm self-assigned this Sep 4, 2023
@iddm iddm changed the title Draft: Add inspector api Add the V8 Inspector API Sep 5, 2023
Copy link
Contributor

@MeirShpilraien MeirShpilraien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vityafx great feature that I believe will be widely used.
I added comments on the review itself and I have some general comments as well:

  1. I think it would be nice to summerise the new API on this PR on the top comment with explanation on each API, why it was created and how it should be used. I believe it would have made the review part easier and would probably spare some of the questions I asked.
  2. I believe we should consider the API safety property. I understand that if we bind the inspector lifetime to the inspector it will be very hard for the user to use it. But I still believe we should come up with a safer API that will not allow using the inspector without been entered to the isolate and if possible make sure its the right isolate. I already suggested having an inspector guard but I would like to know if you maybe have other ideas.
  3. I am not follow why, in general, we need to use Mutex and Arc/Rc on this PR. Can you please explain why it is needed? (maybe cover it on the top comment so we will have it documented?)
  4. I would avoid saving pointers to isolate/context as much as possible (if possible). And if it is mandatory to save them, I would avoid exposing them back for safety reasons.
  5. I believe it will be easier for user to get an API that except closures (using generics) instead of boxes, we can use boxes internally where we need to.

Copy link
Contributor

@MeirShpilraien MeirShpilraien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 few last comments and some few comments that was left open.

Adds the V8 Inspector wrapper and the Rust-idiomatic code to interact
with one from C++.
Also provides with a WebSocket server for easier establishing of the
remote debugging sessions.
Makes it is safer to use the dispatch_protocol_message and
schedule_pause_on_next_statement methods of the Inspector API.

The only requirement for these methods is that the strings passed do not
contain NUL symbols in Rust, and in C++ those must contain a valid JSON
object (stringified).
This allows the data to leak from Rust, moving the responsibility of
managing the objects to C++.
Makes the isolate stored instead.
This removes all the assumptions for the users to make about what it
needs for correct operation.
Helps with the correct usage of the APIs.
This moves some of the functionality of the Inspector struct to the new
InspectorGuard struct, objects of which may only be created when the
isolate scope passed is for the same isolate this Inspector object was
created with. This is done to make sure that the APIs which rely on the
isolate and the corresponding HandleScope are correctly used.
Copy link
Contributor

@MeirShpilraien MeirShpilraien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Great work

@iddm iddm merged commit 12ef635 into master Sep 18, 2023
2 checks passed
@iddm iddm deleted the add-inspector-api branch September 18, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants