Title: [276760] releases/WebKitGTK/webkit-2.32
Revision
276760
Author
[email protected]
Date
2021-04-29 01:33:22 -0700 (Thu, 29 Apr 2021)

Log Message

Merge r275600 - [GStreamer] Videos start playing muted in epiphany with no unmute icon visible in tab, webkit_web_view_get_is_muted() returns incorrect results
https://bugs.webkit.org/show_bug.cgi?id=223195

Patch by Philippe Normand <[email protected]> on 2021-04-07
Source/WebCore:

Reviewed by Eric Carlson.

For GStreamer ports the semantics of IsPlayingAudio slightly differ from Apple ports. The
webkit_web_view_is_playing_audio() API is expected to return true if a page is producing
audio even though it might be muted.

The second change affects the private player mute state when the page mute state has been
updated.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaState const):
(WebCore::HTMLMediaElement::pageMutedStateDidChange):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: Logging improvements.
(WebCore::MediaPlayerPrivateGStreamer::isMuted const):
(WebCore::MediaPlayerPrivateGStreamer::volume const):
(WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfVolumeChange):
(WebCore::MediaPlayerPrivateGStreamer::setMuted):
(WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfMute):

Tools:

Reviewed by Michael Catanzaro.

Adapt is-playing test, after muting the page, webkit_web_view_is_playing_audio() should
still return TRUE.

* TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
(IsPlayingAudioWebViewTest::periodicallyCheckIsPlayingForAWhile):
(testWebViewIsPlayingAudio):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog (276759 => 276760)


--- releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog	2021-04-29 08:33:12 UTC (rev 276759)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog	2021-04-29 08:33:22 UTC (rev 276760)
@@ -1,3 +1,27 @@
+2021-04-07  Philippe Normand  <[email protected]>
+
+        [GStreamer] Videos start playing muted in epiphany with no unmute icon visible in tab, webkit_web_view_get_is_muted() returns incorrect results
+        https://bugs.webkit.org/show_bug.cgi?id=223195
+
+        Reviewed by Eric Carlson.
+
+        For GStreamer ports the semantics of IsPlayingAudio slightly differ from Apple ports. The
+        webkit_web_view_is_playing_audio() API is expected to return true if a page is producing
+        audio even though it might be muted.
+
+        The second change affects the private player mute state when the page mute state has been
+        updated.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::mediaState const):
+        (WebCore::HTMLMediaElement::pageMutedStateDidChange):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: Logging improvements.
+        (WebCore::MediaPlayerPrivateGStreamer::isMuted const):
+        (WebCore::MediaPlayerPrivateGStreamer::volume const):
+        (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfVolumeChange):
+        (WebCore::MediaPlayerPrivateGStreamer::setMuted):
+        (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfMute):
+
 2021-04-06  Philippe Normand  <[email protected]>
 
         REGRESSION(r274358) [GStreamer] http/tests/images/mp4-partial-load.html is flaky crashing inside GStreamer

Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/html/HTMLMediaElement.cpp (276759 => 276760)


--- releases/WebKitGTK/webkit-2.32/Source/WebCore/html/HTMLMediaElement.cpp	2021-04-29 08:33:12 UTC (rev 276759)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/html/HTMLMediaElement.cpp	2021-04-29 08:33:22 UTC (rev 276760)
@@ -7672,7 +7672,14 @@
     if (!isPlaying())
         return state;
 
-    if (hasAudio && !muted() && volume())
+    // For GStreamer ports the semantics of IsPlayingAudio slightly differ from Apple ports. The
+    // webkit_web_view_is_playing_audio() API is expected to return true if a page is producing
+    // audio even though it might be muted.
+    bool isPlayingAudio = hasAudio && volume();
+#if !USE(GSTREAMER)
+    isPlayingAudio = isPlayingAudio && !muted();
+#endif
+    if (isPlayingAudio)
         state |= IsPlayingAudio;
 
     if (hasActiveVideo)
@@ -7729,9 +7736,10 @@
 
 void HTMLMediaElement::pageMutedStateDidChange()
 {
-    updateVolume();
-
     if (Page* page = document().page()) {
+        // Propagate the new state to the platform player.
+        if (m_player)
+            m_player->setMuted(page->isAudioMuted());
         if (hasAudio() && !muted() && page->isAudioMuted())
             userDidInterfereWithAutoplay();
     }

Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (276759 => 276760)


--- releases/WebKitGTK/webkit-2.32/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2021-04-29 08:33:12 UTC (rev 276759)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2021-04-29 08:33:22 UTC (rev 276760)
@@ -1240,7 +1240,7 @@
 
     gboolean isMuted;
     g_object_get(m_volumeElement.get(), "mute", &isMuted, nullptr);
-    GST_INFO_OBJECT(pipeline(), "Player is muted: %s", boolForPrinting(!!isMuted));
+    GST_INFO_OBJECT(pipeline(), "Player is muted: %s", boolForPrinting(isMuted));
     return isMuted;
 }
 
@@ -1675,7 +1675,9 @@
     if (!m_volumeElement)
         return 0;
 
-    return gst_stream_volume_get_volume(m_volumeElement.get(), GST_STREAM_VOLUME_FORMAT_LINEAR);
+    auto volume = gst_stream_volume_get_volume(m_volumeElement.get(), GST_STREAM_VOLUME_FORMAT_LINEAR);
+    GST_DEBUG_OBJECT(pipeline(), "Volume: %f", volume);
+    return volume;
 }
 
 void MediaPlayerPrivateGStreamer::notifyPlayerOfVolumeChange()
