Skip to content

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

Open
@melink14

Description

@melink14

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...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions