Title: [277589] trunk
Revision
277589
Author
you...@apple.com
Date
2021-05-17 11:19:42 -0700 (Mon, 17 May 2021)

Log Message

[ BigSur Debug wk2 ARM64 ] imported/w3c/web-platform-tests/webrtc-encoded-transform/sframe-transform-readable.html is flaky crashing
https://bugs.webkit.org/show_bug.cgi?id=225534
<rdar://problem/77679466>

Reviewed by Eric Carlson.

Source/WebCore:

In case the transform is stopped, the pipeTo operation will propagate the error/closure to the ReadableStream.
In that case, we need to stop enqueuing or we end up hitting the assert.
Handle this by adding a boolean which is set to true when SimpleReadableStreamSource::doCancel is called.
Make close and enqueue as no-op if that boolean is true.
Covered by test no longer crashing.

In addition, make sure to skip frames for which the array buffer is null as it might trigger debug asserts in libwebrtc.
Add a test to cover that case.

Test: http/wpt/webrtc/video-script-transform-keyframe-only.html

* Modules/mediastream/RTCRtpScriptTransformer.cpp:
(WebCore::RTCRtpScriptTransformer::writable):
* Modules/streams/ReadableStreamSource.cpp:
(WebCore::SimpleReadableStreamSource::doCancel):
(WebCore::SimpleReadableStreamSource::close):
(WebCore::SimpleReadableStreamSource::enqueue):
* Modules/streams/ReadableStreamSource.h:

LayoutTests:

* http/wpt/webrtc/video-script-transform-keyframe-only-expected.txt: Added.
* http/wpt/webrtc/video-script-transform-keyframe-only-worker.js: Added.
* http/wpt/webrtc/video-script-transform-keyframe-only.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (277588 => 277589)


--- trunk/LayoutTests/ChangeLog	2021-05-17 18:12:36 UTC (rev 277588)
+++ trunk/LayoutTests/ChangeLog	2021-05-17 18:19:42 UTC (rev 277589)
@@ -1,3 +1,15 @@
+2021-05-17  Youenn Fablet  <you...@apple.com>
+
+        [ BigSur Debug wk2 ARM64 ] imported/w3c/web-platform-tests/webrtc-encoded-transform/sframe-transform-readable.html is flaky crashing
+        https://bugs.webkit.org/show_bug.cgi?id=225534
+        <rdar://problem/77679466>
+
+        Reviewed by Eric Carlson.
+
+        * http/wpt/webrtc/video-script-transform-keyframe-only-expected.txt: Added.
+        * http/wpt/webrtc/video-script-transform-keyframe-only-worker.js: Added.
+        * http/wpt/webrtc/video-script-transform-keyframe-only.html: Added.
+
 2021-05-17  Jer Noble  <jer.no...@apple.com>
 
         MediaSession action handlers aren't treated as having a user gesture

Added: trunk/LayoutTests/http/wpt/webrtc/video-script-transform-keyframe-only-expected.txt (0 => 277589)


--- trunk/LayoutTests/http/wpt/webrtc/video-script-transform-keyframe-only-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/webrtc/video-script-transform-keyframe-only-expected.txt	2021-05-17 18:19:42 UTC (rev 277589)
@@ -0,0 +1,4 @@
+
+
+PASS enqueue video frames with empty buffer
+

Added: trunk/LayoutTests/http/wpt/webrtc/video-script-transform-keyframe-only-worker.js (0 => 277589)


--- trunk/LayoutTests/http/wpt/webrtc/video-script-transform-keyframe-only-worker.js	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/webrtc/video-script-transform-keyframe-only-worker.js	2021-05-17 18:19:42 UTC (rev 277589)
@@ -0,0 +1,32 @@
+class MockRTCRtpTransformer {
+    constructor(transformer) {
+        this.context = transformer;
+        this.start();
+    }
+    start()
+    {
+        this.reader = this.context.readable.getReader();
+        this.writer = this.context.writable.getWriter();
+        this.process();
+    }
+
+    process()
+    {
+        this.reader.read().then(chunk => {
+            if (chunk.done)
+                return;
+
+            if (chunk.value.type === "delta")
+                chunk.value = new ArrayBuffer();
+
+            this.writer.write(chunk.value);
+            this.process();
+        });
+    }
+};
+
+_onrtctransform_ = (event) => {
+    new MockRTCRtpTransformer(event.transformer);
+};
+
+self.postMessage("registered");

Added: trunk/LayoutTests/http/wpt/webrtc/video-script-transform-keyframe-only.html (0 => 277589)


