Update capturing document media state when entering b/f cache
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Nov 2019 18:16:04 +0000 (18:16 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Nov 2019 18:16:04 +0000 (18:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=204589

Reviewed by Chris Dumez.

Source/WebCore:

Remove enqueuing the task in configureTrackRendering.
This allows stopTrack to trigger the track rendering configuration and document media state computation.
Covered by updated test.

* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::MediaStreamTrack):
(WebCore::MediaStreamTrack::configureTrackRendering):
(WebCore::MediaStreamTrack::suspend):
(WebCore::MediaStreamTrack::stop): Deleted.
* Modules/mediastream/MediaStreamTrack.h:

LayoutTests:

* http/tests/navigation/page-cache-mediastream-expected.txt:
* http/tests/navigation/page-cache-mediastream.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252890 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/navigation/page-cache-mediastream-expected.txt
LayoutTests/http/tests/navigation/page-cache-mediastream.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h

index 96ef8c5..b8f2fc2 100644 (file)
@@ -1,5 +1,15 @@
 2019-11-26  youenn fablet  <youenn@apple.com>
 
+        Update capturing document media state when entering b/f cache
+        https://bugs.webkit.org/show_bug.cgi?id=204589
+
+        Reviewed by Chris Dumez.
+
+        * http/tests/navigation/page-cache-mediastream-expected.txt:
+        * http/tests/navigation/page-cache-mediastream.html:
+
+2019-11-26  youenn fablet  <youenn@apple.com>
+
         Allow b/f cache in case of connected peer connections
         https://bugs.webkit.org/show_bug.cgi?id=204583
 
index 150da52..031c635 100644 (file)
@@ -7,6 +7,7 @@ pageshow - not from cache
 pagehide - entering cache
 pageshow - from cache
 PASS Page did enter and was restored from the page cache
+page media state is 'IsNotPlaying'
 PASS successfullyParsed is true
 
 TEST COMPLETE
index ef9c351..d5407fb 100644 (file)
@@ -17,6 +17,9 @@ window.addEventListener("pageshow", function(event) {
         testPassed("Page did enter and was restored from the page cache");
         restoredFromPageCache = true;
 
+        if (window.internals)
+            debug("page media state is '" + internals.pageMediaState() + "'");
+
         if (!canvasStream.active)
             testFailed("Canvas stream is not active");
 
index 2b85fb1..ca69048 100644 (file)
@@ -1,5 +1,23 @@
 2019-11-26  youenn fablet  <youenn@apple.com>
 
+        Update capturing document media state when entering b/f cache
+        https://bugs.webkit.org/show_bug.cgi?id=204589
+
+        Reviewed by Chris Dumez.
+
+        Remove enqueuing the task in configureTrackRendering.
+        This allows stopTrack to trigger the track rendering configuration and document media state computation.
+        Covered by updated test.
+
+        * Modules/mediastream/MediaStreamTrack.cpp:
+        (WebCore::MediaStreamTrack::MediaStreamTrack):
+        (WebCore::MediaStreamTrack::configureTrackRendering):
+        (WebCore::MediaStreamTrack::suspend):
+        (WebCore::MediaStreamTrack::stop): Deleted.
+        * Modules/mediastream/MediaStreamTrack.h:
+
+2019-11-26  youenn fablet  <youenn@apple.com>
+
         Allow b/f cache in case of connected peer connections
         https://bugs.webkit.org/show_bug.cgi?id=204583
 
index 46cfae3..773a1dd 100644 (file)
@@ -70,7 +70,6 @@ Ref<MediaStreamTrack> MediaStreamTrack::create(ScriptExecutionContext& context,
 MediaStreamTrack::MediaStreamTrack(ScriptExecutionContext& context, Ref<MediaStreamTrackPrivate>&& privateTrack)
     : ActiveDOMObject(&context)
     , m_private(WTFMove(privateTrack))
-    , m_taskQueue(context)
     , m_isCaptureTrack(m_private->isCaptureTrack())
     , m_mediaSession(PlatformMediaSession::create(*this))
 {
@@ -535,24 +534,16 @@ void MediaStreamTrack::trackEnabledChanged(MediaStreamTrackPrivate&)
 
 void MediaStreamTrack::configureTrackRendering()
 {
-    m_taskQueue.enqueueTask([this] {
-        if (m_mediaSession && m_private->type() == RealtimeMediaSource::Type::Audio)
-            m_mediaSession->canProduceAudioChanged();
+    if (m_mediaSession && m_private->type() == RealtimeMediaSource::Type::Audio)
+        m_mediaSession->canProduceAudioChanged();
 
-        if (auto document = this->document())
-            document->updateIsPlayingMedia();
-    });
+    if (auto document = this->document())
+        document->updateIsPlayingMedia();
 
     // 4.3.1
     // ... media from the source only flows when a MediaStreamTrack object is both unmuted and enabled
 }
 
-void MediaStreamTrack::stop()
-{
-    stopTrack();
-    m_taskQueue.close();
-}
-
 const char* MediaStreamTrack::activeDOMObjectName() const
 {
     return "MediaStreamTrack";
index b1298e1..337b8f7 100644 (file)
@@ -175,7 +175,7 @@ private:
     Document* document() const;
 
     // ActiveDOMObject API.
-    void stop() final;
+    void stop() final { stopTrack(); }
     const char* activeDOMObjectName() const override;
     void suspend(ReasonForSuspension) final;
 
@@ -216,7 +216,6 @@ private:
 
     MediaTrackConstraints m_constraints;
     std::unique_ptr<DOMPromiseDeferred<void>> m_promise;
-    GenericTaskQueue<ScriptExecutionContext> m_taskQueue;
     GenericTaskQueue<Timer> m_eventTaskQueue;
 
     bool m_ended { false };