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

Slowness: Every call to browser takes at least 100ms #446

Open
jeromerobert opened this issue Jan 4, 2024 · 1 comment
Open

Slowness: Every call to browser takes at least 100ms #446

jeromerobert opened this issue Jan 4, 2024 · 1 comment

Comments

@jeromerobert
Copy link

Sending a message to the browser always takes 100ms. This is because this lock:
https://github.com/rust-headless-chrome/rust-headless-chrome/blob/v1.0.8/src/browser/transport/web_socket_connection.rs#L162
is always waiting for this lock:
https://github.com/rust-headless-chrome/rust-headless-chrome/blob/v1.0.8/src/browser/transport/web_socket_connection.rs#L80
which almost always last for 100ms because of:
https://github.com/rust-headless-chrome/rust-headless-chrome/blob/v1.0.8/src/browser/transport/web_socket_connection.rs#L153

Most Tab methods needs to do multiple calls to the browser so they last for 200ms to 600ms.

dispatch_incoming_messages should not keep the lock while it has nothing to read.

Changing READ_TIMEOUT_DURATION from 100ms to 1ms make Element::click run in 50ms instead of 500ms. I do not submit a PR because I'm not sure that it's good to do that.

According to snapview/tungstenite-rs#378 it would also be possible to use non blocking socket but again I'm not sure it's good.

A not disruptive and easy change would be to let the user change the READ_TIMEOUT_DURATION value.

@Gitigi
Copy link

Gitigi commented May 20, 2024

Am facing the same issue, calling new_tab takes 400ms, I was previously using chromedp written in golang and it doesn't take that long to create a tab

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