Title: [239889] trunk/Source/WebCore
Revision
239889
Author
jer.no...@apple.com
Date
2019-01-11 17:22:58 -0800 (Fri, 11 Jan 2019)

Log Message

REGRESSION(r239419): Crash in AudioSourceProviderAVFObjC::~AudioSourceProviderAVFObjC()
https://bugs.webkit.org/show_bug.cgi?id=193342
<rdar://problem/47119836>

Reviewed by Eric Carlson.

Make the TapStorage used by AudioSourceProviderAVFObjC thread-safe RefCounted.

* platform/graphics/avfoundation/AudioSourceProviderAVFObjC.h:
* platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm:
(WebCore::AudioSourceProviderAVFObjC::initCallback):
(WebCore::AudioSourceProviderAVFObjC::finalizeCallback):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (239888 => 239889)


--- trunk/Source/WebCore/ChangeLog	2019-01-12 01:13:32 UTC (rev 239888)
+++ trunk/Source/WebCore/ChangeLog	2019-01-12 01:22:58 UTC (rev 239889)
@@ -1,3 +1,18 @@
+2019-01-11  Jer Noble  <jer.no...@apple.com>
+
+        REGRESSION(r239419): Crash in AudioSourceProviderAVFObjC::~AudioSourceProviderAVFObjC()
+        https://bugs.webkit.org/show_bug.cgi?id=193342
+        <rdar://problem/47119836>
+
+        Reviewed by Eric Carlson.
+
+        Make the TapStorage used by AudioSourceProviderAVFObjC thread-safe RefCounted.
+
+        * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.h:
+        * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm:
+        (WebCore::AudioSourceProviderAVFObjC::initCallback):
+        (WebCore::AudioSourceProviderAVFObjC::finalizeCallback):
+
 2019-01-11  John Wilander  <wilan...@apple.com>
 
         Compile out Web API Statistics Collection

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.h (239888 => 239889)


--- trunk/Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.h	2019-01-12 01:13:32 UTC (rev 239888)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.h	2019-01-12 01:22:58 UTC (rev 239889)
@@ -98,8 +98,8 @@
     bool m_paused { true };
     AudioSourceProviderClient* m_client { nullptr };
 
-    struct TapStorage;
-    TapStorage* m_tapStorage { nullptr };
+    class TapStorage;
+    RefPtr<TapStorage> m_tapStorage;
 };
     
 }

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm (239888 => 239889)


--- trunk/Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm	2019-01-12 01:13:32 UTC (rev 239888)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm	2019-01-12 01:22:58 UTC (rev 239889)
@@ -69,7 +69,8 @@
 using namespace PAL;
 static const double kRingBufferDuration = 1;
 
-struct AudioSourceProviderAVFObjC::TapStorage {
+class AudioSourceProviderAVFObjC::TapStorage : public ThreadSafeRefCounted<AudioSourceProviderAVFObjC::TapStorage> {
+public:
     TapStorage(AudioSourceProviderAVFObjC* _this) : _this(_this) { }
     AudioSourceProviderAVFObjC* _this;
     Lock mutex;
@@ -238,9 +239,12 @@
     ASSERT(tap);
     AudioSourceProviderAVFObjC* _this = static_cast<AudioSourceProviderAVFObjC*>(clientInfo);
     _this->m_tap = adoptCF(tap);
-    _this->m_tapStorage = new TapStorage(_this);
+    _this->m_tapStorage = adoptRef(new TapStorage(_this));
     _this->init(clientInfo, tapStorageOut);
-    *tapStorageOut = _this->m_tapStorage;
+    *tapStorageOut = _this->m_tapStorage.get();
+
+    // ref balanced by deref in finalizeCallback:
+    _this->m_tapStorage->ref();
 }
 
 void AudioSourceProviderAVFObjC::finalizeCallback(MTAudioProcessingTapRef tap)
@@ -253,7 +257,7 @@
         if (tapStorage->_this)
             tapStorage->_this->finalize();
     }
-    delete tapStorage;
+    tapStorage->deref();
 }
 
 void AudioSourceProviderAVFObjC::prepareCallback(MTAudioProcessingTapRef tap, CMItemCount maxFrames, const AudioStreamBasicDescription *processingFormat)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to