Title: [294988] trunk/Source/WebCore/platform/graphics/avfoundation/objc/QueuedVideoOutput.mm
Revision
294988
Author
jer.no...@apple.com
Date
2022-05-28 01:07:10 -0700 (Sat, 28 May 2022)

Log Message

CRASH: Exception thrown from QueuedVideoOutput::invalidate
https://bugs.webkit.org/show_bug.cgi?id=241052
<rdar://93953827>

Reviewed by Eric Carlson.

* Source/WebCore/platform/graphics/avfoundation/objc/QueuedVideoOutput.mm:
(WebCore::QueuedVideoOutput::QueuedVideoOutput):

An Objective-C exception is thrown from -removeObserver: stating the observer
was never added in the first place. Clear out ivars in the early return to avoid
doing work in invalidate() which (in addition to being unnecessary) will trigger
the exception.

Canonical link: https://commits.webkit.org/251092@main

Modified Paths

Diff

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/QueuedVideoOutput.mm (294987 => 294988)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/QueuedVideoOutput.mm	2022-05-28 05:25:49 UTC (rev 294987)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/QueuedVideoOutput.mm	2022-05-28 08:07:10 UTC (rev 294988)
@@ -135,12 +135,19 @@
     , m_delegate(adoptNS([[WebQueuedVideoOutputDelegate alloc] initWithParent:this]))
 {
     m_videoOutput = adoptNS([PAL::allocAVPlayerItemVideoOutputInstance() initWithPixelBufferAttributes:nil]);
+    if (!m_videoOutput) {
+        // When bailing out early, also release these following objects
+        // to avoid doing unnecessary work in ::invalidate(). Failure to
+        // do so will result in exceptions being thrown from -removeObserver:.
+        m_player = nullptr;
+        m_playerItem = nullptr;
+        m_delegate = nullptr;
+        return;
+    }
+
     [m_videoOutput setDelegate:m_delegate.get() queue:globalOutputDelegateQueue()];
     [m_videoOutput requestNotificationOfMediaDataChangeAsSoonAsPossible];
 
-    if (!m_videoOutput)
-        return;
-    
     [m_playerItem addOutput:m_videoOutput.get()];
 
     [m_player addObserver:m_delegate.get() forKeyPath:@"rate" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial) context:nil];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to