[ Mac WK2 ] Layout Test fast/mediastream/MediaStreamTrack-getSettings.html is a flaky...
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Oct 2019 18:10:11 +0000 (18:10 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Oct 2019 18:10:11 +0000 (18:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196400
<rdar://problem/49567579>

Reviewed by Youenn Fablet.

Source/WebCore:

No new tests, this fixes a broken test.

* platform/mediastream/mac/MockRealtimeAudioSourceMac.h:
* platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
(WebCore::MockRealtimeAudioSourceMac::reconfigure): Reconfigure buffers as well.
(WebCore::MockRealtimeAudioSourceMac::render): Call reconfigure if the buffer isn't
configured correctly.
(WebCore::MockRealtimeAudioSourceMac::settingsDidChange): Call reconfigure.

* platform/mock/MockRealtimeAudioSource.cpp:
(WebCore::MockRealtimeAudioSource::MockRealtimeAudioSource): Set sample rate to default.

LayoutTests:

* fast/mediastream/MediaStreamTrack-getSettings.html: Cleanup test.
* platform/mac-wk2/TestExpectations: Unskip test.

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

LayoutTests/ChangeLog
LayoutTests/fast/mediastream/MediaStreamTrack-getSettings.html
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/mediastream/mac/MockRealtimeAudioSourceMac.mm
Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp

index 5e9793e..ddbecd5 100644 (file)
@@ -1,3 +1,14 @@
+2019-10-09  Eric Carlson  <eric.carlson@apple.com>
+
+        [ Mac WK2 ] Layout Test fast/mediastream/MediaStreamTrack-getSettings.html is a flaky failure
+        https://bugs.webkit.org/show_bug.cgi?id=196400
+        <rdar://problem/49567579>
+
+        Reviewed by Youenn Fablet.
+
+        * fast/mediastream/MediaStreamTrack-getSettings.html: Cleanup test.
+        * platform/mac-wk2/TestExpectations: Unskip test.
+
 2019-10-09  Dean Jackson  <dino@apple.com>
 
         Layout Test webgl/2.0.0/conformance/glsl/misc/shaders-with-invariance.html is failing since ANGLE roll
index b35fbd3..d86458f 100644 (file)
@@ -4,8 +4,7 @@
         <script src="../../resources/js-test-pre.js"></script>
         <script src="./resources/getUserMedia-helper.js"></script>
         <script>
-            var mediaStream;
-            var track;
+            let track;
 
             function limitPrecision(value, precision)
             {
                 return value;
             }
             
+            function forEachNativeProperty(list, func)
+            {
+                for (let property in list) {
+                    if (list.hasOwnProperty(property, list[property]) || list.__proto__.hasOwnProperty(property))
+                        func(property, list[property]);
+                }
+            }
+            
             function listTrackSettings(track)
             {
                 debug(`${track.kind} track settings:`);
-                settings = track.getSettings();
-                for (var property in settings) {
-                    if (settings.hasOwnProperty(property) || settings.__proto__.hasOwnProperty(property)) {
-                        if (property == "deviceId")
-                            value = "&lt;UUID>";
-                        else
-                            value = limitPrecision(settings[property], 3);
-                        debug(`  settings.${property} = ${value}`);
-                    }
-                }
+                forEachNativeProperty(track.getSettings(), (property, value) => {
+                    if (property == "deviceId")
+                        value = "&lt;UUID>";
+                    else
+                        value = limitPrecision(value, 3);
+                    debug(`  settings.${property} = ${value}`);
+                });
 
                 debug("");
             }
             function checkTrackSettings(t)
             {
                 track = t;
-
-                capabilities = track.getCapabilities();
-                settings = track.getSettings();
-                for (var property in settings) {
-                    if (settings.hasOwnProperty(property) || settings.__proto__.hasOwnProperty(property)) {
-                        shouldBeTrue(`"${property}" in track.getCapabilities()`);
-                    }
-                }
+                forEachNativeProperty(track.getSettings(), (property, value) => {
+                    shouldBeTrue(`"${property}" in track.getCapabilities()`);
+                });
             }
 
-            function gotStream(stream)
+            async function start()
             {
-                mediaStream = stream;
+                description("Tests MediaStreamTrack.getSettings.");
+                let stream = await navigator.mediaDevices.getUserMedia({audio:true, video:true});
 
-                listTrackSettings(mediaStream.getVideoTracks()[0]);
-                listTrackSettings(mediaStream.getAudioTracks()[0]);
+                listTrackSettings(stream.getVideoTracks()[0]);
+                listTrackSettings(stream.getAudioTracks()[0]);
 
                 debug('According to the spec: "[every setting] MUST be a member of the set defined for that property by getCapabilities()"<br>');
-                checkTrackSettings(mediaStream.getVideoTracks()[0]);
-                checkTrackSettings(mediaStream.getAudioTracks()[0]);
+                checkTrackSettings(stream.getVideoTracks()[0]);
+                checkTrackSettings(stream.getAudioTracks()[0]);
                 finishJSTest();
             }
 
-            function start()
-            {
-                description("Tests MediaStreamTrack.getSettings.");
-                getUserMedia("allow", {audio:true, video:true}, gotStream);
-            }
-
             window.jsTestIsAsync = true;
             window.successfullyParsed = true;
         </script>
index c4f7f6d..88b0756 100644 (file)
@@ -907,8 +907,6 @@ webkit.org/b/194826 http/tests/resourceLoadStatistics/do-not-block-top-level-nav
 
 webkit.org/b/194916 fast/mediastream/MediaStream-video-element.html [ Pass Failure ]
 
-webkit.org/b/196400 fast/mediastream/MediaStreamTrack-getSettings.html [ Pass Failure ]
-
 webkit.org/b/196403 imported/w3c/web-platform-tests/mediacapture-record/MediaRecorder-stop.html [ Pass Failure ]
 
 webkit.org/b/187391 accessibility/mac/async-increment-decrement-action.html [ Skip ]
index cbd5658..7477731 100644 (file)
@@ -1,3 +1,23 @@
+2019-10-09  Eric Carlson  <eric.carlson@apple.com>
+
+        [ Mac WK2 ] Layout Test fast/mediastream/MediaStreamTrack-getSettings.html is a flaky failure
+        https://bugs.webkit.org/show_bug.cgi?id=196400
+        <rdar://problem/49567579>
+
+        Reviewed by Youenn Fablet.
+
+        No new tests, this fixes a broken test.
+
+        * platform/mediastream/mac/MockRealtimeAudioSourceMac.h:
+        * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm:
+        (WebCore::MockRealtimeAudioSourceMac::reconfigure): Reconfigure buffers as well.
+        (WebCore::MockRealtimeAudioSourceMac::render): Call reconfigure if the buffer isn't
+        configured correctly.
+        (WebCore::MockRealtimeAudioSourceMac::settingsDidChange): Call reconfigure.
+
+        * platform/mock/MockRealtimeAudioSource.cpp:
+        (WebCore::MockRealtimeAudioSource::MockRealtimeAudioSource): Set sample rate to default.
+
 2019-10-09  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed, address Darin's post-landing comments for r250912.
index 611ac16..07d6cd4 100644 (file)
@@ -123,7 +123,11 @@ void MockRealtimeAudioSourceMac::emitSampleBuffers(uint32_t frameCount)
 void MockRealtimeAudioSourceMac::reconfigure()
 {
     ASSERT(!isMainThread());
-    m_maximiumFrameCount = WTF::roundUpToPowerOfTwo(renderInterval().seconds() * sampleRate() * 2);
+
+    auto rate = sampleRate();
+    ASSERT(rate);
+
+    m_maximiumFrameCount = WTF::roundUpToPowerOfTwo(renderInterval().seconds() * rate * 2);
     ASSERT(m_maximiumFrameCount);
 
     const int bytesPerFloat = sizeof(Float32);
@@ -132,19 +136,30 @@ void MockRealtimeAudioSourceMac::reconfigure()
     const bool isFloat = true;
     const bool isBigEndian = false;
     const bool isNonInterleaved = true;
-    FillOutASBDForLPCM(m_streamFormat, sampleRate(), channelCount, bitsPerByte * bytesPerFloat, bitsPerByte * bytesPerFloat, isFloat, isBigEndian, isNonInterleaved);
+    FillOutASBDForLPCM(m_streamFormat, rate, channelCount, bitsPerByte * bytesPerFloat, bitsPerByte * bytesPerFloat, isFloat, isBigEndian, isNonInterleaved);
 
     m_audioBufferList = makeUnique<WebAudioBufferList>(m_streamFormat, m_streamFormat.mBytesPerFrame * m_maximiumFrameCount);
 
     CMFormatDescriptionRef formatDescription;
     CMAudioFormatDescriptionCreate(NULL, &m_streamFormat, 0, NULL, 0, NULL, NULL, &formatDescription);
     m_formatDescription = adoptCF(formatDescription);
+
+    size_t sampleCount = 2 * rate;
+    m_bipBopBuffer.resize(sampleCount);
+    m_bipBopBuffer.fill(0);
+
+    size_t bipBopSampleCount = ceil(BipBopDuration * rate);
+    size_t bipStart = 0;
+    size_t bopStart = rate;
+
+    addHum(BipBopVolume, BipFrequency, rate, 0, m_bipBopBuffer.data() + bipStart, bipBopSampleCount);
+    addHum(BipBopVolume, BopFrequency, rate, 0, m_bipBopBuffer.data() + bopStart, bipBopSampleCount);
 }
 
 void MockRealtimeAudioSourceMac::render(Seconds delta)
 {
     ASSERT(!isMainThread());
-    if (!m_audioBufferList)
+    if (!m_audioBufferList || !m_bipBopBuffer.size())
         reconfigure();
 
     uint32_t totalFrameCount = alignTo16Bytes(delta.seconds() * sampleRate());
@@ -173,21 +188,7 @@ void MockRealtimeAudioSourceMac::settingsDidChange(OptionSet<RealtimeMediaSource
 {
     if (settings.contains(RealtimeMediaSourceSettings::Flag::SampleRate)) {
         m_workQueue->dispatch([this, protectedThis = makeRef(*this)] {
-            m_formatDescription = nullptr;
-            m_audioBufferList = nullptr;
-
-            auto rate = sampleRate();
-            size_t sampleCount = 2 * rate;
-
-            m_bipBopBuffer.grow(sampleCount);
-            m_bipBopBuffer.fill(0);
-
-            size_t bipBopSampleCount = ceil(BipBopDuration * rate);
-            size_t bipStart = 0;
-            size_t bopStart = rate;
-
-            addHum(BipBopVolume, BipFrequency, rate, 0, m_bipBopBuffer.data() + bipStart, bipBopSampleCount);
-            addHum(BipBopVolume, BopFrequency, rate, 0, m_bipBopBuffer.data() + bopStart, bipBopSampleCount);
+            reconfigure();
         });
     }
 
index 83a5632..e03a652 100644 (file)
@@ -68,6 +68,8 @@ MockRealtimeAudioSource::MockRealtimeAudioSource(String&& deviceID, String&& nam
     auto device = MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID(persistentID());
     ASSERT(device);
     m_device = *device;
+
+    setSampleRate(WTF::get<MockMicrophoneProperties>(m_device.properties).defaultSampleRate);
 }
 
 MockRealtimeAudioSource::~MockRealtimeAudioSource()