Title: [285305] trunk/Source/WebCore
Revision
285305
Author
[email protected]
Date
2021-11-04 13:31:43 -0700 (Thu, 04 Nov 2021)

Log Message

[ iOS ] TestWebKitAPI.WebKitLegacy.AudioSessionCategoryIOS is crashing
https://bugs.webkit.org/show_bug.cgi?id=232676

Patch by Alex Christensen <[email protected]> on 2021-11-04
Reviewed by Eric Carlson.

In WebKitLegacy on iOS, WebCoreAVFPullDelegate.initWithPlayer is being called on the web thread,
but outputMediaDataWillChange is being called on the main run loop then accessing _player in a non-thread-safe manner.
To fix this, I call callOnMainThread to access _player on the web thread.  To fix the assertion that happens after this
fix, I made MediaPlayerPrivateAVFoundationObjC::outputMediaDataWillChange able to be called on the non-main run loop.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::outputMediaDataWillChange):
(-[WebCoreAVFPullDelegate outputMediaDataWillChange:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285304 => 285305)


--- trunk/Source/WebCore/ChangeLog	2021-11-04 20:02:17 UTC (rev 285304)
+++ trunk/Source/WebCore/ChangeLog	2021-11-04 20:31:43 UTC (rev 285305)
@@ -1,3 +1,19 @@
+2021-11-04  Alex Christensen  <[email protected]>
+
+        [ iOS ] TestWebKitAPI.WebKitLegacy.AudioSessionCategoryIOS is crashing
+        https://bugs.webkit.org/show_bug.cgi?id=232676
+
+        Reviewed by Eric Carlson.
+
+        In WebKitLegacy on iOS, WebCoreAVFPullDelegate.initWithPlayer is being called on the web thread,
+        but outputMediaDataWillChange is being called on the main run loop then accessing _player in a non-thread-safe manner.
+        To fix this, I call callOnMainThread to access _player on the web thread.  To fix the assertion that happens after this
+        fix, I made MediaPlayerPrivateAVFoundationObjC::outputMediaDataWillChange able to be called on the non-main run loop.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::outputMediaDataWillChange):
+        (-[WebCoreAVFPullDelegate outputMediaDataWillChange:]):
+
 2021-11-04  Antti Koivisto  <[email protected]>
 
         Remove isMatchingHostPseudoClass state from ElementRuleCollector

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (285304 => 285305)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2021-11-04 20:02:17 UTC (rev 285304)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2021-11-04 20:31:43 UTC (rev 285305)
@@ -2633,8 +2633,15 @@
 
 void MediaPlayerPrivateAVFoundationObjC::outputMediaDataWillChange()
 {
-    if (m_runningModalPaint)
-        RunLoop::main().stop();
+    if (m_runningModalPaint) {
+        if (RunLoop::isMain())
+            RunLoop::main().stop();
+        else {
+            RunLoop::main().dispatch([] {
+                RunLoop::main().stop();
+            });
+        }
+    }
 }
 
 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
@@ -4017,9 +4024,9 @@
 {
     UNUSED_PARAM(output);
     m_semaphore.signal();
-    RunLoop::main().dispatch([player = _player] {
-        if (player)
-            player->outputMediaDataWillChange();
+    callOnMainThread([self, strongSelf = RetainPtr { self }] {
+        if (_player)
+            _player->outputMediaDataWillChange();
     });
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to