[Mac] Crash at com.apple.WebCore: WebCore::MediaPlayerPrivateAVFoundationObjC::tracks...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Nov 2013 17:55:39 +0000 (17:55 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Nov 2013 17:55:39 +0000 (17:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124031

Reviewed by Eric Carlson.

WTF::bind() causes errors when given a bare id pointer as a parameter,
when that parameter is casted to a specific NS type pointer (in this
case, a NSArray*) in order to pass it as a parameter to the bound
function.

Instead of passing around bare id pointers, wrap them in RetainPtr<>
objects before passing them to WTF::bind().

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::seekableTimeRangesDidChange):
(WebCore::MediaPlayerPrivateAVFoundationObjC::loadedTimeRangesDidChange):
(WebCore::MediaPlayerPrivateAVFoundationObjC::tracksDidChange):
(-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

index 142753e..a5260fa 100644 (file)
@@ -1,3 +1,25 @@
+2013-11-07  Jer Noble  <jer.noble@apple.com>
+
+        [Mac] Crash at com.apple.WebCore: WebCore::MediaPlayerPrivateAVFoundationObjC::tracksDidChange + 26
+        https://bugs.webkit.org/show_bug.cgi?id=124031
+
+        Reviewed by Eric Carlson.
+
+        WTF::bind() causes errors when given a bare id pointer as a parameter,
+        when that parameter is casted to a specific NS type pointer (in this
+        case, a NSArray*) in order to pass it as a parameter to the bound
+        function.
+
+        Instead of passing around bare id pointers, wrap them in RetainPtr<>
+        objects before passing them to WTF::bind().
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::seekableTimeRangesDidChange):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::loadedTimeRangesDidChange):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::tracksDidChange):
+        (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]):
+
 2013-11-08  Antti Koivisto  <antti@apple.com>
 
         Templated LChar/UChar paths for simple line layout
index 7c75131..00b95fa 100644 (file)
@@ -98,9 +98,9 @@ public:
     void playbackBufferEmptyDidChange(bool);
     void playbackBufferFullWillChange();
     void playbackBufferFullDidChange(bool);
-    void loadedTimeRangesDidChange(NSArray*);
-    void seekableTimeRangesDidChange(NSArray*);
-    void tracksDidChange(NSArray*);
+    void loadedTimeRangesDidChange(RetainPtr<NSArray>);
+    void seekableTimeRangesDidChange(RetainPtr<NSArray>);
+    void tracksDidChange(RetainPtr<NSArray>);
     void hasEnabledAudioDidChange(bool);
     void presentationSizeDidChange(FloatSize);
     void durationDidChange(double);
index 1fc6123..fa7f805 100644 (file)
@@ -1699,7 +1699,7 @@ void MediaPlayerPrivateAVFoundationObjC::playbackBufferFullDidChange(bool buffer
         updateStates();
 }
 
-void MediaPlayerPrivateAVFoundationObjC::seekableTimeRangesDidChange(NSArray* seekableRanges)
+void MediaPlayerPrivateAVFoundationObjC::seekableTimeRangesDidChange(RetainPtr<NSArray> seekableRanges)
 {
     m_cachedSeekableRanges = seekableRanges;
 
@@ -1707,7 +1707,7 @@ void MediaPlayerPrivateAVFoundationObjC::seekableTimeRangesDidChange(NSArray* se
     updateStates();
 }
 
-void MediaPlayerPrivateAVFoundationObjC::loadedTimeRangesDidChange(NSArray* loadedRanges)
+void MediaPlayerPrivateAVFoundationObjC::loadedTimeRangesDidChange(RetainPtr<NSArray> loadedRanges)
 {
     m_cachedLoadedRanges = loadedRanges;
 
@@ -1715,7 +1715,7 @@ void MediaPlayerPrivateAVFoundationObjC::loadedTimeRangesDidChange(NSArray* load
     updateStates();
 }
 
-void MediaPlayerPrivateAVFoundationObjC::tracksDidChange(NSArray* tracks)
+void MediaPlayerPrivateAVFoundationObjC::tracksDidChange(RetainPtr<NSArray> tracks)
 {
     m_cachedTracks = tracks;
 
@@ -1876,13 +1876,13 @@ NSArray* itemKVOProperties()
         else if ([keyPath isEqualToString:@"playbackBufferFull"])
             function = WTF::bind(&MediaPlayerPrivateAVFoundationObjC::playbackBufferFullDidChange, m_callback, [newValue boolValue]);
         else if ([keyPath isEqualToString:@"asset"])
-            function = WTF::bind(&MediaPlayerPrivateAVFoundationObjC::setAsset, m_callback, newValue);
+            function = WTF::bind(&MediaPlayerPrivateAVFoundationObjC::setAsset, m_callback, RetainPtr<NSArray>(newValue));
         else if ([keyPath isEqualToString:@"loadedTimeRanges"])
-            function = WTF::bind(&MediaPlayerPrivateAVFoundationObjC::loadedTimeRangesDidChange, m_callback, newValue);
+            function = WTF::bind(&MediaPlayerPrivateAVFoundationObjC::loadedTimeRangesDidChange, m_callback, RetainPtr<NSArray>(newValue));
         else if ([keyPath isEqualToString:@"seekableTimeRanges"])
-            function = WTF::bind(&MediaPlayerPrivateAVFoundationObjC::seekableTimeRangesDidChange, m_callback, newValue);
+            function = WTF::bind(&MediaPlayerPrivateAVFoundationObjC::seekableTimeRangesDidChange, m_callback, RetainPtr<NSArray>(newValue));
         else if ([keyPath isEqualToString:@"tracks"])
-            function = WTF::bind(&MediaPlayerPrivateAVFoundationObjC::tracksDidChange, m_callback, newValue);
+            function = WTF::bind(&MediaPlayerPrivateAVFoundationObjC::tracksDidChange, m_callback, RetainPtr<NSArray>(newValue));
         else if ([keyPath isEqualToString:@"hasEnabledAudio"])
             function = WTF::bind(&MediaPlayerPrivateAVFoundationObjC::hasEnabledAudioDidChange, m_callback, [newValue boolValue]);
         else if ([keyPath isEqualToString:@"presentationSize"])