@@ -1682,13 +1684,15 @@
 {
     if (!m_player || !m_volumeElement)
         return;
-    double volume;
-    volume = gst_stream_volume_get_volume(m_volumeElement.get(), GST_STREAM_VOLUME_FORMAT_LINEAR);
-    // get_volume() can return values superior to 1.0 if the user
-    // applies software user gain via third party application (GNOME
-    // volume control for instance).
-    volume = CLAMP(volume, 0.0, 1.0);
-    m_player->volumeChanged(static_cast<float>(volume));
+
+    // get_volume() can return values superior to 1.0 if the user applies software user gain via
+    // third party application (GNOME volume control for instance).
+    auto oldVolume = this->volume();
+    auto volume = CLAMP(oldVolume, 0.0, 1.0);
+
+    if (volume != oldVolume)
+        GST_DEBUG_OBJECT(pipeline(), "Volume value (%f) was not in [0,1] range. Clamped to %f", oldVolume, volume);
+    m_player->volumeChanged(volume);
 }
 
 void MediaPlayerPrivateGStreamer::volumeChangedCallback(MediaPlayerPrivateGStreamer* player)
@@ -1719,7 +1723,7 @@
     if (!m_volumeElement || shouldMute == isMuted())
         return;
 
-    GST_INFO_OBJECT(pipeline(), "Muted? %s", boolForPrinting(shouldMute));
+    GST_INFO_OBJECT(pipeline(), "Setting muted state to %s", boolForPrinting(shouldMute));
     g_object_set(m_volumeElement.get(), "mute", shouldMute, nullptr);
 }
 
@@ -1730,6 +1734,7 @@
 
     gboolean muted;
     g_object_get(m_volumeElement.get(), "mute", &muted, nullptr);
+    GST_DEBUG_OBJECT(pipeline(), "Notifying player of new mute value: %s", boolForPrinting(muted));
     m_player->muteChanged(static_cast<bool>(muted));
 }
 

Modified: releases/WebKitGTK/webkit-2.32/Tools/ChangeLog (276759 => 276760)


--- releases/WebKitGTK/webkit-2.32/Tools/ChangeLog	2021-04-29 08:33:12 UTC (rev 276759)
+++ releases/WebKitGTK/webkit-2.32/Tools/ChangeLog	2021-04-29 08:33:22 UTC (rev 276760)
@@ -1,3 +1,17 @@
+2021-04-07  Philippe Normand  <[email protected]>
+
+        [GStreamer] Videos start playing muted in epiphany with no unmute icon visible in tab, webkit_web_view_get_is_muted() returns incorrect results
+        https://bugs.webkit.org/show_bug.cgi?id=223195
+
+        Reviewed by Michael Catanzaro.
+
+        Adapt is-playing test, after muting the page, webkit_web_view_is_playing_audio() should
+        still return TRUE.
+
+        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:
+        (IsPlayingAudioWebViewTest::periodicallyCheckIsPlayingForAWhile):
+        (testWebViewIsPlayingAudio):
+
 2021-03-18  Carlos Garcia Campos  <[email protected]>
 
         [WPE] Bump API version when building with libsoup3

Modified: releases/WebKitGTK/webkit-2.32/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp (276759 => 276760)


--- releases/WebKitGTK/webkit-2.32/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp	2021-04-29 08:33:12 UTC (rev 276759)
+++ releases/WebKitGTK/webkit-2.32/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp	2021-04-29 08:33:22 UTC (rev 276760)
@@ -44,6 +44,25 @@
         g_signal_connect(m_webView, "notify::is-playing-audio", G_CALLBACK(isPlayingAudioChanged), this);
         g_main_loop_run(m_mainLoop);
     }
+
+    void periodicallyCheckIsPlayingForAWhile()
+    {
+        m_tickCount = 0;
+        g_timeout_add(50, [](gpointer userData) -> gboolean {
+            auto* test = static_cast<IsPlayingAudioWebViewTest*>(userData);
+            g_assert_true(webkit_web_view_is_playing_audio(test->m_webView));
+            test->m_tickCount++;
+            if (test->m_tickCount >= 10) {
+                test->quitMainLoop();
+                return G_SOURCE_REMOVE;
+            }
+            return G_SOURCE_CONTINUE;
+        }, this);
+        g_main_loop_run(m_mainLoop);
+    }
+
+private:
+    uint32_t m_tickCount { 0 };
 };
 
 static WebKitTestServer* gServer;
@@ -1114,6 +1133,7 @@
 
     // Initially, web views should always report no audio being played.
     g_assert_false(webkit_web_view_is_playing_audio(test->m_webView));
+    g_assert_false(webkit_web_view_get_is_muted(test->m_webView));
 
     GUniquePtr<char> resourcePath(g_build_filename(Test::getResourcesDir(Test::WebKit2Resources).data(), "file-with-video.html", nullptr));
     GUniquePtr<char> resourceURL(g_filename_to_uri(resourcePath.get(), nullptr, nullptr));
@@ -1126,6 +1146,15 @@
         test->waitUntilIsPlayingAudioChanged();
     g_assert_true(webkit_web_view_is_playing_audio(test->m_webView));
 
+    // Mute the page, webkit_web_view_is_playing_audio() should still return TRUE.
+    webkit_web_view_set_is_muted(test->m_webView, TRUE);
+    g_assert_true(webkit_web_view_get_is_muted(test->m_webView));
+    test->periodicallyCheckIsPlayingForAWhile();
+    g_assert_true(webkit_web_view_is_playing_audio(test->m_webView));
+    webkit_web_view_set_is_muted(test->m_webView, FALSE);
+    g_assert_false(webkit_web_view_get_is_muted(test->m_webView));
+    g_assert_true(webkit_web_view_is_playing_audio(test->m_webView));
+
     // Pause the video, and check again.
     test->runJavaScriptAndWaitUntilFinished("document.getElementById('test-video').pause();", nullptr);
     if (webkit_web_view_is_playing_audio(test->m_webView))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to