Title: [263876] branches/safari-610.1.20-branch
Revision
263876
Author
kocsen_ch...@apple.com
Date
2020-07-02 17:17:01 -0700 (Thu, 02 Jul 2020)

Log Message

Cherry-pick r263854. rdar://problem/65048370

    Unreviewed, reverting r263633, r263651, and r263671.

    Still seeing MediaRecorder test crashes after re-landing
    r263633

    Reverted changesets:

    "MediaRecorder stopRecorder() returns empty Blob after first
    use"
    https://bugs.webkit.org/show_bug.cgi?id=212274
    https://trac.webkit.org/changeset/263633

    "MediaRecorder.start() Method is Ignoring the "timeslice"
    Parameter"
    https://bugs.webkit.org/show_bug.cgi?id=202233
    https://trac.webkit.org/changeset/263651

    "Support MediaRecorder.onstart"
    https://bugs.webkit.org/show_bug.cgi?id=213720
    https://trac.webkit.org/changeset/263671

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

Modified Paths

Removed Paths

Diff

Modified: branches/safari-610.1.20-branch/LayoutTests/ChangeLog (263875 => 263876)


--- branches/safari-610.1.20-branch/LayoutTests/ChangeLog	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/LayoutTests/ChangeLog	2020-07-03 00:17:01 UTC (rev 263876)
@@ -1,3 +1,53 @@
+2020-07-02  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r263854. rdar://problem/65048370
+
+    Unreviewed, reverting r263633, r263651, and r263671.
+    
+    Still seeing MediaRecorder test crashes after re-landing
+    r263633
+    
+    Reverted changesets:
+    
+    "MediaRecorder stopRecorder() returns empty Blob after first
+    use"
+    https://bugs.webkit.org/show_bug.cgi?id=212274
+    https://trac.webkit.org/changeset/263633
+    
+    "MediaRecorder.start() Method is Ignoring the "timeslice"
+    Parameter"
+    https://bugs.webkit.org/show_bug.cgi?id=202233
+    https://trac.webkit.org/changeset/263651
+    
+    "Support MediaRecorder.onstart"
+    https://bugs.webkit.org/show_bug.cgi?id=213720
+    https://trac.webkit.org/changeset/263671
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263854 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-07-02  Ryan Haddad  <ryanhad...@apple.com>
+
+            Unreviewed, reverting r263633, r263651, and r263671.
+
+            Still seeing MediaRecorder test crashes after re-landing
+            r263633
+
+            Reverted changesets:
+
+            "MediaRecorder stopRecorder() returns empty Blob after first
+            use"
+            https://bugs.webkit.org/show_bug.cgi?id=212274
+            https://trac.webkit.org/changeset/263633
+
+            "MediaRecorder.start() Method is Ignoring the "timeslice"
+            Parameter"
+            https://bugs.webkit.org/show_bug.cgi?id=202233
+            https://trac.webkit.org/changeset/263651
+
+            "Support MediaRecorder.onstart"
+            https://bugs.webkit.org/show_bug.cgi?id=213720
+            https://trac.webkit.org/changeset/263671
+
 2020-06-29  Xabier Rodriguez Calvar  <calva...@igalia.com>
 
         [GStreamer] imported/w3c/web-platform-tests/encrypted-media/clearkey-mp4-playback-temporary-setMediaKeys-immediately.https.html is a flaky crash

Deleted: branches/safari-610.1.20-branch/LayoutTests/http/wpt/mediarecorder/MediaRecorder-multiple-start-stop-expected.txt (263875 => 263876)


--- branches/safari-610.1.20-branch/LayoutTests/http/wpt/mediarecorder/MediaRecorder-multiple-start-stop-expected.txt	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/LayoutTests/http/wpt/mediarecorder/MediaRecorder-multiple-start-stop-expected.txt	2020-07-03 00:17:01 UTC (rev 263876)
@@ -1,3 +0,0 @@
-
-PASS Make sure that MediaRecorder can be used after stopping it once 
-

Deleted: branches/safari-610.1.20-branch/LayoutTests/http/wpt/mediarecorder/MediaRecorder-multiple-start-stop.html (263875 => 263876)


--- branches/safari-610.1.20-branch/LayoutTests/http/wpt/mediarecorder/MediaRecorder-multiple-start-stop.html	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/LayoutTests/http/wpt/mediarecorder/MediaRecorder-multiple-start-stop.html	2020-07-03 00:17:01 UTC (rev 263876)
@@ -1,49 +0,0 @@
-<!doctype html>
-<html>
-<head>
-    <title>MediaRecorder Dataavailable</title>
-    <link rel="help" href=""
-    <script src=""
-    <script src=""
-</head>
-<body>
-<canvas id="canvas" width="200" height="200">
-</canvas>
-<script>
-    promise_test(async t => {
-        const video = await navigator.mediaDevices.getUserMedia({ audio : true, video : true });
-        const recorder = new MediaRecorder(video);
-
-        assert_equals(recorder.stream, video);
-
-        let promise = new Promise(resolve => {
-            recorder._ondataavailable_ = t.step_func(blobEvent => {
-                if (blobEvent.data.size)
-                    resolve();
-            });
-        });
-
-        recorder.start();
-        let timer = setInterval(() => recorder.requestData(), 10);
-        await promise;
-        clearInterval(timer);
-
-        recorder.stop();
-
-        promise = new Promise(resolve => {
-            recorder._ondataavailable_ = t.step_func(blobEvent => {
-                if (blobEvent.data.size)
-                    resolve();
-            });
-        });
-
-        recorder.start();
-        timer = setInterval(() => recorder.requestData(), 10);
-        await promise;
-        clearInterval(timer);
-
-        recorder.stop();
-    }, 'Make sure that MediaRecorder can be used after stopping it once');
-</script>
-</body>
-</html>

Modified: branches/safari-610.1.20-branch/Source/WebCore/ChangeLog (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebCore/ChangeLog	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebCore/ChangeLog	2020-07-03 00:17:01 UTC (rev 263876)
@@ -1,3 +1,53 @@
+2020-07-02  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r263854. rdar://problem/65048370
+
+    Unreviewed, reverting r263633, r263651, and r263671.
+    
+    Still seeing MediaRecorder test crashes after re-landing
+    r263633
+    
+    Reverted changesets:
+    
+    "MediaRecorder stopRecorder() returns empty Blob after first
+    use"
+    https://bugs.webkit.org/show_bug.cgi?id=212274
+    https://trac.webkit.org/changeset/263633
+    
+    "MediaRecorder.start() Method is Ignoring the "timeslice"
+    Parameter"
+    https://bugs.webkit.org/show_bug.cgi?id=202233
+    https://trac.webkit.org/changeset/263651
+    
+    "Support MediaRecorder.onstart"
+    https://bugs.webkit.org/show_bug.cgi?id=213720
+    https://trac.webkit.org/changeset/263671
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263854 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-07-02  Ryan Haddad  <ryanhad...@apple.com>
+
+            Unreviewed, reverting r263633, r263651, and r263671.
+
+            Still seeing MediaRecorder test crashes after re-landing
+            r263633
+
+            Reverted changesets:
+
+            "MediaRecorder stopRecorder() returns empty Blob after first
+            use"
+            https://bugs.webkit.org/show_bug.cgi?id=212274
+            https://trac.webkit.org/changeset/263633
+
+            "MediaRecorder.start() Method is Ignoring the "timeslice"
+            Parameter"
+            https://bugs.webkit.org/show_bug.cgi?id=202233
+            https://trac.webkit.org/changeset/263651
+
+            "Support MediaRecorder.onstart"
+            https://bugs.webkit.org/show_bug.cgi?id=213720
+            https://trac.webkit.org/changeset/263671
+
 2020-06-09  Sergio Villar Senin  <svil...@igalia.com>
 
         [css-flexbox] WebKit mistakenly lets pointer events (click/hover/etc) pass through flex items, if they have negative margin

Modified: branches/safari-610.1.20-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.cpp	2020-07-03 00:17:01 UTC (rev 263876)
@@ -51,8 +51,11 @@
     auto privateInstance = MediaRecorder::createMediaRecorderPrivate(document, stream->privateStream());
     if (!privateInstance)
         return Exception { NotSupportedError, "The MediaRecorder is unsupported on this platform"_s };
-    auto recorder = adoptRef(*new MediaRecorder(document, WTFMove(stream), WTFMove(options)));
+    auto recorder = adoptRef(*new MediaRecorder(document, WTFMove(stream), WTFMove(privateInstance), WTFMove(options)));
     recorder->suspendIfNeeded();
+    recorder->m_private->setErrorCallback([recorder](auto&& exception) mutable {
+        recorder->dispatchError(WTFMove(*exception));
+    });
     return recorder;
 }
 
@@ -79,11 +82,11 @@
 #endif
 }
 
-MediaRecorder::MediaRecorder(Document& document, Ref<MediaStream>&& stream, Options&& option)
+MediaRecorder::MediaRecorder(Document& document, Ref<MediaStream>&& stream, std::unique_ptr<MediaRecorderPrivate>&& privateImpl, Options&& option)
     : ActiveDOMObject(document)
     , m_options(WTFMove(option))
     , m_stream(WTFMove(stream))
-    , m_timeSliceTimer([this] { requestData(); })
+    , m_private(WTFMove(privateImpl))
 {
     m_tracks = WTF::map(m_stream->getTracks(), [] (auto&& track) -> Ref<MediaStreamTrackPrivate> {
         return track->privateTrack();
@@ -126,35 +129,16 @@
     return "MediaRecorder";
 }
 
-ExceptionOr<void> MediaRecorder::startRecording(Optional<int> timeSlice)
+ExceptionOr<void> MediaRecorder::startRecording(Optional<int> timeslice)
 {
-    if (!m_isActive)
-        return Exception { InvalidStateError, "The MediaRecorder is not active"_s };
-
+    UNUSED_PARAM(timeslice);
     if (state() != RecordingState::Inactive)
         return Exception { InvalidStateError, "The MediaRecorder's state must be inactive in order to start recording"_s };
 
-    ASSERT(!m_private);
-    m_private = createMediaRecorderPrivate(*document(), m_stream->privateStream());
-
-    if (!m_private)
-        return Exception { NotSupportedError, "The MediaRecorder is unsupported on this platform"_s };
-
-    m_private->startRecording([this, pendingActivity = makePendingActivity(*this)](auto&& exception) mutable {
-        if (!m_isActive || !exception)
-            return;
-
-        stopRecordingInternal();
-        dispatchError(WTFMove(*exception));
-    });
-
     for (auto& track : m_tracks)
         track->addObserver(*this);
 
     m_state = RecordingState::Recording;
-    m_timeSlice = timeSlice;
-    if (m_timeSlice)
-        m_timeSliceTimer.startOneShot(Seconds::fromMilliseconds(*m_timeSlice));
     return { };
 }
 
@@ -162,17 +146,22 @@
 {
     if (state() == RecordingState::Inactive)
         return Exception { InvalidStateError, "The MediaRecorder's state cannot be inactive"_s };
+    
+    queueTaskKeepingObjectAlive(*this, TaskSource::Networking, [this] {
+        if (!m_isActive || state() == RecordingState::Inactive)
+            return;
 
-    stopRecordingInternal();
-    auto& privateRecorder = *m_private;
-    privateRecorder.fetchData([this, pendingActivity = makePendingActivity(*this), privateRecorder = WTFMove(m_private)](auto&& buffer, auto& mimeType) {
-        queueTaskKeepingObjectAlive(*this, TaskSource::Networking, [this, buffer = WTFMove(buffer), mimeType]() mutable {
+        stopRecordingInternal();
+        ASSERT(m_state == RecordingState::Inactive);
+        m_private->fetchData([this, pendingActivity = makePendingActivity(*this)](auto&& buffer, auto& mimeType) {
             if (!m_isActive)
                 return;
+    
             dispatchEvent(BlobEvent::create(eventNames().dataavailableEvent, Event::CanBubble::No, Event::IsCancelable::No, buffer ? Blob::create(buffer.releaseNonNull(), mimeType) : Blob::create()));
 
             if (!m_isActive)
                 return;
+
             dispatchEvent(Event::create(eventNames().stopEvent, Event::CanBubble::No, Event::IsCancelable::No));
         });
     });
@@ -184,18 +173,11 @@
     if (state() == RecordingState::Inactive)
         return Exception { InvalidStateError, "The MediaRecorder's state cannot be inactive"_s };
 
-    if (m_timeSliceTimer.isActive())
-        m_timeSliceTimer.stop();
     m_private->fetchData([this, pendingActivity = makePendingActivity(*this)](auto&& buffer, auto& mimeType) {
-        queueTaskKeepingObjectAlive(*this, TaskSource::Networking, [this, buffer = WTFMove(buffer), mimeType]() mutable {
-            if (!m_isActive)
-                return;
+        if (!m_isActive)
+            return;
 
-            dispatchEvent(BlobEvent::create(eventNames().dataavailableEvent, Event::CanBubble::No, Event::IsCancelable::No, buffer ? Blob::create(buffer.releaseNonNull(), mimeType) : Blob::create()));
-
-            if (m_timeSlice)
-                m_timeSliceTimer.startOneShot(Seconds::fromMilliseconds(*m_timeSlice));
-        });
+        dispatchEvent(BlobEvent::create(eventNames().dataavailableEvent, Event::CanBubble::No, Event::IsCancelable::No, buffer ? Blob::create(buffer.releaseNonNull(), mimeType) : Blob::create()));
     });
     return { };
 }

Modified: branches/safari-610.1.20-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.h (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.h	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebCore/Modules/mediarecorder/MediaRecorder.h	2020-07-03 00:17:01 UTC (rev 263876)
@@ -30,7 +30,6 @@
 #include "EventTarget.h"
 #include "MediaStream.h"
 #include "MediaStreamTrackPrivate.h"
-#include "Timer.h"
 #include <wtf/UniqueRef.h>
 
 namespace WebCore {
@@ -76,7 +75,7 @@
     MediaStream& stream() { return m_stream.get(); }
 
 private:
-    MediaRecorder(Document&, Ref<MediaStream>&&, Options&& = { });
+    MediaRecorder(Document&, Ref<MediaStream>&&, std::unique_ptr<MediaRecorderPrivate>&&, Options&& = { });
 
     static std::unique_ptr<MediaRecorderPrivate> createMediaRecorderPrivate(Document&, MediaStreamPrivate&);
     
@@ -117,8 +116,6 @@
     std::unique_ptr<MediaRecorderPrivate> m_private;
     RecordingState m_state { RecordingState::Inactive };
     Vector<Ref<MediaStreamTrackPrivate>> m_tracks;
-    Optional<int> m_timeSlice;
-    Timer m_timeSliceTimer;
     
     bool m_isActive { true };
 };

Modified: branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivate.h (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivate.h	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivate.h	2020-07-03 00:17:01 UTC (rev 263876)
@@ -60,13 +60,16 @@
     virtual void fetchData(FetchDataCallback&&) = 0;
     virtual void stopRecording() = 0;
 
-    using ErrorCallback = CompletionHandler<void(Optional<Exception>&&)>;
-    virtual void startRecording(ErrorCallback&& callback) { callback({ }); }
+    using ErrorCallback = Function<void(Optional<Exception>&&)>;
+    void setErrorCallback(ErrorCallback&& errorCallback) { m_errorCallback = WTFMove(errorCallback); }
 
 protected:
     void setAudioSource(RefPtr<RealtimeMediaSource>&&);
     void setVideoSource(RefPtr<RealtimeMediaSource>&&);
 
+protected:
+    ErrorCallback m_errorCallback;
+
 private:
     RefPtr<RealtimeMediaSource> m_audioSource;
     RefPtr<RealtimeMediaSource> m_videoSource;

Modified: branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp	2020-07-03 00:17:01 UTC (rev 263876)
@@ -83,15 +83,11 @@
 
 void MediaRecorderPrivateMock::fetchData(FetchDataCallback&& completionHandler)
 {
-    RefPtr<SharedBuffer> buffer;
-    {
-        auto locker = holdLock(m_bufferLock);
-        Vector<uint8_t> value(m_buffer.length());
-        memcpy(value.data(), m_buffer.characters8(), m_buffer.length());
-        m_buffer.clear();
-        buffer = SharedBuffer::create(WTFMove(value));
-    }
-    completionHandler(WTFMove(buffer), mimeType());
+    auto locker = holdLock(m_bufferLock);
+    Vector<uint8_t> value(m_buffer.length());
+    memcpy(value.data(), m_buffer.characters8(), m_buffer.length());
+    m_buffer.clear();
+    completionHandler(SharedBuffer::create(WTFMove(value)), mimeType());
 }
 
 const String& MediaRecorderPrivateMock::mimeType()

Modified: branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/AudioSampleBufferCompressor.h (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/AudioSampleBufferCompressor.h	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/AudioSampleBufferCompressor.h	2020-07-03 00:17:01 UTC (rev 263876)
@@ -60,13 +60,13 @@
     OSStatus provideSourceDataNumOutputPackets(UInt32*, AudioBufferList*, AudioStreamPacketDescription**);
 
     dispatch_queue_t m_serialDispatchQueue;
-    CMTime m_lowWaterTime { kCMTimeInvalid };
+    CMTime m_lowWaterTime;
 
     RetainPtr<CMBufferQueueRef> m_outputBufferQueue;
     RetainPtr<CMBufferQueueRef> m_inputBufferQueue;
     bool m_isEncoding { false };
 
-    AudioConverterRef m_converter { nullptr };
+    RetainPtr<AudioConverterRef> m_converter;
     AudioStreamBasicDescription m_sourceFormat;
     AudioStreamBasicDescription m_destinationFormat;
     RetainPtr<CMFormatDescriptionRef> m_destinationFormatDescription;
@@ -74,9 +74,9 @@
     UInt32 m_maxOutputPacketSize { 0 };
     Vector<AudioStreamPacketDescription> m_destinationPacketDescriptions;
 
-    CMTime m_currentNativePresentationTimeStamp { kCMTimeInvalid };
-    CMTime m_currentOutputPresentationTimeStamp { kCMTimeInvalid };
-    CMTime m_remainingPrimeDuration { kCMTimeInvalid };
+    CMTime m_currentNativePresentationTimeStamp;
+    CMTime m_currentOutputPresentationTimeStamp;
+    CMTime m_remainingPrimeDuration;
 
     Vector<char> m_sourceBuffer;
     Vector<char> m_destinationBuffer;

Modified: branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/AudioSampleBufferCompressor.mm (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/AudioSampleBufferCompressor.mm	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/AudioSampleBufferCompressor.mm	2020-07-03 00:17:01 UTC (rev 263876)
@@ -58,10 +58,6 @@
 AudioSampleBufferCompressor::~AudioSampleBufferCompressor()
 {
     dispatch_release(m_serialDispatchQueue);
-    if (m_converter) {
-        AudioConverterDispose(m_converter);
-        m_converter = nullptr;
-    }
 }
 
 bool AudioSampleBufferCompressor::initialize(CMBufferQueueTriggerCallback callback, void* callbackObject)
@@ -116,12 +112,12 @@
         RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor AudioConverterNew failed with %d", error);
         return false;
     }
-    m_converter = converter;
+    m_converter = adoptCF(converter);
 
     size_t cookieSize = 0;
     const void *cookie = CMAudioFormatDescriptionGetMagicCookie(formatDescription, &cookieSize);
     if (cookieSize) {
-        if (auto error = AudioConverterSetProperty(m_converter, kAudioConverterDecompressionMagicCookie, (UInt32)cookieSize, cookie)) {
+        if (auto error = AudioConverterSetProperty(m_converter.get(), kAudioConverterDecompressionMagicCookie, (UInt32)cookieSize, cookie)) {
             RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor setting kAudioConverterDecompressionMagicCookie failed with %d", error);
             return false;
         }
@@ -128,7 +124,7 @@
     }
 
     size = sizeof(m_sourceFormat);
-    if (auto error = AudioConverterGetProperty(m_converter, kAudioConverterCurrentInputStreamDescription, &size, &m_sourceFormat)) {
+    if (auto error = AudioConverterGetProperty(m_converter.get(), kAudioConverterCurrentInputStreamDescription, &size, &m_sourceFormat)) {
         RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor getting kAudioConverterCurrentInputStreamDescription failed with %d", error);
         return false;
     }
@@ -139,7 +135,7 @@
     }
 
     size = sizeof(m_destinationFormat);
-    if (auto error = AudioConverterGetProperty(m_converter, kAudioConverterCurrentOutputStreamDescription, &size, &m_destinationFormat)) {
+    if (auto error = AudioConverterGetProperty(m_converter.get(), kAudioConverterCurrentOutputStreamDescription, &size, &m_destinationFormat)) {
         RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor getting kAudioConverterCurrentOutputStreamDescription failed with %d", error);
         return false;
     }
@@ -153,7 +149,7 @@
             outputBitRate = 32000;
 
         size = sizeof(outputBitRate);
-        if (auto error = AudioConverterSetProperty(m_converter, kAudioConverterEncodeBitRate, size, &outputBitRate)) {
+        if (auto error = AudioConverterSetProperty(m_converter.get(), kAudioConverterEncodeBitRate, size, &outputBitRate)) {
             RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor setting kAudioConverterEncodeBitRate failed with %d", error);
             return false;
         }
@@ -163,7 +159,7 @@
         // If the destination format is VBR, we need to get max size per packet from the converter.
         size = sizeof(m_maxOutputPacketSize);
 
-        if (auto error = AudioConverterGetProperty(m_converter, kAudioConverterPropertyMaximumOutputPacketSize, &size, &m_maxOutputPacketSize)) {
+        if (auto error = AudioConverterGetProperty(m_converter.get(), kAudioConverterPropertyMaximumOutputPacketSize, &size, &m_maxOutputPacketSize)) {
             RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor getting kAudioConverterPropertyMaximumOutputPacketSize failed with %d", error);
             return false;
         }
@@ -193,7 +189,7 @@
         AudioConverterPrimeInfo primeInfo { 0, 0 };
         UInt32 size = sizeof(primeInfo);
 
-        if (auto error = AudioConverterGetProperty(m_converter, kAudioConverterPrimeInfo, &size, &primeInfo)) {
+        if (auto error = AudioConverterGetProperty(m_converter.get(), kAudioConverterPrimeInfo, &size, &primeInfo)) {
             RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor getting kAudioConverterPrimeInfo failed with %d", error);
             return;
         }
@@ -215,13 +211,13 @@
 {
     UInt32 delaySize = sizeof(uint32_t);
     uint32_t originalDelayMode = 0;
-    if (auto error = AudioConverterGetProperty(m_converter, kAudioCodecPropertyDelayMode, &delaySize, &originalDelayMode)) {
+    if (auto error = AudioConverterGetProperty(m_converter.get(), kAudioCodecPropertyDelayMode, &delaySize, &originalDelayMode)) {
         RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor getting kAudioCodecPropertyDelayMode failed with %d", error);
         return nil;
     }
 
     uint32_t optimalDelayMode = kAudioCodecDelayMode_Optimal;
-    if (auto error = AudioConverterSetProperty(m_converter, kAudioCodecPropertyDelayMode, delaySize, &optimalDelayMode)) {
+    if (auto error = AudioConverterSetProperty(m_converter.get(), kAudioCodecPropertyDelayMode, delaySize, &optimalDelayMode)) {
         RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor setting kAudioCodecPropertyDelayMode failed with %d", error);
         return nil;
     }
@@ -228,12 +224,12 @@
 
     UInt32 primeSize = sizeof(AudioCodecPrimeInfo);
     AudioCodecPrimeInfo primeInfo { 0, 0 };
-    if (auto error = AudioConverterGetProperty(m_converter, kAudioCodecPropertyPrimeInfo, &primeSize, &primeInfo)) {
+    if (auto error = AudioConverterGetProperty(m_converter.get(), kAudioCodecPropertyPrimeInfo, &primeSize, &primeInfo)) {
         RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor getting kAudioCodecPropertyPrimeInfo failed with %d", error);
         return nil;
     }
 
-    if (auto error = AudioConverterSetProperty(m_converter, kAudioCodecPropertyDelayMode, delaySize, &originalDelayMode)) {
+    if (auto error = AudioConverterSetProperty(m_converter.get(), kAudioCodecPropertyDelayMode, delaySize, &originalDelayMode)) {
         RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor setting kAudioCodecPropertyDelayMode failed with %d", error);
         return nil;
     }
@@ -246,11 +242,11 @@
     if (!m_destinationFormatDescription) {
         UInt32 cookieSize = 0;
 
-        auto error = AudioConverterGetPropertyInfo(m_converter, kAudioConverterCompressionMagicCookie, &cookieSize, NULL);
+        auto error = AudioConverterGetPropertyInfo(m_converter.get(), kAudioConverterCompressionMagicCookie, &cookieSize, NULL);
         if ((error == noErr) && !!cookieSize) {
             cookie.resize(cookieSize);
 
-            if (auto error = AudioConverterGetProperty(m_converter, kAudioConverterCompressionMagicCookie, &cookieSize, cookie.data())) {
+            if (auto error = AudioConverterGetProperty(m_converter.get(), kAudioConverterCompressionMagicCookie, &cookieSize, cookie.data())) {
                 RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor getting kAudioConverterCompressionMagicCookie failed with %d", error);
                 return nil;
             }
@@ -443,7 +439,7 @@
         UInt32 outputPacketSize = m_destinationFormat.mBytesPerPacket ? m_destinationFormat.mBytesPerPacket : m_maxOutputPacketSize;
         UInt32 numOutputPackets = (UInt32)m_destinationBuffer.capacity() / outputPacketSize;
 
-        auto error = AudioConverterFillComplexBuffer(m_converter, audioConverterComplexInputDataProc, this, &numOutputPackets, &fillBufferList, m_destinationPacketDescriptions.data());
+        auto error = AudioConverterFillComplexBuffer(m_converter.get(), audioConverterComplexInputDataProc, this, &numOutputPackets, &fillBufferList, m_destinationPacketDescriptions.data());
         if (error) {
             RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor AudioConverterFillComplexBuffer failed with %d", error);
             return;

Modified: branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h	2020-07-03 00:17:01 UTC (rev 263876)
@@ -114,8 +114,8 @@
     RetainPtr<CMFormatDescriptionRef> m_videoFormatDescription;
     std::unique_ptr<VideoSampleBufferCompressor> m_videoCompressor;
     RetainPtr<AVAssetWriterInput> m_videoAssetWriterInput;
-    CMTime m_lastVideoPresentationTime { kCMTimeInvalid };
-    CMTime m_lastVideoDecodingTime { kCMTimeInvalid };
+    CMTime m_lastVideoPresentationTime;
+    CMTime m_lastVideoDecodingTime;
     bool m_hasEncodedVideoSamples { false };
 
     RetainPtr<WebAVAssetWriterDelegate> m_writerDelegate;

Modified: branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm	2020-07-03 00:17:01 UTC (rev 263876)
@@ -435,18 +435,16 @@
     m_isStopping = true;
     // We hop to the main thread since finishing the video compressor might trigger starting the writer asynchronously.
     callOnMainThread([this, weakThis = makeWeakPtr(this)]() mutable {
-        auto whenFinished = [this, weakThis] {
-            if (!weakThis)
-                return;
+        auto whenFinished = [this] {
+            m_isStopping = false;
+            if (m_fetchDataCompletionHandler) {
+                auto buffer = WTFMove(m_data);
+                m_fetchDataCompletionHandler(WTFMove(buffer));
+            }
 
-            m_isStopping = false;
             m_isStopped = false;
             m_hasStartedWriting = false;
-
-            if (m_writer)
-                m_writer.clear();
-            if (m_fetchDataCompletionHandler)
-                m_fetchDataCompletionHandler(std::exchange(m_data, nullptr));
+            clear();
         };
 
         if (!m_hasStartedWriting) {
@@ -463,8 +461,12 @@
             [m_writer flush];
             ALLOW_DEPRECATED_DECLARATIONS_END
 
-            [m_writer finishWritingWithCompletionHandler:[whenFinished = WTFMove(whenFinished)]() mutable {
-                callOnMainThread(WTFMove(whenFinished));
+            [m_writer finishWritingWithCompletionHandler:[weakThis = WTFMove(weakThis), whenFinished = WTFMove(whenFinished)]() mutable {
+                callOnMainThread([weakThis = WTFMove(weakThis), whenFinished = WTFMove(whenFinished)]() mutable {
+                    if (!weakThis)
+                        return;
+                    whenFinished();
+                });
             }];
         });
     });

Modified: branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/VideoSampleBufferCompressor.mm (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/VideoSampleBufferCompressor.mm	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebCore/platform/mediarecorder/cocoa/VideoSampleBufferCompressor.mm	2020-07-03 00:17:01 UTC (rev 263876)
@@ -56,10 +56,6 @@
 VideoSampleBufferCompressor::~VideoSampleBufferCompressor()
 {
     dispatch_release(m_serialDispatchQueue);
-    if (m_vtSession) {
-        VTCompressionSessionInvalidate(m_vtSession.get());
-        m_vtSession = nullptr;
-    }
 }
 
 bool VideoSampleBufferCompressor::initialize(CMBufferQueueTriggerCallback callback, void* callbackObject)

Modified: branches/safari-610.1.20-branch/Source/WebCore/platform/mediastream/MediaStreamPrivate.h (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebCore/platform/mediastream/MediaStreamPrivate.h	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebCore/platform/mediastream/MediaStreamPrivate.h	2020-07-03 00:17:01 UTC (rev 263876)
@@ -73,7 +73,7 @@
     static Ref<MediaStreamPrivate> create(Ref<const Logger>&&, RefPtr<RealtimeMediaSource>&& audioSource, RefPtr<RealtimeMediaSource>&& videoSource);
     static Ref<MediaStreamPrivate> create(Ref<const Logger>&& logger, const MediaStreamTrackPrivateVector& tracks, String&& id = createCanonicalUUIDString()) { return adoptRef(*new MediaStreamPrivate(WTFMove(logger), tracks, WTFMove(id))); }
 
-    WEBCORE_EXPORT virtual ~MediaStreamPrivate();
+    virtual ~MediaStreamPrivate();
 
     void addObserver(Observer&);
     void removeObserver(Observer&);

Modified: branches/safari-610.1.20-branch/Source/WebKit/ChangeLog (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebKit/ChangeLog	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebKit/ChangeLog	2020-07-03 00:17:01 UTC (rev 263876)
@@ -1,3 +1,53 @@
+2020-07-02  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r263854. rdar://problem/65048370
+
+    Unreviewed, reverting r263633, r263651, and r263671.
+    
+    Still seeing MediaRecorder test crashes after re-landing
+    r263633
+    
+    Reverted changesets:
+    
+    "MediaRecorder stopRecorder() returns empty Blob after first
+    use"
+    https://bugs.webkit.org/show_bug.cgi?id=212274
+    https://trac.webkit.org/changeset/263633
+    
+    "MediaRecorder.start() Method is Ignoring the "timeslice"
+    Parameter"
+    https://bugs.webkit.org/show_bug.cgi?id=202233
+    https://trac.webkit.org/changeset/263651
+    
+    "Support MediaRecorder.onstart"
+    https://bugs.webkit.org/show_bug.cgi?id=213720
+    https://trac.webkit.org/changeset/263671
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263854 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-07-02  Ryan Haddad  <ryanhad...@apple.com>
+
+            Unreviewed, reverting r263633, r263651, and r263671.
+
+            Still seeing MediaRecorder test crashes after re-landing
+            r263633
+
+            Reverted changesets:
+
+            "MediaRecorder stopRecorder() returns empty Blob after first
+            use"
+            https://bugs.webkit.org/show_bug.cgi?id=212274
+            https://trac.webkit.org/changeset/263633
+
+            "MediaRecorder.start() Method is Ignoring the "timeslice"
+            Parameter"
+            https://bugs.webkit.org/show_bug.cgi?id=202233
+            https://trac.webkit.org/changeset/263651
+
+            "Support MediaRecorder.onstart"
+            https://bugs.webkit.org/show_bug.cgi?id=213720
+            https://trac.webkit.org/changeset/263671
+
 2020-07-01  Alan Coon  <alanc...@apple.com>
 
         Cherry-pick r263793. rdar://problem/65011200

Modified: branches/safari-610.1.20-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorderManager.cpp (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorderManager.cpp	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorderManager.cpp	2020-07-03 00:17:01 UTC (rev 263876)
@@ -64,6 +64,7 @@
 
 void RemoteMediaRecorderManager::releaseRecorder(MediaRecorderIdentifier identifier)
 {
+    ASSERT(m_recorders.contains(identifier));
     m_recorders.remove(identifier);
 }
 

Modified: branches/safari-610.1.20-branch/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.cpp	2020-07-03 00:17:01 UTC (rev 263876)
@@ -45,17 +45,12 @@
 
 MediaRecorderPrivate::MediaRecorderPrivate(MediaStreamPrivate& stream)
     : m_identifier(MediaRecorderIdentifier::generate())
-    , m_stream(makeRef(stream))
     , m_connection(WebProcess::singleton().ensureGPUProcessConnection().connection())
 {
-}
-
-void MediaRecorderPrivate::startRecording(ErrorCallback&& errorCallback)
-{
     // FIXME: we will need to implement support for multiple audio/video tracks
     // Currently we only choose the first track as the recorded track.
 
-    auto selectedTracks = MediaRecorderPrivate::selectTracks(m_stream);
+    auto selectedTracks = MediaRecorderPrivate::selectTracks(stream);
     if (selectedTracks.audioTrack) {
         m_ringBuffer = makeUnique<CARingBuffer>(makeUniqueRef<SharedRingBufferStorage>(this));
         m_recordedAudioTrackID = selectedTracks.audioTrack->id();
@@ -69,20 +64,15 @@
         width = selectedTracks.videoTrack->settings().width();
     }
 
-    m_connection->sendWithAsyncReply(Messages::RemoteMediaRecorderManager::CreateRecorder { m_identifier, !!selectedTracks.audioTrack, width, height }, [this, weakThis = makeWeakPtr(this), audioTrack = makeRefPtr(selectedTracks.audioTrack), videoTrack = makeRefPtr(selectedTracks.videoTrack), errorCallback = WTFMove(errorCallback)](auto&& exception) mutable {
-        if (!weakThis) {
-            errorCallback({ });
+    m_connection->sendWithAsyncReply(Messages::RemoteMediaRecorderManager::CreateRecorder { m_identifier, !!selectedTracks.audioTrack, width, height }, [this, weakThis = makeWeakPtr(this), audioTrack = makeRefPtr(selectedTracks.audioTrack), videoTrack = makeRefPtr(selectedTracks.videoTrack)](auto&& exception) {
+        if (!weakThis)
             return;
-        }
-        if (exception) {
-            errorCallback(Exception { exception->code, WTFMove(exception->message) });
-            return;
-        }
+        if (exception)
+            return m_errorCallback(Exception { exception->code, WTFMove(exception->message) });
         if (audioTrack)
             setAudioSource(&audioTrack->source());
         if (videoTrack)
             setVideoSource(&videoTrack->source());
-        errorCallback({ });
     }, 0);
 }
 

Modified: branches/safari-610.1.20-branch/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.h (263875 => 263876)


--- branches/safari-610.1.20-branch/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.h	2020-07-03 00:08:06 UTC (rev 263875)
+++ branches/safari-610.1.20-branch/Source/WebKit/WebProcess/GPU/webrtc/MediaRecorderPrivate.h	2020-07-03 00:17:01 UTC (rev 263876)
@@ -58,7 +58,6 @@
     void videoSampleAvailable(WebCore::MediaSample&) final;
     void fetchData(CompletionHandler<void(RefPtr<WebCore::SharedBuffer>&&, const String& mimeType)>&&) final;
     void stopRecording() final;
-    void startRecording(ErrorCallback&&) final;
     void audioSamplesAvailable(const WTF::MediaTime&, const WebCore::PlatformAudioData&, const WebCore::AudioStreamDescription&, size_t) final;
 
     // SharedRingBufferStorage::Client
@@ -65,9 +64,8 @@
     void storageChanged(SharedMemory*);
 
     MediaRecorderIdentifier m_identifier;
-    Ref<MediaStreamPrivate> m_stream;
+
     Ref<IPC::Connection> m_connection;
-
     String m_recordedAudioTrackID;
     String m_recordedVideoTrackID;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to