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

Chrome error -32000 browser window not found #193

Open
gadenbuie opened this issue Jan 21, 2025 · 13 comments
Open

Chrome error -32000 browser window not found #193

gadenbuie opened this issue Jan 21, 2025 · 13 comments

Comments

@gadenbuie
Copy link
Member

I can't seem to solve the problem, on Arch Linux.
chromote 0.3.1.9000
renderthis 0.2.1
I have the latest chromium and chrome installed. My .Rprofile includes options(chromote.headless = "new") and I did export CHROMOTE_HEADLESS=new.
Anytime I call to_pdf() I get

Error in callback(...) : code: -32000 message: Browser window not found
I did check and I am able to start a headless browser, just like shown at https://github.com/rstudio/chromote.

Any help appreciated.

Originally posted by @jorgetendeiro in #187

@gadenbuie
Copy link
Member Author

SeleniumHQ/selenium#12889 (comment) suggests that this is a Chrome bug that may be fixed by including --remote-debugging-pipe.

Can you try this?

library(chromote)

old_chrome_args <- get_chrome_args()
set_chrome_args(c("--remote-debugging-pipe", old_chrome_args)

# ... the rest of your code ...

@jorgetendeiro
Copy link

I tried, it did not work.
Here's my code, run right after starting RStudio (no related code loaded from .Rprofile):

library(chromote)
options(chromote.headless = "new")
old_chrome_args <- get_chrome_args()
set_chrome_args(c("--remote-debugging-pipe", old_chrome_args))
renderthis::to_pdf("Lecture1.html", partial_slides = TRUE)

Output:

Error in with_random_port():
! Cannot find an available port. Please try again.
Caused by error in startup():
! object 'verify' not found
Run rlang::last_trace() to see where the error occurred.

rlang::last_trace()
<error/error_no_available_port>
Error in with_random_port():
! Cannot find an available port. Please try again.
Caused by error in startup():
! object 'verify' not found
Backtrace:
└─renderthis::to_pdf("Lecture12.html", partial_slides = TRUE)
└─renderthis:::to_pdf_complex(...)
└─chromote::ChromoteSession$new()
└─chromote (local) initialize(...)
└─chromote::default_chromote_object()
├─chromote::set_default_chromote_object(Chromote$new())
└─Chromote$new()
└─chromote (local) initialize(...)
└─Chrome$new()
└─chromote (local) initialize(...)
└─chromote:::launch_chrome(path, args)
└─chromote:::with_random_port(launch_chrome_impl, path = path, args = args)
Run rlang::last_trace(drop = FALSE) to see 1 hidden frame.

I did install the dev version of chromote (0.3.1.9000).

@gadenbuie
Copy link
Member Author

That's interesting. The good news is it's a different error message, which means the command I suggested likely did work but uncovered another error, which might be in the renderthis package. Does this error happen with just this file or with any file you try on your computer?

@jorgetendeiro
Copy link

It happens to all files (all xaringan lectures).

@gadenbuie
Copy link
Member Author

Oh I see the issue (fixed in e905638). Can you please update chromote again and try again? I suspect it will still fail but you'll at least get an error message (which actually might be the same -32000 error).

@jorgetendeiro
Copy link

jorgetendeiro commented Jan 22, 2025

OK, I removed and reinstalled chromote from dev (0.3.1.9000).

> library(chromote)
> options(chromote.headless = "new")
> old_chrome_args <- get_chrome_args()
> set_chrome_args(c("--remote-debugging-pipe", old_chrome_args))
> renderthis::to_pdf("Lecture1.html", partial_slides = TRUE)
Error in `with_random_port()`:
! Cannot find an available port. Please try again.
Caused by error in `startup()`:
! Failed to start chrome. Chrome is available on your system, so this error may be a configuration issue. Try `chromote_info()` to check and verify your settings. 
Log file: /tmp/RtmpQR5dZR/chrome-64d57063a373-stderr.log
Error:
[0122/113607.071162:ERROR:chrome_main_delegate.cc(1202)] Remote debugging pipe file descriptors are not open.
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/error_no_available_port>
Error in `with_random_port()`:
! Cannot find an available port. Please try again.
Caused by error in `startup()`:
! Failed to start chrome. Chrome is available on your system, so this error may be a configuration issue. Try `chromote_info()` to check and verify your settings. 
Log file: /tmp/RtmpQR5dZR/chrome-64d57063a373-stderr.log
Error:
[0122/113607.071162:ERROR:chrome_main_delegate.cc(1202)] Remote debugging pipe file descriptors are not open.
---
Backtrace:
     ▆
  1. └─renderthis::to_pdf("Lecture1.html", partial_slides = TRUE)
  2.   └─renderthis:::to_pdf_complex(...)
  3.     └─chromote::ChromoteSession$new()
  4.       └─chromote (local) initialize(...)
  5.         └─chromote::default_chromote_object()
  6.           ├─chromote::set_default_chromote_object(Chromote$new())
  7.           └─Chromote$new()
  8.             └─chromote (local) initialize(...)
  9.               └─Chrome$new()
 10.                 └─chromote (local) initialize(...)
 11.                   └─chromote:::launch_chrome(path, args)
 12.                     └─chromote:::with_random_port(launch_chrome_impl, path = path, args = args)
Run rlang::last_trace(drop = FALSE) to see 1 hidden frame.

Furthermore:

> chromote::chromote_info()
Error in get_chrome_args() : 
  lazy-load database '/home/me/R/x86_64-pc-linux-gnu-library/4.4/chromote/R/chromote.rdb' is corrupt
In addition: Warning message:
In get_chrome_args() : internal error -3 in R_decompress1

Sorry about the code tags, not working so well.

@gadenbuie
Copy link
Member Author

lazy-load database '/home/me/R/x86_64-pc-linux-gnu-library/4.4/chromote/R/chromote.rdb' is corrupt

This error happens when you re-install a package that was likely already loaded in the R session. If you restart your R session and try chromote::chromote_info() again, it should go away.

After some more internet searches, I don't think --remote-debug-pipe is going to help fix your issue. Can you restart your R session and run your original code again? Then copy and paste the error message again.

Sidenote: to add sections of code to a GitHub issue, use this kind of markdown:

```
# ... your code here ...
```

@jorgetendeiro
Copy link

OK, here it goes:

Input:

remove.packages("chromote")
# Closed RStudio, restarted, then:
remotes::install_github("rstudio/chromote")
library(chromote)
options(chromote.headless = "new")
old_chrome_args <- get_chrome_args()
set_chrome_args(c("--remote-debugging-pipe", old_chrome_args))
chromote::chromote_info()

Output:

---- {chromote} ----
   System: x86_64-pc-linux-gnu
R version: R version 4.4.2 (2024-10-31)
 chromote: 0.3.1.9000

---- Chrome ----
   Path: /usr/bin/google-chrome-stable
Version: Google Chrome 132.0.6834.83
   Args: --headless=new --remote-debugging-pipe --force-color-profile=srgb --disable-extensions
         --mute-audio

Input:

renderthis::to_pdf("Lecture01.html", partial_slides = TRUE)

Output:

Error in `with_random_port()`:
! Cannot find an available port. Please try again.
Caused by error in `startup()`:
! Failed to start chrome. Chrome is available on your system, so this error may be a configuration issue. Try `chromote_info()` to check and verify your settings. 
Log file: /tmp/Rtmphdf3Hx/chrome-8e9a3da8efc4-stderr.log
Error:
[0122/134233.565487:ERROR:chrome_main_delegate.cc(1202)] Remote debugging pipe file descriptors are not open.
Run `rlang::last_trace()` to see where the error occurred.

Input:

rlang::last_trace()

Output:

<error/error_no_available_port>
Error in `with_random_port()`:
! Cannot find an available port. Please try again.
Caused by error in `startup()`:
! Failed to start chrome. Chrome is available on your system, so this error may be a configuration issue. Try `chromote_info()` to check and verify your settings. 
Log file: /tmp/Rtmphdf3Hx/chrome-8e9a3da8efc4-stderr.log
Error:
[0122/134233.565487:ERROR:chrome_main_delegate.cc(1202)] Remote debugging pipe file descriptors are not open.
---
Backtrace:
     ▆
  1. └─renderthis::to_pdf("Lecture01.html", partial_slides = TRUE)
  2.   └─renderthis:::to_pdf_complex(...)
  3.     └─chromote::ChromoteSession$new()
  4.       └─chromote (local) initialize(...)
  5.         └─chromote::default_chromote_object()
  6.           ├─chromote::set_default_chromote_object(Chromote$new())
  7.           └─Chromote$new()
  8.             └─chromote (local) initialize(...)
  9.               └─Chrome$new()
 10.                 └─chromote (local) initialize(...)
 11.                   └─chromote:::launch_chrome(path, args)
 12.                     └─chromote:::with_random_port(launch_chrome_impl, path = path, args = args)
Run rlang::last_trace(drop = FALSE) to see 1 hidden frame.

@gadenbuie
Copy link
Member Author

gadenbuie commented Jan 22, 2025

Sorry @jorgetendeiro, I meant to run the code without adding the --remote-debugging-pipe, specifically this:

chromote::chromote_info()
renderthis::to_pdf("Lecture01.html", partial_slides = TRUE)

@jorgetendeiro
Copy link

I see.

For good measure, I again uninstalled chromote, closed and restarted RStudio, then reinstalled the dev version. I'm on a different desktop, also on Linux, up to date (same recent issues with renderthis). For some reason, on this desktop chromote looks for chromium whereas on my other desktop it looks for chrome. The net effect is similar on both machines, though:

> chromote::chromote_info()
---- {chromote} ----
   System: x86_64-pc-linux-gnu
R version: R version 4.4.2 (2024-10-31)
 chromote: 0.3.1.9000

---- Chrome ----
   Path: /usr/bin/chromium
Version: Chromium 132.0.6834.83 Arch Linux
   Args: --headless --force-color-profile=srgb --disable-extensions --mute-audio
> renderthis::to_pdf("Lecture01.html", partial_slides = TRUE)
Error in callback(...) : code: -32000
  message: Browser window not found

@gadenbuie
Copy link
Member Author

Thanks! Does rlang::last_trace() give any more information with this error?

@jorgetendeiro
Copy link

No, unfortunately:

> rlang::last_trace()
Error: Can't show last error because no error was recorded yet

@jorgetendeiro
Copy link

For the record, I found a new tool (for me). It works in Linux and apparently in Windows too (did not try): decktape. Like this:

decktape --chrome-path=/usr/bin/google-chrome-stable --headless=true remark "file:///path/to/Lecture01.html#1" output.pdf

the PDF takes longer to load, unsure why.
For now I'll use this until renderthis is back to normal.

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

No branches or pull requests

2 participants