Skip to content

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

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

jkleinsc merged 1 commit into
41-x-yfrom
sam/backport/mac-occlusion-visibility-41

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 added backport This is a backport PR semver/patch backwards-compatible bug fixes 41-x-y labels Apr 6, 2026
@MarshallOfSound
MarshallOfSound requested a review from a team as a code owner April 6, 2026 05:21
@MarshallOfSound MarshallOfSound added semver/patch backwards-compatible bug fixes 41-x-y labels Apr 6, 2026
@trop
trop Bot requested a review from a team April 6, 2026 05:22
* 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-41 branch from 4e8cfa4 to 581d481 Compare April 6, 2026 17:24
@jkleinsc
jkleinsc merged commit 3fa5280 into 41-x-y Apr 6, 2026
61 checks passed
@jkleinsc
jkleinsc deleted the sam/backport/mac-occlusion-visibility-41 branch April 6, 2026 20:01
@release-clerk

release-clerk Bot commented Apr 6, 2026

Copy link
Copy Markdown

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

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