Skip to content

setBounds a WebContentsView will trigger page-favicon-updated event on some websites #49392

@z0gSh1u

Description

@z0gSh1u

Preflight Checklist

Electron Version

39.2.7

What operating system(s) are you using?

Windows

Operating System Version

Windows 11 25H2

What arch are you using?

x64

Last Known Working Electron version

No response

Does the issue also appear in Chromium / Google Chrome?

I don't know how to test

Expected Behavior

Intuitively, setBounds is related to positions and has nothing to do with the favicon. So page-favicon-updated event should not be emitted when calling setBounds with a new bounds on a WebContentsView.

Actual Behavior

Construct a WebContentsView, listen its page-favicon-updated event, add it to the main window, and loadURL for like https://electronjs.org. Then call setBounds with a new bounds on the WebContentsView, page-favicon-updated will be triggered.

This doesn't occur on all websites, but many websites have this problem, including https://github.com.

Usually this won't lead to noticeable problems. But if the user wants to auto resize the WebContentsView when the main window resizes, setBounds will be frequently called and a series of page-favicon-updated event will be emitted, even if the favicon urls array is not changed.

Image

Testcase Gist URL

https://gist.github.com/z0gSh1u/72fe6f155e1f145385461853d7ef2782

Additional Information

Can be reproduced on macOS too.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions