Skip to content

fix: avoid redundant page-favicon-updated events on setBounds#49464

Merged
codebytere merged 3 commits intoelectron:mainfrom
ANANYA542:fix/deduplicate-page-favicon-updated
Mar 5, 2026
Merged

fix: avoid redundant page-favicon-updated events on setBounds#49464
codebytere merged 3 commits intoelectron:mainfrom
ANANYA542:fix/deduplicate-page-favicon-updated

Conversation

@ANANYA542
Copy link
Copy Markdown
Contributor

@ANANYA542 ANANYA542 commented Jan 21, 2026

Description of Change

Closes #49392

Fixes an issue where calling setBounds on a WebContentsView unintentionally triggers the page-favicon-updated event even when the favicon has not actually changed.

Currently, layout-related updates such as resizing or repositioning a WebContentsView can cause redundant emissions of page-favicon-updated, which is unexpected and leads to duplicate callbacks in user code. This change ensures that the event is only emitted when there is a real change in the favicon data, preventing unnecessary and misleading notifications.

This makes the page-favicon-updated event more semantically correct and avoids side effects caused by purely visual or layout updates.

Checklist


Release Notes

Notes: Fixed an issue where calling setBounds on a WebContentsView could trigger redundant page-favicon-updated events even when the favicon had not changed.

@welcome
Copy link
Copy Markdown

welcome bot commented Jan 21, 2026

💖 Thanks for opening this pull request! 💖

Semantic PR titles

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Commit signing

This repo enforces commit signatures for all incoming PRs.
To sign your commits, see GitHub's documentation on Telling Git about your signing key.

PR tips

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Jan 21, 2026
@codebytere codebytere added semver/patch backwards-compatible bug fixes target/39-x-y PR should also be added to the "39-x-y" branch. target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. labels Jan 21, 2026
@codebytere codebytere changed the title fix(web contents): avoid redundant page-favicon-updated events on setBounds (#49392) fix: avoid redundant page-favicon-updated events on setBounds Jan 21, 2026
Copy link
Copy Markdown
Member

@codebytere codebytere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed this corrects the issue. Please add a test here to validate the fix. You also need to sign your commit.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Jan 22, 2026
@nikwen
Copy link
Copy Markdown
Member

nikwen commented Jan 22, 2026

I wonder if this just works around an upstream issue that should really be fixed in Chromium. Why would WebContentsObserver::DidUpdateFaviconURL be called in the first place when changing bounds?

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @ANANYA542! It looks like this pull request touches one of our dependency or CI files, and per our contribution policy we do not accept these types of changes in PRs.

@ANANYA542
Copy link
Copy Markdown
Contributor Author

@ckerr , @codebytere Thanks for the reviews!
I’ve addressed the requested changes, added a regression test for the favicon behavior, and synced the branch with main. I’m keeping an eye on the CI results.Do recommend further changes if needed.

@ANANYA542
Copy link
Copy Markdown
Contributor Author

@nikwen I tried looking into whether this should be handled upstream, but I couldn’t find a clear Chromium issue or documentation that explains exactly why DidUpdateFaviconURL fires on bounds/layout changes from what I could observe while testing locally, the callback was getting triggered even when the favicon URL itself didn’t actually change, but I don’t have a solid upstream reference yet that proves the root cause so for now I treated this more like an electron-side safeguard so app developers don’t get duplicate page-favicon-updated events I’m still pretty new to digging into Chromium internals and trying to understand how these observers propagate, so I might be missing some deeper context here if there’s an existing upstream issue or a better place to fix this, I’d definitely be happy to explore that direction too.

@nikwen
Copy link
Copy Markdown
Member

nikwen commented Feb 6, 2026

I don't think you'd find an issue already filed upstream or any documentation on it. It would require reading the relevant Chromium code and debugging why the event fires multiple times.

@ANANYA542 ANANYA542 requested review from ckerr and codebytere February 6, 2026 12:54
@ANANYA542 ANANYA542 force-pushed the fix/deduplicate-page-favicon-updated branch from 5fb281f to 906692a Compare February 6, 2026 14:21
Copy link
Copy Markdown
Member

@codebytere codebytere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ANANYA542 please rebase and remove yark.lock changes! We can then get this merged.

@ckerr ckerr force-pushed the fix/deduplicate-page-favicon-updated branch from 906692a to 198b23b Compare February 24, 2026 21:39
Copy link
Copy Markdown
Member

@ckerr ckerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codebytere I've pushed up a rebase to e/e's main branch to resolve any remaining shear eg package.json & yarn.lock; should be ready for re-review

@ANANYA542
Copy link
Copy Markdown
Contributor Author

@ckerr Thanks for pushing the updates and rebasing!
The changes look good to me @codebytere please let me know if there's anything else you'd like me to adjust.

@ANANYA542 ANANYA542 requested a review from codebytere February 27, 2026 02:55
@codebytere codebytere merged commit 9b15976 into electron:main Mar 5, 2026
102 of 105 checks passed
@welcome
Copy link
Copy Markdown

welcome bot commented Mar 5, 2026

Congrats on merging your first pull request! 🎉🎉🎉

@release-clerk
Copy link
Copy Markdown

release-clerk bot commented Mar 5, 2026

Release Notes Persisted

Fixed an issue where calling setBounds on a WebContentsView could trigger redundant page-favicon-updated events even when the favicon had not changed.

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 5, 2026

I have automatically backported this PR to "40-x-y", please check out #50084

@trop trop bot added the in-flight/40-x-y label Mar 5, 2026
@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 5, 2026

I have automatically backported this PR to "41-x-y", please check out #50085

@trop trop bot removed the target/40-x-y PR should also be added to the "40-x-y" branch. label Mar 5, 2026
@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 5, 2026

I have automatically backported this PR to "39-x-y", please check out #50086

@trop trop bot added in-flight/41-x-y in-flight/39-x-y merged/39-x-y PR was merged to the "39-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. merged/40-x-y PR was merged to the "40-x-y" branch. and removed target/41-x-y PR should also be added to the "41-x-y" branch. target/39-x-y PR should also be added to the "39-x-y" branch. in-flight/39-x-y in-flight/41-x-y in-flight/40-x-y labels Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/39-x-y PR was merged to the "39-x-y" branch. merged/40-x-y PR was merged to the "40-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants