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

visual regression visualDiff hangs forever when tab is in background #2849

Open
melink14 opened this issue Dec 18, 2024 · 1 comment
Open

Comments

@melink14
Copy link
Contributor

melink14 commented Dec 18, 2024

With new headless chrome (and headfull), if the tab is in the background takeScreenshot never returns (and no timeouts fire until the top level 120s timer fires;)

This is because element.screenshot in puppeteer relies on IntersectionObserver (via scrollIntoViewIfAble) doesn't work in backgrounded tabs. (ref: https://github.com/puppeteer/puppeteer/blob/682bb682116437dc803afd613eb95fd2efd65a65/packages/puppeteer-core/src/api/ElementHandle.ts#L1479)

I made a local patch where I just added page.bringToFront() before calling element.screenshot and that seems to work though I'm not sure if there's a better fix. (ref:

const screenshot = await element.screenshot({ encoding: 'binary' });
)

It seems like when the simlar #2366 was merged it added a __bringTabToFront method to window which I could call before visualDiff as well but it seems like an implementation detail I shouldn't rely on.

For now, I can use patch-package but I'd love to hear thoughts on this approach.

For completeness, similar to other new headless bugs, this can be fixed by setting concurrency to 1 as well.

(As an aside, given we patched requestAnimationFrame I wonder if we should also patch client side IntersectionObserver to call bringTabToFront...)

@melink14
Copy link
Contributor Author

(A similar problem for .click was opened on puppeteer: puppeteer/puppeteer#5201)

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