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

unexpected performance impact on devtools console method #1442

Open
meltfar opened this issue Feb 18, 2024 · 0 comments
Open

unexpected performance impact on devtools console method #1442

meltfar opened this issue Feb 18, 2024 · 0 comments

Comments

@meltfar
Copy link

meltfar commented Feb 18, 2024

What versions are you running?

$ go list -m github.com/chromedp/chromedp
github.com/chromedp/chromedp v0.9.5
$ google-chrome --version
Version 1.63.157 Chromium: 122.0.6261.43 (Official Build)  (64-bit)
$ go version
go version go1.20.4 windows/amd64

What did you do? Include clear steps.

        ctx, _ := chromedp.NewRemoteAllocator(context.Background(), "ws://127.0.0.1:9222")
	ctx, _ = chromedp.NewContext(ctx)

	if err := chromedp.Run(ctx,
		network.Enable(),
		log.Disable(),
		css.Disable(),
		inspector.Disable(),
		chromedp.Navigate("https://blog.aepkill.com/demos/devtools-detector/"),
		chromedp.Sleep(time.Second*3),
		chromedp.Evaluate(`const btn = document.createElement('button'); btn.textContent = "click me!"; btn.id = 'btn'; document.body.appendChild(btn); btn.onclick=function () {const v1 = document.createElement('div'); v1.textContent = 'v1'; document.body.appendChild(v1)}`, nil),
		chromedp.Sleep(time.Second*5),
		chromedp.Click("#btn", chromedp.ByQuery),
	); err != nil {
		panic(err)
	}

What did you expect to see?

Keeping devtools page closed, so that devtools shouldn't be detected. The page should shown as "Devtools: close".

What did you see instead?

Devtools can be detected as opened while actually not, especially when chromedp.Sleep running.
The page shows that Devtools Opens because of performance impact.

Description

I was very curious about this strange performance issue. By running the code above, the webpage shows the browser with devtools page opening, which was because it detected a performance impact on console.log, console.table or largeArrayCreation within its code. But that should not happen.

I have also check with a python port of cdp client, with the same behaviours as nivagating, sleeping, executing js code and finally click it by calling dispatchMouseEvent, it runs smoothly without any performance impact after multiple attempts.

And it seems that the performance impact may occurred during chromedp.Sleep(). I'm not 100% sure about this. But if I delete all sleeping invocation, there is a chance that the webpage cannot detect any performance issue.

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

1 participant