--- trunk/LayoutTests/http/wpt/webrtc/video-script-transform-keyframe-only.html	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/webrtc/video-script-transform-keyframe-only.html	2021-05-17 18:19:42 UTC (rev 277589)
@@ -0,0 +1,56 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <script src=""
+        <script src=""
+    </head>
+    <body>
+        <video id="video" autoplay playsInline></video>
+        <script src=""
+        <script>
+function setH264BaselineCodec(sdp)
+{
+    const lines = sdp.split('\r\n');
+    const h264Lines = lines.filter(line => line.indexOf("a=fmtp") === 0 && line.indexOf("42e01f") !== -1);
+    const baselineNumber = h264Lines[0].substring(6).split(' ')[0];
+    return lines.filter(line => {
+        return (line.indexOf('a=fmtp') === -1 && line.indexOf('a=rtcp-fb') === -1 && line.indexOf('a=rtpmap') === -1) || line.indexOf(baselineNumber) !== -1;
+    }).join('\r\n');
+}
+
+let pc2;
+promise_test(async (test) => {
+    worker = new Worker('video-script-transform-keyframe-only-worker.js');
+    const data = "" new Promise(resolve => worker._onmessage_ = (event) => resolve(event.data));
+    assert_equals(data, "registered");
+
+    const localStream = await navigator.mediaDevices.getUserMedia({video: true});
+
+    const senderTransform = new RTCRtpScriptTransform(worker, {name:'MockRTCRtpTransform', mediaType:'video', side:'sender'});
+    const receiverTransform = new RTCRtpScriptTransform(worker, {name:'MockRTCRtpTransform', mediaType:'video', side:'receiver'});
+
+    video.srcObject = await new Promise((resolve, reject) => {
+        createConnections((firstConnection) => {
+            const sender = firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
+            sender.transform = senderTransform;
+        }, (secondConnection) => {
+            pc2 = secondConnection;
+            secondConnection._ontrack_ = (trackEvent) => {
+                const receiver = trackEvent.receiver;
+                receiver.transform = receiverTransform;
+                resolve(trackEvent.streams[0]);
+            };
+        }, { observeOffer : (offer) => {
+            offer.sdp = setH264BaselineCodec(offer.sdp);
+            return offer;
+        }});
+        setTimeout(() => reject("Test timed out"), 5000);
+    });
+
+    await video.play();
+    await waitFor(50);
+}, "enqueue video frames with empty buffer");
+        </script>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (277588 => 277589)


--- trunk/Source/WebCore/ChangeLog	2021-05-17 18:12:36 UTC (rev 277588)
+++ trunk/Source/WebCore/ChangeLog	2021-05-17 18:19:42 UTC (rev 277589)
@@ -1,3 +1,30 @@
+2021-05-17  Youenn Fablet  <you...@apple.com>
+
+        [ BigSur Debug wk2 ARM64 ] imported/w3c/web-platform-tests/webrtc-encoded-transform/sframe-transform-readable.html is flaky crashing
+        https://bugs.webkit.org/show_bug.cgi?id=225534
+        <rdar://problem/77679466>
+
+        Reviewed by Eric Carlson.
+
+        In case the transform is stopped, the pipeTo operation will propagate the error/closure to the ReadableStream.
+        In that case, we need to stop enqueuing or we end up hitting the assert.
+        Handle this by adding a boolean which is set to true when SimpleReadableStreamSource::doCancel is called.
+        Make close and enqueue as no-op if that boolean is true.
+        Covered by test no longer crashing.
+
+        In addition, make sure to skip frames for which the array buffer is null as it might trigger debug asserts in libwebrtc.
+        Add a test to cover that case.
+
+        Test: http/wpt/webrtc/video-script-transform-keyframe-only.html
+
+        * Modules/mediastream/RTCRtpScriptTransformer.cpp:
+        (WebCore::RTCRtpScriptTransformer::writable):
+        * Modules/streams/ReadableStreamSource.cpp:
+        (WebCore::SimpleReadableStreamSource::doCancel):
+        (WebCore::SimpleReadableStreamSource::close):
+        (WebCore::SimpleReadableStreamSource::enqueue):
+        * Modules/streams/ReadableStreamSource.h:
+
 2021-05-17  Jer Noble  <jer.no...@apple.com>
 
         MediaSession action handlers aren't treated as having a user gesture

Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.cpp (277588 => 277589)


--- trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.cpp	2021-05-17 18:12:36 UTC (rev 277588)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpScriptTransformer.cpp	2021-05-17 18:19:42 UTC (rev 277589)
@@ -104,7 +104,10 @@
             }, [&](RefPtr<RTCEncodedVideoFrame>& value) {
                 return makeRef(value->rtcFrame());
             });
-            transformer->m_backend->processTransformedFrame(rtcFrame.get());
+
+            // If no data, skip the frame since there is nothing to packetize or decode.
+            if (rtcFrame->data().data)
+                transformer->m_backend->processTransformedFrame(rtcFrame.get());
             return { };
         }));
         if (writableOrException.hasException())

Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamSource.cpp (277588 => 277589)


--- trunk/Source/WebCore/Modules/streams/ReadableStreamSource.cpp	2021-05-17 18:12:36 UTC (rev 277588)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamSource.cpp	2021-05-17 18:19:42 UTC (rev 277589)
@@ -82,4 +82,21 @@
     }
 }
 
+void SimpleReadableStreamSource::doCancel()
+{
+    m_isCancelled = true;
+}
+
+void SimpleReadableStreamSource::close()
+{
+    if (!m_isCancelled)
+        controller().close();
+}
+
+void SimpleReadableStreamSource::enqueue(JSC::JSValue value)
+{
+    if (!m_isCancelled)
+        controller().enqueue(value);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamSource.h (277588 => 277589)


--- trunk/Source/WebCore/Modules/streams/ReadableStreamSource.h	2021-05-17 18:12:36 UTC (rev 277588)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamSource.h	2021-05-17 18:19:42 UTC (rev 277589)
@@ -72,8 +72,8 @@
 public:
     static Ref<SimpleReadableStreamSource> create() { return adoptRef(*new SimpleReadableStreamSource); }
 
-    void close() { controller().close(); }
-    void enqueue(JSC::JSValue value) { controller().enqueue(value); }
+    void close();
+    void enqueue(JSC::JSValue);
 
 private:
     SimpleReadableStreamSource() = default;
@@ -83,7 +83,9 @@
     void setInactive() final { }
     void doStart() final { }
     void doPull() final { }
-    void doCancel() final { }
+    void doCancel() final;
+
+    bool m_isCancelled { false };
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to