NativeScript / android

NativeScript for Android using v8
https://docs.nativescript.org/guide/android-marshalling
Apache License 2.0
519 stars 135 forks source link

Restore Console inspector for V8 10.3 #1751

Closed ptomato closed 1 year ago

ptomato commented 1 year ago

Description

This PR updates the V8 inspector headers on the 10.3 branch to the correct headers from V8 10.3, removes ones that are no longer part of V8, and moves NativeScript-specific ones out of the V8 folders so they don't accidentally get deleted when updating V8 sources in the future.

The PR adds the inspector functionality back in, which was removed in the V8 update. Most of the inspector agents are commented out or not compiled, but this re-implements the Console inspector using the CRDTP's Runtime protocol. (It was previously implemented using the Log protocol, which is no longer part of V8.)

This is a huge pull request, but most of it is just V8 header updates. I'd recommend reviewing it commit by commit. Each commit message has a description of what is going on in that commit.

Related Pull Requests

Does your pull request have unit tests?

No unit tests. (I'm not sure how to test the integration between runtime and Chrome devtools in an automated way.) Here's my steps for testing this:

Screenshot from 2023-02-27 17-38-07

rigor789 commented 1 year ago

Just had a chance to run this PR and it's looking good!🎉 I was able to add logs of different kinds and see them in the Chrome console as well as jump to source.

I did run into a few issues I'll note here:

Typing into the Chrome console crashes the app (as it tries to evaluate an expression). To reproduce: - attach the Chrome Debugger - type `g` in the console (for example) - app will crash (or stop if the Android Studio debugger is attached) ![image](https://user-images.githubusercontent.com/879060/223405269-a6250cb9-99fd-4779-8853-121ddf046fa3.png)
Another crash I occasionally saw was related to expanding a (native) object I logged to the console. In this particular case I added the following logs to the test app: ```js // MyActivity.js // ... line 54-ish ... button.setOnClickListener( new android.view.View.OnClickListener("AppClickListener", { onClick: function () { button.setBackgroundColor(colors[taps % colors.length]); taps++; // added these to test... console.log("string message"); console.warn("warning!"); console.trace("trace"); console.error("oh no", new Error()); console.info("info!"); console.dir(Color); console.log({ object: "yay!", }); }, }) ); ``` Expanding the `Color` object in the Chrome console occasionally crashes. Since the test-app runs all the runtime unit-tests this might be an edge case when expanding the details during a particular test where v8 might be running on another thread (workers) or something similar. I wasn't able to identify a clear pattern of when this crash occurs, and it's fairly hard to consistently reproduce.
ptomato commented 1 year ago

Thanks for the testing! I've fixed the crash when typing into the Chrome console, and updated this branch. I haven't managed to reproduce the other one yet.