PIP icon will disappear when dragging the tab to create a new window
Categories
(Toolkit :: Video/Audio Controls, defect, P3)
Tracking
()
People
(Reporter: csasca, Assigned: heftydav)
References
(Blocks 2 open bugs)
Details
Attachments
(3 files, 2 obsolete files)
Affected versions
- Firefox 82.0b7
- Firefox 83.0a1
Affected platforms
- Windows 7
- macOS 11
- Ubuntu 20.04
Steps to reproduce
- Launch Firefox
- Access a video from Twitch for example
- Put the video in PIP mode and drag the current tab out of the window to create a new one
Expected result
- The PIP icon in tab is still displayed
Actual result
- The PIP icon will disappear
Regression range
- I will see for a regression if there is one.
Additional notes
- The issue can be seen in the attachment
Suggested severity
- S3
Reporter | ||
Updated•5 years ago
|
Updated•5 years ago
|
Comment 1•5 years ago
|
||
Checked with builds from 2019 January (around the date of feature being launched) the pip-indicator was not displayed.
It's not a regressed behaviour:
- checked with mozregression and located builds between 2019-05-22 / 2019-05-23 on having or not the tab indicator so it became visible with addition of that element;
- most likely visible as mentioned above, with patch from bug 1528459 [Show PiP Icon in parent tab of media] / [Tab should indicate that a <video> inside of it is being viewed in Picture-in-Picture, and perhaps not display the audio indicator];
- pushlog URL.
Comment 2•5 years ago
|
||
Mike, would you mind having a look?
Comment 3•5 years ago
|
||
I'll see if one of our MSU students has time for this.
Updated•5 years ago
|
Updated•5 years ago
|
Comment 4•5 years ago
|
||
Updated•5 years ago
|
Updated•5 years ago
|
Comment 5•5 years ago
|
||
I wanted to write down some things we learned while investigating this issue before I forget.
-
We're adopting the approach shown in D99018 by creating a "TabClose" event handler on the
PictureInPicture
object and setting an event listener for "TabClose" on the tab PiP is launched from. This works the first time the PiP tab is moved out of its original window. The second time, not so much. I've observed that the issue is reproducible when moving the PiP tab out into its own window (and not into another existing one). -
The tab browser is responsible for firing the TabClose event when a tab is about to be removed from its original window and moved to the new one. Because of this, we'd need to set another listener for "TabClose" on the new tab the old PiP tab is being moved to. This is done inside the handler for "TabClose" we have on the PictureInPicture object:
// in PictureInPicture
handleEvent(event) {
switch (event.type) {
case "TabClose":
...
let adoptedBy = event.detail.adoptedBy;
adoptedBy.addEventListener("TabClose", this);
...
break;
}
}
The adoptedBy
object here refers to the new tab the old PiP tab will be moving to. But it seems like the "TabClose" event is lost after it's fired from tabbrowser.js when moving the tab the second time.
- This might mean
adoptedBy
isn't the new tab we think we are moving PiP to. The next steps are to observe the lifecycle of these <tab> element when they're removed. What's the difference between moving a tab into its own window vs moving a tab into an existing one?
Comment 6•5 years ago
|
||
It might be easier to set our new browser to the existing PiP window by firing a CustomEvent after we swap around the "pictureinpicture" attributes in swapBrowsersAndCloseOther. That way, we are guaranteeing the adopted tab is ready when browsers are swapped.
Let's try this:
- Make PictureInPicture listen for a custom event called "PictureInPicture:SwappedBrowsers"
tab.addEventListener("PictureInPicture:SwappedBrowsers", this);
- Create a handler called
onPipSwappedBrowsers
. This is responsible for setting the new browser to the current PiP player window:
let otherTab = e.detail;
if (otherTab) {
for (let win of Services.wm.getEnumerator(WINDOW_TYPE)) {
if (this.weakWinToBrowser.get(win) === e.target.linkedBrowser) {
this.weakWinToBrowser.set(win, otherTab.linkedBrowser);
}
}
}
- Have browser fire "PictureInPicture:SwappedBrowsers" after we have swapped the "pictureinpicture" attributes with the closing tab.
if (aOtherTab.hasAttribute("pictureinpicture")) {
aOurTab.setAttribute("pictureinpicture", "true");
modifiedAttrs.push("pictureinpicture");
let event = new CustomEvent("PictureInPicture:SwappedBrowsers", {
detail: aOurTab,
});
aOtherTab.dispatchEvent(event);
}
Let's do this around here: https://searchfox.org/mozilla-central/source/browser/base/content/tabbrowser.js#3974.
With this, we can probably remove the listener for "TabClose" since we are having PiP react only when swapping browsers.
Updated•5 years ago
|
Updated•5 years ago
|
Assignee | ||
Comment 10•5 years ago
|
||
Assignee | ||
Comment 11•5 years ago
|
||
Comment 12•5 years ago
|
||
(In reply to David from comment #11)
https://treeherder.mozilla.org/jobs?repo=try&revision=34b5e1dea1d524d78c2fd151617b8b255cbd53c3
Failures for linux-debug. Since we're both using either Windows or MacOSX, we didn't catch these failures when running the test locally.
I pushed another "try" push with more logging to help narrow down issue. It seems like we're timing out during detachTab
: https://treeherder.mozilla.org/push-health/push?repo=try&revision=351e90ec3c9bbe0cae1cb5e1eabe690db3708841&testGroup=pr&selectedTest=toolkitcomponentspictureinpicturetestsbrowserpreserveTabPipIconOverlayjs&selectedTaskId=332753936&selectedJobName=toolkit%2Fcomponents%2Fpictureinpicture%2Ftests%2Fbrowser_preserveTabPipIconOverlay.js+test-linux1804-64%2Fdebug-mochitest-browser-chrome-e10s-6
Updated•5 years ago
|
Assignee | ||
Comment 13•5 years ago
|
||
Depends on D105831
Assignee | ||
Comment 14•5 years ago
|
||
Updated•5 years ago
|
Updated•5 years ago
|
Comment 15•5 years ago
|
||
Comment 16•5 years ago
|
||
bugherder |
Updated•5 years ago
|
Updated•5 years ago
|
Reporter | ||
Comment 17•5 years ago
|
||
Verified that the issue is fixed on latest Nightly 89.0a1 (2021-04-06) and Firefox 88.0b7. Tests were performed under macOS 11.2.3, Ubuntu 20.04 and Windows 10.
Description
•