Closed Bug 1611748 Opened 5 years ago Closed 4 years ago

video does not play in a dynamically created iframe (friendly)

Categories

(Core :: Audio/Video: Playback, defect, P3)

72 Branch
defect

Tracking

()

RESOLVED WORKSFORME
Tracking Status
firefox-esr68 --- unaffected
firefox72 --- wontfix
firefox73 --- wontfix
firefox74 --- wontfix
firefox75 --- wontfix
firefox76 --- wontfix
firefox84 --- wontfix
firefox85 --- wontfix
firefox86 --- wontfix

People

(Reporter: vadim.mazzherin, Assigned: alwu)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36

Steps to reproduce:

Example with the bug:
https://codepen.io/eldengrof/pen/yLywjEE

  1. We created an iframe
    document.querySelector('.slot').innerHTML = '<iframe...'

  2. Put the video tag inside
    iFrameDocument.write(videoWithScript);

  3. After calling the "play" method, we have a promise with a permanent pending state
    var promise = video.play();

  4. Video does not play...

I tried using different methods for creating an iframe, video tag, and the result is the same. The video can't be started by the user or code.

But, if I go to another tab and go back, then the video starts working.

Reproduced on my local machine and in the Browserstack

Actual results:

video does not play

Expected results:

the video must be played

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Audio/Video: Playback
Product: Firefox → Core
Status: UNCONFIRMED → NEW
Has Regression Range: --- → yes
Has STR: --- → yes
Ever confirmed: true
Keywords: regression
Regressed by: 1578615

Interestingly, the video starts when browser is resized(switch maximize <> normal sizemode).

Assignee: nobody → alwu
Priority: -- → P2

According to our priority for media team, I would like to move it to P3 because now I don't know if it can be fixed in this cycle.

Priority: P2 → P3

Whenever document becomes visible, we should activate media component in order to update its outerwindow's suspend state, which is used to decide whether we should delay media playback.

This test is modified from the test user reported [1]

[1] https://codepen.io/eldengrof/pen/yLywjEE

Okay, although current patch can fix the problem, it would break delay autoplay in most other situations. The reason is that, I observed that we would create a document, which I don't know where it come from and it's not the page document, before creating a real documet, and the problem is that that document was visible at the time we create it, and would become hidden after a short while.

But it would make us to resume the whole window because we think the document has become visible! I remember I had hear this weird behavior at the time I implemented this feature, but I can't remember why this would happen.

So I would try another way to see if I can fix this issue.

Before doing this, we have to do some clean-up and change for audio channel code...

I found a weird behavior which I don't know is expected behavior or not. This issue won't happen on every dynamically created iframe, it would only happen on iframe with src="javascript:void(0)".

Here are two test cases, in the first one [1] we can start video successfully, but we would fail to start video on the second one [2]. And I found that Document::UpdateVisibilityState() would be called for the iframe in the first test case, but in the second one, this function didn't be called, so we couldn't activate media.

I wonder if Document::UpdateVisibilityState() should also be called in the second test case?

[1] video can start
https://codepen.io/alwu/pen/JjdEvmW

[2] video can't start
https://codepen.io/alwu/pen/rNVyPyL


Hi, Smaug,
May I have you opinion for this issue?
Thank you.

Flags: needinfo?(bugs)

(In reply to Alastor Wu [:alwu] from comment #7)

Okay, although current patch can fix the problem, it would break delay autoplay in most other situations. The reason is that, I observed that we would create a document, which I don't know where it come from and it's not the page document, before creating a real documet, and the problem is that that document was visible at the time we create it, and would become hidden after a short while.

There is usually about:blank document created to an iframe before the "real" document is loaded there.
That implicit about:blank is created on demand whenever someone tries to access the document of the docshell and there isn't anything there yet. Same happens with window.open(). Such newly opened window has about:blank first.

[1] video can start
https://codepen.io/alwu/pen/JjdEvmW
So here there is just the about:blank I think

[2] video can't start
https://codepen.io/alwu/pen/rNVyPyL
Here iframeDoc points to the about:blank but then a new document replaces it once javascript: is loaded.

Hmm, but I see video playing in both cases.

But I see video playing in both cases

Flags: needinfo?(bugs)
See Also: → 1685163

I found that this issue is no longer being able to be reproduced, so it'd be better to close that one and work on bug 1685163 instead.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: