Closed Bug 1912002 Opened 2 years ago Closed 21 days ago

Auto-open PiP on app switch

Categories

(Toolkit :: Picture-in-Picture, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
159 Branch
Tracking Status
firefox159 --- fixed

People

(Reporter: pannett, Assigned: rio.syed)

Details

Attachments

(3 external files, 1 obsolete file)

Love the new 'Auto-open PiP on tab switch' feature! ❤️

Is it possible to make it work on app-switch, too? 🤞

Following up from this Slack convo:
https://mozilla.slack.com/archives/C4D3JFF26/p1722945883378159

Severity: -- → N/A
Priority: -- → P3
Assignee: nobody → danieleferla1
Status: NEW → ASSIGNED

Hey Daniele, I wanted to check in and see if you were going to update your patch for this based on the comments! If not, I'd be happy to take a dab at this

Flags: needinfo?(danieleferla1)

Hi @Harshit,

I have no access to the Slack conversation, but I think I won't implement a feature to trigger the PiP window when switching app, as I have very limited time.
If you want, you can take it. :)

Flags: needinfo?(danieleferla1)

Taking over from Daniele, I'll start work on this soon!

Assignee: 9wjt17j4z → hsohaney
Attachment #9547103 - Attachment description: WIP: Bug 1912002 - Auto-pip on app switch. WIP → WIP: Bug 1912002 - Auto-pip on app switch on windows/linux. WIP
Attachment #9547103 - Attachment description: WIP: Bug 1912002 - Auto-pip on app switch on windows/linux. WIP → Bug 1912002 - Auto-pip on app switch on windows/linux. r=mconley

I have a working implementation of the macOS side of this and wanted to offer
it rather than duplicate your WIP (attachment 9584516 [details]).

Today PictureInPicture:VideoTabHidden is dropped when
gBrowser.selectedBrowser == browser, so a window that becomes hidden while
its tab is still the selected one never auto-PiPs. Splitting that single gate
in two was enough to cover the app-switch case: the existing
enable-when-switching-tabs pref keeps handling the switched-away case, and a
second pref handles the still-selected-but-occluded case.

No new platform plumbing was needed. Occlusion already reaches document
visibility via CanonicalBrowsingContext::RecomputeAppWindowVisibility
(IsFullyOccluded() -> SetIsActiveInternal(false)), so the visibilitychange
was already firing — it was just being ignored by that gate.

I have been running this locally on macOS 26.6 and it covers switching
applications, switching desktop Spaces, and another window covering the browser.

Would that help? Happy to put it up as a patch, or to leave it with you and just
test your WIP on macOS if that is more useful — whichever fits what you have
already.

Flags: needinfo?(hsohaney)

happy to take a look at the patch!

Flags: needinfo?(hsohaney)

PictureInPicture:VideoTabHidden already fires whenever a tab's document becomes
hidden, but the handler drops the event when the tab is still the selected tab.
That means a window which becomes hidden while its tab stays selected -- switching
to a fullscreen app, minimizing, or another window covering it -- never
auto-opens the player, even though the same visibilitychange that drives the
switching-tabs case has already fired.

Occlusion already reaches document visibility on macOS via
CanonicalBrowsingContext::RecomputeAppWindowVisibility (IsFullyOccluded() ->
SetIsActiveInternal(false)), so no new platform plumbing is needed. This splits
the single gate in two: the tab-switched-away case keeps using
enable-when-switching-tabs, and a new enable-when-occluded pref (off by default,
mirroring its sibling) handles the still-selected-but-occluded case. The
docshell-restore path that reactivates an auto-pip'd browser is widened to the
new pref as well.

Attachment #9584516 - Attachment is obsolete: true
Pushed by mconley@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/07860b19f2db https://hg.mozilla.org/integration/autoland/rev/63af73109066 Auto-open Picture-in-Picture when a still-selected tab's window becomes occluded r=hsohaney,mconley
Status: ASSIGNED → RESOLVED
Closed: 21 days ago
Resolution: --- → FIXED
Target Milestone: --- → 159 Branch
QA Whiteboard: [qa-triage-done-c160/b159]
Assignee: hsohaney → rio.syed
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: