Bug 137305

Summary: Calling WebCore::Page::setMediaVolume(0) does not mute videos as expected
Product: WebKit Reporter: Ada Chan <adachan>
Component: MediaAssignee: Ada Chan <adachan>
Status: RESOLVED FIXED    
Severity: Normal CC: adachan, bshafiei, calvaris, commit-queue, eric.carlson, esprehn+autocc, glenn, gyuyoung.kim, jer.noble, philipj, pnormand, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch darin: review+

Description Ada Chan 2014-10-01 11:25:29 PDT
I have a simple test page with a video element in it:

<div id=target style="border: solid;">
    <video src="http://movies.apple.com/movies/us/apple/ipoditunes/2007/touch/ads/apple_ipodtouch_touch_r640-9cie.mov" autoplay controls></video>
</div>

I set the page's media volume to 0 with WKPageSetMediaVolume(0).  But I can still hear the video playing.

Looking at HTMLMediaElement::updateVolume(), it looks like the volume multiplier is only applied if m_volumeInitialized is true, and in this case it's not.
Comment 1 Radar WebKit Bug Importer 2014-10-10 13:32:55 PDT
<rdar://problem/18614742>
Comment 2 Ada Chan 2014-10-21 10:42:50 PDT
Looks like this was broken in http://trac.webkit.org/changeset/154970.
Comment 3 Eric Carlson 2014-10-21 11:20:30 PDT
Removing the "if (m_volumeInitialized)" check in HTMLMediaElement::updateVolume will fix this problem, and I don't *think* it will change the GStreamer behavior because MediaPlayerPrivateGStreamerBase::setStreamVolumeElement does nothing unless m_volumeInitialized is true (HTMLMediaElement::mediaPlayerPlatformVolumeConfigurationRequired).
Comment 4 Philippe Normand 2014-10-21 14:03:11 PDT
Sorry for the breakage :(

Looking at r154970 too, I agree with Eric that it should be enough to remove the "if (m_volumeInitialized)" test from ::updateVolume()
Comment 5 Ada Chan 2014-10-21 15:48:46 PDT
Created attachment 240225 [details]
Patch

Please let me know if there's a way to write a test for this.
Comment 6 Eric Carlson 2014-10-21 17:04:59 PDT
(In reply to comment #5)
> Created attachment 240225 [details]
> Patch
> 
> Please let me know if there's a way to write a test for this.
>
I don't think there is a way to add a test for this change, because any problems will only happen to users of the GTK port with some versions of pulse audio. 

You might be able to add a test for Page::setMediaVolume to ensure that it isn't broken in the future, but that will require fairly invasive changes so I am not sure it is worth while.
Comment 7 Ada Chan 2014-10-21 17:19:22 PDT
Eric and Philippe: thanks for your help!

Committed:
http://trac.webkit.org/changeset/175003