Skip to content

fix: re-enable MacWebContentsOcclusion with embedder window fix#50712

Merged
MarshallOfSound merged 1 commit into
42-x-yfrom
sam/backport/mac-occlusion-visibility-42
Apr 6, 2026
Merged

fix: re-enable MacWebContentsOcclusion with embedder window fix#50712
MarshallOfSound merged 1 commit into
42-x-yfrom
sam/backport/mac-occlusion-visibility-42

Conversation

@MarshallOfSound
Copy link
Copy Markdown
Member

Backport of #50579

See that PR for details.

Notes: Fixed an issue on macOS where show/hide events and WebContents visibility state could be reported incorrectly when multiple WebContentsViews were attached to a window.

@MarshallOfSound MarshallOfSound requested a review from a team as a code owner April 6, 2026 05:21
@MarshallOfSound MarshallOfSound added backport This is a backport PR semver/patch backwards-compatible bug fixes 42-x-y labels Apr 6, 2026
@trop trop Bot requested a review from a team April 6, 2026 05:21
* fix: re-enable MacWebContentsOcclusion with embedder window fix

Replace the full revert of Chromium's MacWebContentsOcclusion cleanup
with a targeted patch that handles embedder windows shown after
WebContentsViewCocoa attachment. This lets us drop the feature flag
disable in feature_list.cc and re-enable upstream occlusion tracking.

Adds tests for show/hide event counts on macOS and visibility tracking
across multiple child WebContentsViews.

* test: drop show/hide event count assertion

The assertion that 'show' fires exactly once per w.show() call is not
an API guarantee - macOS can send multiple occlusion state
notifications during a single show() when other windows are on screen
(common on CI after hundreds of prior tests). The
visibilitychange-count test in api-web-contents-view-spec.ts covers
the actual invariant we care about.

* fix: ignore WebContentsOcclusionCheckerMac synthetic notifications in window delegate

On macOS 13.3-25.x, Chromium's occlusion checker enables manual
frame-intersection detection and posts synthetic
NSWindowDidChangeOcclusionStateNotification tagged with its class name
in userInfo. These fire when the checker's NSContainsRect heuristic
decides a window is covered by another window's frame, but the real
-[NSWindow occlusionState] hasn't changed.

Our delegate was treating these the same as real macOS notifications
and emitting show/hide events based on occlusionState, which was
unchanged - resulting in spurious duplicate show events when e.g.
Quick Look opened and its frame intersected the BrowserWindow.
@MarshallOfSound MarshallOfSound force-pushed the sam/backport/mac-occlusion-visibility-42 branch from 7e6a31b to 2818b90 Compare April 6, 2026 17:23
@MarshallOfSound MarshallOfSound enabled auto-merge (squash) April 6, 2026 20:12
@MarshallOfSound MarshallOfSound merged commit 487c29b into 42-x-y Apr 6, 2026
112 of 114 checks passed
@MarshallOfSound MarshallOfSound deleted the sam/backport/mac-occlusion-visibility-42 branch April 6, 2026 21:05
@release-clerk
Copy link
Copy Markdown

release-clerk Bot commented Apr 6, 2026

Release Notes Persisted

Fixed an issue on macOS where show/hide events and WebContents visibility state could be reported incorrectly when multiple WebContentsViews were attached to a window.

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

Labels

42-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants