Skip to content

Revert "Keep actively-playing media browser panes alive in the background (issue 5409)" - #5436

Merged
austinywang merged 1 commit into
mainfrom
revert-5412-issue-5409-browser-media-playback-hibernate
Jun 5, 2026
Merged

austinywang merged 1 commit into
mainfrom
revert-5412-issue-5409-browser-media-playback-hibernate

Conversation

@austinywang

@austinywang austinywang commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Reverts #5412


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Note

Medium Risk
Restores prior memory-discard behavior for background tabs; users may see interrupted media or reloads, but no new security or data paths are introduced.

Overview
This reverts the feature that kept hidden browser panes alive while <video>/<audio> was playing (issue 5409).

It removes the injected document-start script, isolated WKContentWorld, and cmuxMediaPlayback message handler, plus per-frame playback tracking on BrowserPanel. Hidden-webview discard no longer treats media playback as a blocker—only camera/mic capture (isCapturingMedia) still blocks discard. Related tests and Xcode project entries for the deleted files are removed.

Behavior change: background tabs with playing media can again be memory-discarded after the hidden delay, which may interrupt playback or force a reload when the pane is restored.

Reviewed by Cursor Bugbot for commit c0f349c. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Reverts the hidden-pane media keep-alive behavior. Hidden browser panes can be discarded again even if they are playing media, restoring prior memory management.

  • Refactors
    • Removed media playback tracking: BrowserPanel+MediaPlayback.swift, BrowserMediaPlaybackMessageHandler.swift, and BrowserMediaPlaybackReport.swift.
    • Dropped media playback state and messaging from BrowserPanel and the media_playback blocker from BrowserHiddenWebViewDiscardManager.
    • Updated tests to remove media playback discard cases.

Written for commit c0f349c. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Refactor
    • Updated memory management for hidden browser tabs to focus on camera and microphone capture activity instead of media playback detection. Browser tabs will now be eligible for memory unloading even while videos or audio are playing.

@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Building Building Preview, Comment Jun 5, 2026 4:48am
cmux-staging Building Building Preview, Comment Jun 5, 2026 4:48am

@austinywang
austinywang merged commit 149edcb into main Jun 5, 2026
16 of 20 checks passed
@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 406dd676-1aae-4703-b311-ff60fc7ea46f

📥 Commits

Reviewing files that changed from the base of the PR and between ce4cfec and c0f349c.

📒 Files selected for processing (7)
  • Sources/Panels/BrowserHiddenWebViewDiscardManager.swift
  • Sources/Panels/BrowserMediaPlaybackMessageHandler.swift
  • Sources/Panels/BrowserMediaPlaybackReport.swift
  • Sources/Panels/BrowserPanel+MediaPlayback.swift
  • Sources/Panels/BrowserPanel.swift
  • cmux.xcodeproj/project.pbxproj
  • cmuxTests/BrowserPanelTests.swift

📝 Walkthrough

Walkthrough

Media-playback-based discard blocking is removed entirely. BrowserHiddenWebViewDiscardManager switches from tracking active media playback (isPlayingMedia) to media-capture state (isCapturingMedia). BrowserPanel's media-playback tracking feature—WebKit script injection, message handling, and state aggregation—is deleted. Tests and Xcode project configuration are updated to reflect these removals.

Changes

Media Playback Discard Blocking Removal

Layer / File(s) Summary
Update discard manager to media-capture blocker
Sources/Panels/BrowserHiddenWebViewDiscardManager.swift, Sources/Panels/BrowserPanel.swift
BlockerSnapshot field changes from isPlayingMedia to isCapturingMedia; blockers(for:) reports "media_capture" instead of "media_playback". BrowserPanel snapshot payload removes the playback field and uses the new capture state.
Remove media-playback tracking from BrowserPanel
Sources/Panels/BrowserPanel.swift
Deletes isPlayingMedia state properties, per-frame tracking, WebKit user-script injection for media-playback reporting, message-handler binding, and committed-navigation reset logic.
Update tests and build configuration
cmuxTests/BrowserPanelTests.swift, cmux.xcodeproj/project.pbxproj
Test helper removes isPlayingMedia parameter; snapshot initializer stops setting playback state; media-playback test cases are deleted. Project file removes BrowserMediaPlaybackMessageHandler.swift, BrowserMediaPlaybackReport.swift, BrowserPanel+MediaPlayback.swift build entries and adds Omnibar-related entries.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • manaflow-ai/cmux#4912: Adds the isCapturingMedia/"media_capture" blocker and capture-state reevaluation wiring that this PR completes by removing the redundant isPlayingMedia/"media_playback" path.
  • manaflow-ai/cmux#5412: Directly removes the same media-playback discard-blocking implementation (BrowserMediaPlayback* files and BrowserPanel+MediaPlayback extension) that was added in an earlier PR, undoing the wiring in favor of media-capture-only signaling.
  • manaflow-ai/cmux#5315: Updates BrowserHiddenWebViewDiscardManager.BlockerSnapshot and its test helper in parallel, refactoring the same snapshot structure used for discard scheduling.

Poem

🐇 A hop, a skip, a cleanup spree,
Playing media? Now we're free!
Capture rules the discard day,
Old playback files hop away! 🎬✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch revert-5412-issue-5409-browser-media-playback-hibernate

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR reverts #5412, which had introduced a mechanism to keep browser panes with actively-playing <video>/<audio> alive in the background by injecting a JavaScript hook into every frame and blocking the hidden-webview discard manager when any frame reported playback.

  • Three source files are deleted (BrowserMediaPlaybackMessageHandler.swift, BrowserMediaPlaybackReport.swift, BrowserPanel+MediaPlayback.swift), along with the corresponding isPlayingMedia state, media_playback blocker, and navigation-commit reset in BrowserPanel.swift and BrowserHiddenWebViewDiscardManager.swift.
  • Tests and Xcode project references are cleaned up consistently; no dangling symbols or orphaned build-file entries remain.

Confidence Score: 5/5

Clean mechanical revert with no dangling symbols, orphaned build references, or test inconsistencies.

All three deleted Swift files have zero remaining references in the source tree or test target. The BlockerSnapshot struct, its callers in BrowserPanel.swift, the bindWebView setup, the navigation-commit reset, and both regression tests were removed in lockstep. The Xcode project file is consistent. The only consequence of this change is intentional: panes playing background media are once again eligible for hidden-webview discard, re-opening issue #5409 until a replacement fix lands.

No files require special attention.

Important Files Changed

Filename Overview
Sources/Panels/BrowserHiddenWebViewDiscardManager.swift Removes isPlayingMedia from BlockerSnapshot and the media_playback blocker check; struct and logic are consistent.
Sources/Panels/BrowserMediaPlaybackMessageHandler.swift File deleted as part of revert; no references remain elsewhere.
Sources/Panels/BrowserMediaPlaybackReport.swift File deleted as part of revert; no references remain elsewhere.
Sources/Panels/BrowserPanel+MediaPlayback.swift File deleted as part of revert; JS injection script, content-world setup, and message-handler wiring all removed.
Sources/Panels/BrowserPanel.swift Removes isPlayingMedia, playingMediaFrameIDs, mediaPlaybackMessageHandler, and three helper functions; bindWebView and navigationCommit call sites cleaned up cleanly.
cmux.xcodeproj/project.pbxproj All three deleted Swift files removed from PBXBuildFile, PBXFileReference, group listing, and Sources build phase; no orphaned entries.
cmuxTests/BrowserPanelTests.swift Removes the two regression tests for issue #5409 and the isPlayingMedia parameter from the snapshot factory helper; remaining tests are unaffected.

Sequence Diagram

sequenceDiagram
    participant Page as WebPage (JS)
    participant Handler as BrowserMediaPlaybackMessageHandler
    participant Panel as BrowserPanel
    participant Discard as BrowserHiddenWebViewDiscardManager

    Note over Page,Discard: BEFORE revert (PR #5412 — now removed)
    Page->>Handler: "postMessage({frameID, playing})"
    Handler->>Panel: handleMediaPlaybackReport(_:fromWebViewInstanceID:)
    Panel->>Panel: "applyMediaPlaybackReport → isPlayingMedia=true"
    Panel->>Discard: reevaluateHiddenWebViewDiscardScheduling
    Discard-->>Discard: blockers → [media_playback] → no discard scheduled

    Note over Page,Discard: AFTER revert (this PR — current state)
    Page--xHandler: (handler removed, no message received)
    Discard-->>Discard: blockers → [] → discard scheduled after hidden delay
Loading

Reviews (1): Last reviewed commit: "Revert "Keep actively-playing media brow..." | Re-trigger Greptile

This branch was successfully deployed

1 active deployment
Preview – cmux — c0f349cf Deployed Jun 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant