VOOZH about

URL: https://bugzilla.mozilla.org/show_bug.cgi?id=1663128

⇱ 1663128 - SMTC interface doesn't be reset completely (show firefox.exe)


Closed Bug 1663128 Opened 5 years ago Closed 5 years ago

SMTC interface doesn't be reset completely (show firefox.exe)

SMTC interface doesn't be reset completely (show firefox.exe)
Core
Audio/Video: Playback
Trunk
Desktop
All
defect
Points:
---
VERIFIED FIXED
VERIFIED
FIXED
83 Branch
Iteration:
---
a11y-review
Accessibility Severity
Performance Impact
Size Estimate
Webcompat Priority
Webcompat Score
Tracking Status
firefox80 --- disabled
firefox81 --- wontfix
firefox82 --- wontfix
firefox83 --- verified
Tracking Status
relnote-firefox
thunderbird_esr115
thunderbird_esr140
firefox-esr115
firefox-esr140
firefox-esr153
firefox80
firefox81
firefox82
firefox83
firefox152
firefox153
firefox154
---
QA Whiteboard:
---
Has STR:
---
Change Request:
---
Bug Flags:
Signature:
None
This bug is publicly visible.

 
Attached video MediaKey.mp4 β€” Details

[Affected versions]:
Beta 81.0b5

[Affected platforms]:
Platforms: Windows 10

Steps :

  1. Launch the Firefox browser and reach https://www.youtube.com/watch?v=dl6pWnbUWCY
  2. Start the video and use loop in order for the short video to keep playing over and over.
  3. Open a new video in a new tab and use the Media control key to Pause it.
  4. Open a third video in a new tab and use the Media control key to pause it.
  5. Close the two separate tabs until only the tab with the short video remains.
  6. Use the Media control key in order to pause / play the short video.

Expected Results :
The Virtual control interface should not be displayed since the short video cannot be controlled from the Media key.

Actual Results :
The Virtual Control interface is displayed with greyed out buttons and the firefox.exe text displayed.

Reporter

Comment 1

β€’
5 years ago

I think this is an S3 severity issue, maybe even an S4 since it only happens in specific conditions and it will not affect the users experience.

Reporter

Comment 2

β€’
5 years ago
Attached file logs.zip β€” Details

Attached some log files hoping it helps.

Reporter

Comment 3

β€’
5 years ago

I also have a different scenario for this exact same issue but please let me know if you would like me to log a separate issue for it.

  1. Start the Firefox browser and play a Youtube video with sound.
  2. Use the Media control key from the keyboard a few times.
  3. Reach Youtube in a private window.
  4. Mute the video before starting it.
  5. Hit the Media control button in order to start/pause the video from the normal window.
  6. Close the Normal window.
  7. Hit the Media control key in order to start/pause the muted video.

Expected results:
The Virtual control interface should not be displayed at all since the user cannot control the muted video.

Actual Results:
The Virtual control interface is displayed with the firefox.exe information displayed and greyed out buttons.

Flags: needinfo?(cchang)

Thanks for the log you provided!

I can reproduce this bug now. I'll let you know if I need your help.

In log.txt.child-4.moz_log.0, I do find Not listening because media's duration 2.981000 is too short, which indicates that short video is not being controlled. It seems the virtual control interface stays on the screen even no media is being controlled. I can reproduce this bug without opening a short-duration video by the following steps

  1. Play an audible video whose duration is at least 3 seconds in a tab
  2. Open an empty tab
  3. Go back to the tab contains video
  4. Press any media key (e.g. volume+/-) that can prompt the virtual control interface
  5. While the virtual control interface stays, close the tab playing video
  6. Press volume+/- key

Now the virtual control interface stays with a title firefox.exe. There is no any video now. However, if volume+/- key is pressed again, the virtual control interface pop up again, with the title firefox.exe.

I can reproduce this on Windows 10, but not on Ubuntu 18.04. I suspect it's a windows-only issue. I'll investigate what happens.

Flags: needinfo?(cchang)
Severity: -- β†’ S2
Priority: -- β†’ P3
Assignee

Comment 5

β€’
5 years ago

I can reproduce this issue, but it's still no clear what happened to me. If I start normal videos first, and start short duration video, then the interface would be reset completely. Or if you don't pause normal video, and close them directly, this issue also doesn't happen.

I guess we didn't reset SMTC's interface correctly under that situation, I've tried to call ClearAll() [1] when we close the SMTC, but it didn't work. I would continue to check how we can fix that.

[1] https://docs.microsoft.com/en-us/previous-versions/windows/desktop/mediatransport/isystemmediatransportcontrolsdisplayupdater-clearall

Assignee: nobody β†’ alwu
Severity: S2 β†’ S4

Chrome uses ISystemMediaTransportControls::put_IsEnabled [1] to close the SystemMediaTransportControls (or SMTC) panel [2], but somehow it doesn't work for us. I tried to destroy the window-handle bound to SMTC [3] when there is no more media elements in Firefox but it didn't work either. One difference is that chrome uses the existing singleton window-handle instead of creating a new one [4].

Molly, do you have idea what's going on? I wonder if we do something wrong when creating a window for SMTC [5], since the SMTC panel can still pop up even it's bound window-handle is destroyed.

Does Firefox has a singleton window-handle used in parent process? Do you happen to know how to get that window handle? I'd like to try using a similar way chrome applied to see if the SMTC panel will be disappeared or not. Or it's ok to create a new window-handle in this case?

[1] https://docs.microsoft.com/en-us/previous-versions/windows/desktop/mediatransport/isystemmediatransportcontrols-put-isenabled?redirectedfrom=MSDN
[2] https://source.chromium.org/chromium/chromium/src/+/master:components/system_media_controls/win/system_media_controls_win.cc;l=283-286;drc=aeb70b905ac38796b9801ec6a0230e71005c8b6b;bpv=1;bpt=0
[3] https://searchfox.org/mozilla-central/rev/62c443a7c801ba9672de34c2867ec1665a4bbe67/widget/windows/WindowsSMTCProvider.cpp#116
[4] https://source.chromium.org/chromium/chromium/src/+/master:components/system_media_controls/win/system_media_controls_win.cc;l=79;drc=fd31128cb7b8cee546f71e7051c7cd81ff7acd9b
[5] https://searchfox.org/mozilla-central/rev/62c443a7c801ba9672de34c2867ec1665a4bbe67/widget/windows/WindowsSMTCProvider.cpp#102-133

Flags: needinfo?(mhowell)

Another interesting thing I found is that if the enabled states of the media-key buttons are never changed once they are set, then we are free from this problem (e.g., enable all the buttons when opening SMTC, do nothing in SetSupportedMediaKeys, disable all the buttons when closing SMTC). That's weird.

Note that I saw this kind of panel during development as I only had registered the interface and called put_IsEnabled(true).
So it's like neither UpdateButtons, SetPlaybackState etc are ever called (for that instance or maybe after this has been reset by another media being done).

Could this be a "race condition", as in Open -> Close -> Set Metadata (where the Close is called by a previous media ending).
At least I think it's not about the panel creation in itself, but rather that there is a panel, whose state/metadata is not set correctly, right?
This would on one hand match to the strange conditions under which this happens, but I'm just guessing there.

It never happens for a single video at a time, right?

(In reply to Marc Streckfuß [:MeFisto94] from comment #8)

It never happens for a single video at a time, right?

This could be reproduced by a single video. See #comment 4. But Set Metadata could be called several times indeed. We will set some empty data when there is no more media.

Open , Close, SetPlaybackState, SetMediaMetadata, SetSupportedMediaKeys are all on the main thread, so data racing won't happen in the Firefox end.

I've worked out a workaround here. It seems we can avoid this problem if put_IsEnabled(false) is called at the same time when all buttons on the SMTC panel is disabled via put_Is*Enabled. It seems to me this is a Windows bug.

Here is a straightforward workaround patch and here is an alternative that looks slightly better.

It works on my Windows 10 machine but it's better to confirm that works on other machines.

Flags: needinfo?(mhowell)
Reporter

Comment 11

β€’
5 years ago

Hi, we are testing this feature in Beta now and after we control any video with sound using the media key, load a different video in a new tab but muted and close the other tab, every time we hit the Pause/Play media key on the keyboard the Virtual Control interface is displayed with the firefox.exe text. I dont think this is a new issue I think its related to this one but please let me know if we should log a separate issue for it.

  1. Launch the Firefox browser and start a video on youtube with sound.
  2. Use the Pause / Play media key in order to control the video.
  3. Load a separate video in a new tab and mute it before starting the video.
  4. Close the first tab.
  5. Hit the media keys on the keyboard in order to control the muted video.

Expected Results:
The Virtual control interface should not be displayed at all since the video cannot be controlled from the media keys.

@Alastor , please let me know if we should log a separate issue for this.

Flags: needinfo?(cchang)
Flags: needinfo?(alwu)
Reporter

Comment 12

β€’
5 years ago

The Virtual Control interface is also displayed on Gifs if the user controlled any video before reaching the page :
https://giphy.com/gifs/series-canal-killing-eve-canalplus-sries-H3GjxERjsR4YXIihsM

I can log a separate issue for this as well but it does seem its the same issue.

Assignee

Comment 13

β€’
5 years ago

Yes, they look like same issue for me. I guess the issue is we didn't reset the interface, so it keeps displaying. I will start debugging this bug today, to see if we have other way to sove it completely. Thank you.

Flags: needinfo?(cchang)
Flags: needinfo?(alwu)
Assignee

Updated

β€’
5 years ago
Severity: S4 β†’ S3
Priority: P3 β†’ P1
Summary: The Virtual Control interface is displayed for short videos β†’ SMTC interface doesn't be reset completely (show firefox.exe)

Comment 18

β€’
5 years ago
Pushed by alwu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1f6e8e343055 part1 : remove unused function 'SetControlledTabBrowsingContextId()'. r=chunmin https://hg.mozilla.org/integration/autoland/rev/6791eacd4868 part2 : let MediaControlService determine when we should open/close the event source. r=chunmin https://hg.mozilla.org/integration/autoland/rev/0ea9bcad0ff8 part3 : the event source should do the cleanup when it closes. r=chunmin https://hg.mozilla.org/integration/autoland/rev/c9bd215fdafa part4 : enable SMTC after finishing other initializations. r=chunmin
Assignee

Updated

β€’
5 years ago
Flags: needinfo?(alwu)

Comment 20

β€’
5 years ago
Pushed by alwu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/92a26a171220 part1 : remove unused function 'SetControlledTabBrowsingContextId()'. r=chunmin https://hg.mozilla.org/integration/autoland/rev/00ff29a35291 part2 : let MediaControlService determine when we should open/close the event source. r=chunmin https://hg.mozilla.org/integration/autoland/rev/571dc734bba1 part3 : the event source should do the cleanup when it closes. r=chunmin https://hg.mozilla.org/integration/autoland/rev/4bda24c82a0b part4 : enable SMTC after finishing other initializations. r=chunmin
Assignee

Comment 22

β€’
5 years ago
β€’

Comment on attachment 9179076 [details]
Bug 1663128 - part1 : remove unused function 'SetControlledTabBrowsingContextId()'.

Beta/Release Uplift Approval Request

  • User impact if declined: On Windows, when users play media, it would show a virtual control interface to allow them to control media via its virtual button. That should be removed when user closes the tab which was playing audio.

But currently that wasn't removed correctly and would display firefox.exe, which can only be removed after users restart Firefox.

  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: Follow comment0 or comment4.
  • List of other uplifts needed: All patches
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): It doesn't introduce behavior change, but only perform a correct steps to remove the virtual interface.
  • String changes made/needed:
Attachment #9179076 - Flags: approval-mozilla-beta?
Assignee

Updated

β€’
5 years ago
Attachment #9179077 - Flags: approval-mozilla-beta?
Attachment #9179078 - Flags: approval-mozilla-beta?
Attachment #9179080 - Flags: approval-mozilla-beta?
Flags: qe-verify+

We're about to build the last beta for 82, and this affects 81 already, so I'd prefer to let it ride the trains.

Attachment #9179076 - Flags: approval-mozilla-beta? β†’ approval-mozilla-beta-
Attachment #9179077 - Flags: approval-mozilla-beta? β†’ approval-mozilla-beta-
Attachment #9179078 - Flags: approval-mozilla-beta? β†’ approval-mozilla-beta-
Attachment #9179080 - Flags: approval-mozilla-beta? β†’ approval-mozilla-beta-
QA Whiteboard: [qa-triaged]
Reporter

Comment 24

β€’
5 years ago

This issue is Verified as Fixed in our latest Nightly build 83.0a1 (2020-10-08) on Windows 10 and Ubuntu.

Status: RESOLVED β†’ VERIFIED
QA Whiteboard: [qa-triaged]
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.