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

Only create DebugModule where necessary. #654

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

jellefoks
Copy link
Member

Create a DebugModule only for the MainWebModule, so that there is no unnecessary waste observing messages which are then always discarded.

Add a command-line switch '--disable_web_debugger' that disables web debugger support completely, including the debug server.

b/287658692

@jellefoks
Copy link
Member Author

Friendly ping?

@kaidokert
Copy link
Member

Can you clarify what's the use case for this ? When would i use the added commandline flag ?

To be honest, i think we want to go in the opposite direction where most devtools are expected to be always available and included.

@jellefoks
Copy link
Member Author

Can you clarify what's the use case for this ? When would i use the added commandline flag ?

To be honest, i think we want to go in the opposite direction where most devtools are expected to be always available and included.

Before this CL, the DebugModule is otherwise instantiated for the MainWebModule, the SplashScreen, and the DebugModule, while it's actually only functional for the MainWebModule. That means that it's currently instantiating idle and non-functional ScriptDebugger delegate objects, including for example the LogAgent that itself registers to intercept all logging output (and which then in turn does nothing with the log callbacks besides wasting CPU and memory resources).

This became apparent when implementing the functionality to allow reception of Cobalt console log in the devtools, specifically where agents_state (from the DebuggerState, owned by the BrowserModule, so there is a single shared instance for the entire app) would be modified from different threads, resulting in unexpected state and potentially crashes.

(in progress, need a little cleanup): eb247fb

@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Merging #654 (a5fb789) into main (605a223) will decrease coverage by 0.37%.
Report is 1 commits behind head on main.
The diff coverage is 18.51%.

@@            Coverage Diff             @@
##             main     #654      +/-   ##
==========================================
- Coverage   56.88%   56.51%   -0.37%     
==========================================
  Files        1898     1898              
  Lines       94090    94096       +6     
==========================================
- Hits        53522    53181     -341     
- Misses      40568    40915     +347     
Files Changed Coverage Δ
cobalt/browser/switches.cc 0.00% <0.00%> (ø)
cobalt/browser/web_module.h 100.00% <ø> (ø)
cobalt/renderer/backend/egl/graphics_system.cc 58.87% <ø> (-0.76%) ⬇️
cobalt/script/v8c/v8c_script_debugger.cc 0.00% <ø> (-41.75%) ⬇️
cobalt/script/v8c/v8c_script_debugger.h 0.00% <0.00%> (-66.67%) ⬇️
cobalt/browser/web_module.cc 38.68% <20.83%> (-0.75%) ⬇️

... and 26 files with indirect coverage changes

@kaidokert
Copy link
Member

kaidokert commented Jul 12, 2023

This became apparent when implementing the functionality to allow reception of Cobalt console log in the devtools, specifically where agents_state (from the DebuggerState, owned by the BrowserModule, so there is a single shared instance for the entire app) would be modified from different threads, resulting in unexpected state and potentially crashes.

Yep, okay - if it gets in the way and causes more instability in QA builds that are used for most testing, and doesn't work in other modules anyway, it should indeed be disabled.

But still - does a new commandline flag add any extra value here ? Unsure why we'd want that. Otherwise changes look okay - but please have @sherryzy or @aee-google do a bit more closer look as well.

@jellefoks
Copy link
Member Author

This became apparent when implementing the functionality to allow reception of Cobalt console log in the devtools, specifically where agents_state (from the DebuggerState, owned by the BrowserModule, so there is a single shared instance for the entire app) would be modified from different threads, resulting in unexpected state and potentially crashes.

Yep, okay - if it gets in the way and causes more instability in QA builds that are used for most testing, and doesn't work in other modules anyway, it should indeed be disabled.

But still - does a new commandline flag add any extra value here ? Unsure why we'd want that. Otherwise changes look okay - but please have @sherryzy or @aee-google do a bit more closer look as well.

I added the command-line flag because 1) it was a simple change, and 2) in the past I have manually disabled the debug module often by editing code to be able to debug things happening in the MainWebModule without being distracted by the same code running for the DebugConsoleWebModule thread.

Chrome has a similar '--disable-dev-tools' switch.

@jellefoks jellefoks force-pushed the debugger_control branch 3 times, most recently from 226968f to 826d9f3 Compare July 25, 2023 23:39
Create a DebugModule only for the MainWebModule, so that there is no
unnecessary waste observing messages which are then always discarded.

Add a command-line switch '--disable_web_debugger' that disables web
debugger support completely, including the debug server.

b/287658692
@sherryzy
Copy link
Contributor

Well, adding this extra command line switch does bring some extra complexity to the code, but I don't know if there a better way to do it. I trust your judgement here. Overall, the code looks good to me.

@sherryzy sherryzy self-requested a review July 26, 2023 18:16
@jellefoks jellefoks merged commit df40dfd into youtube:main Jul 26, 2023
347 of 349 checks passed
@jellefoks jellefoks added the cp-24.lts.1+ Cherry Pick to the 24.lts.1+ branch label Jul 31, 2023
cobalt-github-releaser-bot pushed a commit that referenced this pull request Jul 31, 2023
Create a DebugModule only for the MainWebModule, so that there is no
unnecessary waste observing messages which are then always discarded.

Add a command-line switch '--disable_web_debugger' that disables web
debugger support completely, including the debug server.

b/287658692

(cherry picked from commit df40dfd)
jellefoks added a commit that referenced this pull request Jul 31, 2023
Refer to the original PR: #654

Create a DebugModule only for the MainWebModule, so that there is no
unnecessary waste observing messages which are then always discarded.

Add a command-line switch '--disable_web_debugger' that disables web
debugger support completely, including the debug server.

b/287658692

Co-authored-by: Jelle Foks <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cp-24.lts.1+ Cherry Pick to the 24.lts.1+ branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants