Skip to content

Conversation

@ANANYA542
Copy link

@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

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

iter->icon_url.is_valid())
unique_urls.insert(iter->icon_url);
}
// Deduplicate: only emit if favicon URLs actually changed
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Deduplicate: only emit if favicon URLs actually changed
// Only emit if favicon URLs actually changed

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Jan 22, 2026
@nikwen
Copy link
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?

private:
// Store last emitted favicon URLs to avoid duplicate page-favicon-updated
// events
base::flat_set<GURL> last_favicon_urls_;
Copy link
Member

Choose a reason for hiding this comment

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

(nit) Needs #include "base/containers/flat_set.h" at the top of the header file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

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