Skip to content

feat: Add chromote_info()#190

Merged
gadenbuie merged 20 commits into
mainfrom
feat/chromote-info
Jan 17, 2025
Merged

feat: Add chromote_info()#190
gadenbuie merged 20 commits into
mainfrom
feat/chromote-info

Conversation

@gadenbuie

@gadenbuie gadenbuie commented Jan 16, 2025

Copy link
Copy Markdown
Member

Fixes #181
Fixes #182

Adds a chromote_info() helper function that's sort of like session_info(). The goal is to serve as a useful starting place as a compliment to session_info().

> chromote_info()
---- {chromote} ----
   System: aarch64-apple-darwin20
R version: R version 4.4.2 (2024-10-31)
 chromote: 0.3.1.9000

---- Chrome ----
   Path: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Version: Google Chrome 131.0.6778.265
   Args: --headless=foo --force-color-profile=srgb
         --disable-extensions --mute-audio

The formatting is bare-bones but pretty and inclusive enough to be useful.

TODO

@gadenbuie gadenbuie marked this pull request as ready for review January 16, 2025 21:18
Base automatically changed from fix/187-old-headless-mode-is-gone to main January 16, 2025 21:42
Comment thread R/chrome.R
Comment on lines +102 to +109
chrome_verify <- function(path = find_chrome()) {
processx::run(
command = path,
args = c("--headless", "--version"),
timeout = 2,
error_on_status = FALSE
)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this works reliably on Mac ?

On windows, it seems this does open a new chrome process in the background and do not close it.

I did not find a way to get the chrome version easily without doing that, but process handling was getting tricky...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, right now I get this:

chromote:::chrome_verify()
#> $status
#> [1] 0
#> 
#> $stdout
#> [1] "Google Chrome 131.0.6778.265 \n"
#> 
#> $stderr
#> [1] ""
#> 
#> $timeout
#> [1] FALSE

and when I force chrome_verify() to test a non-Chrome binary, it correctly kills the process after 2 seconds.

I'll try updating to Chrome v132 to see if this changes anything.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

After updating, I also get this which seems to be working correctly (doesn't increase the number of running Chrome processes after running the command)

chromote:::chrome_verify()
#> $status
#> [1] 0
#> 
#> $stdout
#> [1] "Google Chrome 132.0.6834.84 \n"
#> 
#> $stderr
#> [1] ""
#> 
#> $timeout
#> [1] FALSE

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@cderv on Windows do you think I should still do this? Or should I short-circuit with a message to open Chrome to verify the version? In chromote, I'm only using this for additional information as a user convenience, I haven't inserted this verification on any critical paths.

@cderv cderv Jan 17, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In fact, it fails on windows

> chromote:::chrome_verify()
$status
[1] 2

$stdout
[1] ""

$stderr
[1] "[56636:40396:0117/170723.416:ERROR:cloud_policy_validator.cc(614)] New signature verification failed\r\n"

$timeout
[1] TRUE

> chromote::find_chrome()
[1] "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"

On terminal, I do get the same, but it starts chrome in background too

❯ & "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" --headless --version
[6168:51448:0117/170903.185:ERROR:cloud_policy_validator.cc(614)] New signature verification failed
  • other message as full Chrome Started

It works ok with a proper headless browser in old mode

❯ chrome-headless-shell.exe --headless --version
Google Chrome for Testing 132.0.6834.83

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I updated chrome_verify() on Windows to simply check the presence of the binary and to use wmic to find the Chrome version, rather than starting up any external processes. See 8bc8812 and 7f82fb2

@gadenbuie gadenbuie merged commit bba5e53 into main Jan 17, 2025
@gadenbuie gadenbuie deleted the feat/chromote-info branch January 17, 2025 20:54
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.

Add chromote::chromote_info() similar to devtools::session_info() Add chrome path validity check

2 participants