Closed
Bug 1347758
Opened 8 years ago
Closed 8 years ago
HTML5 video/audio doesn't play if node was removed in background tab
Categories
(Core :: Audio/Video: Playback, defect, P1)
Tracking
()
RESOLVED
FIXED
mozilla55
Tracking | Status | |
---|---|---|
firefox52 | --- | unaffected |
firefox-esr52 | --- | unaffected |
firefox53 | --- | unaffected |
firefox54 | --- | fixed |
firefox55 | --- | verified |
People
(Reporter: 684sigma, Assigned: alwu)
References
Details
(Keywords: regression)
Attachments
(8 files, 2 obsolete files)
437 bytes,
text/html
|
Details | |
59 bytes,
text/x-review-board-request
|
ehsan.akhgari
:
review+
|
Details |
59 bytes,
text/x-review-board-request
|
ehsan.akhgari
:
review+
|
Details |
59 bytes,
text/x-review-board-request
|
ehsan.akhgari
:
review+
|
Details |
59 bytes,
text/x-review-board-request
|
ehsan.akhgari
:
review+
|
Details |
59 bytes,
text/x-review-board-request
|
ehsan.akhgari
:
review+
|
Details |
59 bytes,
text/x-review-board-request
|
ehsan.akhgari
:
review+
|
Details |
42.07 KB,
patch
|
Details | Diff | Splinter Review |
I have a problem with Firefox Nightly 55. It doesn't happen in Firefox Beta 53.
Sometimes when I click play button on a web page, audio doesn't play. I don't remember where I saw it (probably on Soundcloud or Facebook) because I immediately created working html page that reproduces the bug.
I noticed one specific scenario when it happens
1. Open attached html page in background tab
2. When that tab displays title "removed", switch to that tab and click "Play" button on the page
Result: Nothing happens
Expected: Audio should play
Has STR: --- → yes
Keywords: regression
Comment 2•8 years ago
|
||
The issue belongs to the block-background-audio feature, ni Alastor for more information.
Flags: needinfo?(alwu)
Assignee | ||
Updated•8 years ago
|
Comment hidden (mozreview-request) |
Assignee | ||
Comment 4•8 years ago
|
||
Updated•8 years ago
|
status-firefox52:
--- → unaffected
status-firefox53:
--- → unaffected
status-firefox54:
--- → unaffected
status-firefox55:
--- → affected
Updated•8 years ago
|
Priority: -- → P1
Assignee | ||
Updated•8 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 13•8 years ago
|
||
Writing tests...
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 23•8 years ago
|
||
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Updated•8 years ago
|
Attachment #8848000 -
Flags: review?(amarchesini)
Attachment #8849448 -
Flags: review?(amarchesini)
Attachment #8849449 -
Flags: review?(amarchesini)
Attachment #8849450 -
Flags: review?(amarchesini)
Attachment #8849884 -
Flags: review?(amarchesini)
Attachment #8849885 -
Flags: review?(amarchesini)
Assignee | ||
Updated•8 years ago
|
Attachment #8848000 -
Flags: review?(amarchesini) → review?(ehsan)
Attachment #8849448 -
Flags: review?(amarchesini) → review?(ehsan)
Attachment #8849449 -
Flags: review?(amarchesini) → review?(ehsan)
Attachment #8849450 -
Flags: review?(amarchesini) → review?(ehsan)
Attachment #8849884 -
Flags: review?(amarchesini) → review?(ehsan)
Attachment #8849885 -
Flags: review?(amarchesini) → review?(ehsan)
Assignee | ||
Comment 26•8 years ago
|
||
Hi, Ehsan,
Since baku said he's busy with fixing blockers for multi-e10s, could you help me review these patches?
Thanks!
Comment 27•8 years ago
|
||
I'll try to review tomorrow, sorry for the delay!
Assignee | ||
Comment 28•8 years ago
|
||
(In reply to :Ehsan Akhgari (busy) from comment #27)
> I'll try to review tomorrow, sorry for the delay!
Thank you very much!
Comment 29•8 years ago
|
||
mozreview-review |
Comment on attachment 8848000 [details]
Bug 1347758 - part1 : window should know whehter there is any alive media component and decide to resume the tab or not.
https://reviewboard.mozilla.org/r/120956/#review125560
::: dom/base/nsGlobalWindow.cpp:4254
(Diff revision 3)
> nsCOMPtr<nsPIDOMWindowInner> inner = GetCurrentInnerWindow();
> if (!inner) {
> return;
> }
>
> + // If the document is still in the background, don't need to resume it.
nsIDocument::Hidden() is technically not the same thing as the doc being in the background, it also precludes the doc being prerendered. If you reword the comment to say the doc is not visible, that would be more accurate.
::: dom/base/nsPIDOMWindow.h:743
(Diff revision 3)
>
> mozilla::dom::LargeAllocStatus mLargeAllocStatus; // Outer window only
> +
> + // When there is any created alive media component, we can consider to resume
> + // the media content in the window.
> + bool mShouldActiveMediaComponents;
Let's rename this to something slightly better, like mShouldResumeOnFirstActiveMediaComponent.
Attachment #8848000 -
Flags: review?(ehsan) → review+
Comment 30•8 years ago
|
||
mozreview-review |
Comment on attachment 8849448 [details]
Bug 1347758 - part2 : remove add/removeMediaContent() and related codes.
https://reviewboard.mozilla.org/r/122210/#review125562
Attachment #8849448 -
Flags: review?(ehsan) → review+
Comment 31•8 years ago
|
||
mozreview-review |
Comment on attachment 8849449 [details]
Bug 1347758 - part3 : should notify media block for audible agent in the first time.
https://reviewboard.mozilla.org/r/122212/#review125576
Attachment #8849449 -
Flags: review?(ehsan) → review+
Comment 32•8 years ago
|
||
mozreview-review |
Comment on attachment 8849450 [details]
Bug 1347758 - part4 : add audio channel log.
https://reviewboard.mozilla.org/r/122214/#review125580
::: dom/media/webaudio/AudioDestinationNode.cpp:512
(Diff revision 2)
> return NS_OK;
> }
>
> + MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
> + ("AudioDestinationNode, WindowVolumeChanged, "
> + "this = %p, aVolume = %f, aMuted = %d\n", this, aVolume, aMuted));
Nit: because of the %d, please cast the aMuted to int here.
::: dom/media/webaudio/AudioDestinationNode.cpp:533
(Diff revision 2)
> return NS_OK;
> }
>
> + MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
> + ("AudioDestinationNode, WindowSuspendChanged, "
> + "this = %p, aSuspend = %d\n", this, aSuspend));
Similarly here.
::: dom/plugins/base/nsNPAPIPluginInstance.cpp:1743
(Diff revision 2)
> NS_IMETHODIMP
> nsNPAPIPluginInstance::WindowVolumeChanged(float aVolume, bool aMuted)
> {
> + MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
> + ("nsNPAPIPluginInstance, WindowVolumeChanged, "
> + "this = %p, aVolume = %f, aMuted = %d\n", this, aVolume, aMuted));
And here.
::: dom/plugins/base/nsNPAPIPluginInstance.cpp:1766
(Diff revision 2)
> NS_IMETHODIMP
> nsNPAPIPluginInstance::WindowSuspendChanged(nsSuspendedTypes aSuspend)
> {
> + MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
> + ("nsNPAPIPluginInstance, WindowSuspendChanged, "
> + "this = %p, aSuspend = %d\n", this, aSuspend));
Same.
Attachment #8849450 -
Flags: review?(ehsan) → review+
Comment 33•8 years ago
|
||
mozreview-review |
Comment on attachment 8849884 [details]
Bug 1347758 - part5 : add tests.
https://reviewboard.mozilla.org/r/122604/#review125582
::: toolkit/content/tests/browser/browser_block_notInTreeAudio.js:41
(Diff revision 2)
> + content.document.body.removeChild(audio);
> + // Add timeout to ensure the audio is removed from DOM tree.
> + setTimeout(function() {
> + info("Prepare to start playing audio.");
> + audio.play();
> + }, 2000);
Why do we need to wait for 2 seconds here? Can we do something better here? r+ becuase I don't want to block the landing of this patch on this, but please file a follow-up to make this better.
Attachment #8849884 -
Flags: review?(ehsan) → review+
Comment 34•8 years ago
|
||
mozreview-review |
Comment on attachment 8849885 [details]
Bug 1347758 - part6 : reorder tests according to alphabet order.
https://reviewboard.mozilla.org/r/122624/#review125592
r+ based on the commit message. :-)
Attachment #8849885 -
Flags: review?(ehsan) → review+
Assignee | ||
Comment 35•8 years ago
|
||
mozreview-review-reply |
Comment on attachment 8849450 [details]
Bug 1347758 - part4 : add audio channel log.
https://reviewboard.mozilla.org/r/122214/#review125580
> Nit: because of the %d, please cast the aMuted to int here.
I'll change it to %s and print "true" or "false" according to the value of boolean.
Assignee | ||
Comment 36•8 years ago
|
||
mozreview-review-reply |
Comment on attachment 8849884 [details]
Bug 1347758 - part5 : add tests.
https://reviewboard.mozilla.org/r/122604/#review125582
> Why do we need to wait for 2 seconds here? Can we do something better here? r+ becuase I don't want to block the landing of this patch on this, but please file a follow-up to make this better.
Because media element would send async runnable to pause itself when it was unbind from tree [1].
The ideal way is split "unbind from tree" and "play not-in-tree media element" in two different tasks, but I have no way to access the not-in-tree media element in the different task. (can't get that element from document)
Therefore, I need to wait for a while to ensure pause() has been called, before I call play(). If you think 2 seconds is too long, I can change it to 1 second.
[1] http://searchfox.org/mozilla-central/rev/c48398abd9f0f074c69f2223260939e30e8f99a8/dom/html/HTMLMediaElement.cpp#4557
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 43•8 years ago
|
||
Pushed by alwu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/85846edfe957
part1 : window should know whehter there is any alive media component and decide to resume the tab or not. r=Ehsan
https://hg.mozilla.org/integration/autoland/rev/cafb3c12027b
part2 : remove add/removeMediaContent() and related codes. r=Ehsan
https://hg.mozilla.org/integration/autoland/rev/1fd084ec34d4
part3 : should notify media block for audible agent in the first time. r=Ehsan
https://hg.mozilla.org/integration/autoland/rev/80232d4c85d5
part4 : add audio channel log. r=Ehsan
https://hg.mozilla.org/integration/autoland/rev/2abce19f5001
part5 : add tests. r=Ehsan
https://hg.mozilla.org/integration/autoland/rev/9becd55242c1
part6 : reorder tests according to alphabet order. r=Ehsan
Assignee | ||
Comment 44•8 years ago
|
||
Add NI as a reminder for uplift.
Assignee | ||
Updated•8 years ago
|
Comment 45•8 years ago
|
||
sorry had to back this out for eslint failrue like https://treeherder.mozilla.org/logviewer.html#?job_id=86133874&repo=autoland&lineNumber=4368
https://hg.mozilla.org/integration/autoland/rev/e7dbc2e8b2f9
Flags: needinfo?(alwu)
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 52•8 years ago
|
||
Pass the eslint test.
https://treeherder.mozilla.org/#/jobs?repo=try&revision=e73dd38b378e0e36766b745b7604c5ca08e08596
Flags: needinfo?(alwu)
Comment 53•8 years ago
|
||
Pushed by alwu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/de28756d3b2b
part1 : window should know whehter there is any alive media component and decide to resume the tab or not. r=Ehsan
https://hg.mozilla.org/integration/autoland/rev/c8cb2fcd9f01
part2 : remove add/removeMediaContent() and related codes. r=Ehsan
https://hg.mozilla.org/integration/autoland/rev/3e7df5c0637c
part3 : should notify media block for audible agent in the first time. r=Ehsan
https://hg.mozilla.org/integration/autoland/rev/e373c012833a
part4 : add audio channel log. r=Ehsan
https://hg.mozilla.org/integration/autoland/rev/2321624fb1b2
part5 : add tests. r=Ehsan
https://hg.mozilla.org/integration/autoland/rev/04911f2670f1
part6 : reorder tests according to alphabet order. r=Ehsan
Assignee | ||
Updated•8 years ago
|
Flags: needinfo?(alwu)
Comment 54•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/de28756d3b2b
https://hg.mozilla.org/mozilla-central/rev/c8cb2fcd9f01
https://hg.mozilla.org/mozilla-central/rev/3e7df5c0637c
https://hg.mozilla.org/mozilla-central/rev/e373c012833a
https://hg.mozilla.org/mozilla-central/rev/2321624fb1b2
https://hg.mozilla.org/mozilla-central/rev/04911f2670f1
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Assignee | ||
Comment 55•8 years ago
|
||
Approval Request Comment
[Feature/Bug causing the regression]: This regression is caused by bug1338137.
[User impact if declined]: Affect lots of website using webAudio/Flash plugIn, the video would not have audio after it was resumed.
[Is this code covered by automated tests?]: Yes
[Has the fix been verified in Nightly?]: No
[Needs manual test from QE? If yes, steps to reproduce]: Yes, see the duplicated bugs for the details, most of those bugs have the STR.
[List of other uplifts needed for the feature/fix]: No
[Is the change risky?]: No
[Why is the change risky/not risky?]: Because the most risky thing is keep this regression alive, and this changes was passed all previous test cases (and the test I added in this patch)
[String changes made/needed]: No
Flags: needinfo?(alwu)
Attachment #8851454 -
Flags: approval-mozilla-aurora?
Updated•8 years ago
|
Blocks: qe-blockpb
Updated•8 years ago
|
status-firefox-esr52:
--- → unaffected
Comment 56•8 years ago
|
||
I have verified that this issue is fixed (the video has audio after focusing an opened tab) in the latest Nightly 55.0a1 using macOS 10.11.6, Ubuntu 16.04 64bit, Windows 10 64bit and Windows 7 64bit.
Comment 57•8 years ago
|
||
Comment on attachment 8851454 [details] [diff] [review]
Bug 1347758 - let outer window decides when need to resume the tab. (aurora)
Fix a regression caused by block-background-audio. Aurora54+.
Attachment #8851454 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Assignee | ||
Comment 59•8 years ago
|
||
Rebase.
Attachment #8851454 -
Attachment is obsolete: true
Flags: needinfo?(alwu)
Assignee | ||
Comment 60•8 years ago
|
||
Comment on attachment 8854679 [details] [diff] [review]
Bug 1347758 - let outer window decides when need to resume the tab. (aurora)
Rebase the patch in comment55.
Attachment #8854679 -
Flags: approval-mozilla-aurora?
Updated•8 years ago
|
Attachment #8854679 -
Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Comment 61•8 years ago
|
||
patching file dom/base/nsDocument.cpp
Hunk #1 FAILED at 1331
1 out of 4 hunks FAILED -- saving rejects to file dom/base/nsDocument.cpp.rej
patching file dom/base/nsIDocument.h
Hunk #2 FAILED at 3167
1 out of 2 hunks FAILED -- saving rejects to file dom/base/nsIDocument.h.rej
patching file dom/html/HTMLMediaElement.cpp
Hunk #3 FAILED at 877
1 out of 5 hunks FAILED -- saving rejects to file dom/html/HTMLMediaElement.cpp.rej
abort: patch failed to apply
Your parent rev is from Wed, 22 Mar 2017. Can you please make sure you're rebasing on top of the tip revision in the future please? It would save us going around in circles like this.
Flags: needinfo?(alwu)
Assignee | ||
Comment 62•8 years ago
|
||
Ah, sorry, It seems I uploaded the wrong patch.
Flags: needinfo?(alwu)
Assignee | ||
Comment 63•8 years ago
|
||
Rebase the patch in comment55.
Attachment #8854679 -
Attachment is obsolete: true
Attachment #8855142 -
Flags: approval-mozilla-aurora?
Comment 64•8 years ago
|
||
Comment on attachment 8855142 [details] [diff] [review]
Bug 1347758 - let outer window decides when need to resume the tab. (aurora)
You can carry over the previous approval if you're just rebasing.
Attachment #8855142 -
Flags: approval-mozilla-aurora?
Comment 65•8 years ago
|
||
bugherder uplift |
Flags: in-testsuite+
You need to log in
before you can comment on or make changes to this bug.
Description
•