Title: [188761] trunk/Source/WebCore
Revision
188761
Author
[email protected]
Date
2015-08-21 11:37:29 -0700 (Fri, 21 Aug 2015)

Log Message

dispatch_group_t objects may not be retained properly when not backed by Objective-C objects under garbage collection
<http://webkit.org/b/148229>

Reviewed by Eric Carlson.

When compiled with garbage collection enabled, libdispatch
objects are not backed by Objective-C objects, so they don't get
the benefit of automatic reference counting when captured by a
block or a lambda.  To address this, we use OSObjectPtr<> which
always increments the reference count of the contained object.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::beginLoadingMetadata):
Switch to use OSObjectPtr<>.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (188760 => 188761)


--- trunk/Source/WebCore/ChangeLog	2015-08-21 18:27:01 UTC (rev 188760)
+++ trunk/Source/WebCore/ChangeLog	2015-08-21 18:37:29 UTC (rev 188761)
@@ -1,3 +1,20 @@
+2015-08-21  David Kilzer  <[email protected]>
+
+        dispatch_group_t objects may not be retained properly when not backed by Objective-C objects under garbage collection
+        <http://webkit.org/b/148229>
+
+        Reviewed by Eric Carlson.
+
+        When compiled with garbage collection enabled, libdispatch
+        objects are not backed by Objective-C objects, so they don't get
+        the benefit of automatic reference counting when captured by a
+        block or a lambda.  To address this, we use OSObjectPtr<> which
+        always increments the reference count of the contained object.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::beginLoadingMetadata):
+        Switch to use OSObjectPtr<>.
+
 2015-08-21  Nan Wang  <[email protected]>
 
         [Mac] accessibility/selection-states.html fails

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2015-08-21 18:27:01 UTC (rev 188760)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2015-08-21 18:37:29 UTC (rev 188761)
@@ -72,6 +72,7 @@
 #import <wtf/CurrentTime.h>
 #import <wtf/ListHashSet.h>
 #import <wtf/NeverDestroyed.h>
+#import <wtf/OSObjectPtr.h>
 #import <wtf/text/CString.h>
 #import <wtf/text/StringBuilder.h>
 
@@ -1044,31 +1045,29 @@
 {
     LOG(Media, "MediaPlayerPrivateAVFoundationObjC::beginLoadingMetadata(%p) - requesting metadata loading", this);
 
-    dispatch_group_t metadataLoadingGroup = dispatch_group_create();
-    dispatch_group_enter(metadataLoadingGroup);
+    OSObjectPtr<dispatch_group_t> metadataLoadingGroup = adoptOSObject(dispatch_group_create());
+    dispatch_group_enter(metadataLoadingGroup.get());
     auto weakThis = createWeakPtr();
     [m_avAsset.get() loadValuesAsynchronouslyForKeys:assetMetadataKeyNames() completionHandler:^{
 
         callOnMainThread([weakThis, metadataLoadingGroup] {
             if (weakThis && [weakThis->m_avAsset.get() statusOfValueForKey:@"tracks" error:nil] == AVKeyValueStatusLoaded) {
                 for (AVAssetTrack *track in [weakThis->m_avAsset.get() tracks]) {
-                    dispatch_group_enter(metadataLoadingGroup);
+                    dispatch_group_enter(metadataLoadingGroup.get());
                     [track loadValuesAsynchronouslyForKeys:assetTrackMetadataKeyNames() completionHandler:^{
-                        dispatch_group_leave(metadataLoadingGroup);
+                        dispatch_group_leave(metadataLoadingGroup.get());
                     }];
                 }
             }
-            dispatch_group_leave(metadataLoadingGroup);
+            dispatch_group_leave(metadataLoadingGroup.get());
         });
     }];
 
-    dispatch_group_notify(metadataLoadingGroup, dispatch_get_main_queue(), ^{
+    dispatch_group_notify(metadataLoadingGroup.get(), dispatch_get_main_queue(), ^{
         callOnMainThread([weakThis] {
             if (weakThis)
                 [weakThis->m_objcObserver.get() metadataLoaded];
         });
-
-        dispatch_release(metadataLoadingGroup);
     });
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to