Corrupted image after looping movie-backed <img>.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Oct 2017 18:53:52 +0000 (18:53 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Oct 2017 18:53:52 +0000 (18:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178398

Reviewed by Eric Carlson.

Use the decode-order sample cursor rather than the destination sample cursor when generating
the CMSampleBuffer to decode.

* platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm:
(WebCore::ImageDecoderAVFObjC::createFrameImageAtIndex):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm

index c8363d4..6b0c31c 100644 (file)
@@ -1,3 +1,16 @@
+2017-10-17  Jer Noble  <jer.noble@apple.com>
+
+        Corrupted image after looping movie-backed <img>.
+        https://bugs.webkit.org/show_bug.cgi?id=178398
+
+        Reviewed by Eric Carlson.
+
+        Use the decode-order sample cursor rather than the destination sample cursor when generating
+        the CMSampleBuffer to decode.
+
+        * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm:
+        (WebCore::ImageDecoderAVFObjC::createFrameImageAtIndex):
+
 2017-10-17  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r223459.
index 084d642..542d010 100644 (file)
@@ -589,29 +589,29 @@ NativeImagePtr ImageDecoderAVFObjC::createFrameImageAtIndex(size_t index, Subsam
 
         auto presentationTime = PAL::toMediaTime(m_cursor.get().presentationTimeStamp);
         auto indexIter = m_presentationTimeToIndex.find(presentationTime);
-        advanceCursor();
 
         if (indexIter == m_presentationTimeToIndex.end())
-            return nullptr;
+            break;
 
         auto& cursorSampleData = m_sampleData[indexIter->second];
 
         if (!cursorSampleData.sample) {
-            auto request = adoptNS([allocAVSampleBufferRequestInstance() initWithStartCursor:frameCursor]);
+            auto request = adoptNS([allocAVSampleBufferRequestInstance() initWithStartCursor:m_cursor.get()]);
             cursorSampleData.sample = adoptCF([m_generator createSampleBufferForRequest:request.get()]);
         }
 
         if (!cursorSampleData.sample)
-            return nullptr;
+            break;
 
         if (!storeSampleBuffer(cursorSampleData.sample.get()))
-            return nullptr;
+            break;
 
+        advanceCursor();
         if (sampleData.image)
             return sampleData.image;
     }
 
-    ASSERT_NOT_REACHED();
+    advanceCursor();
     return nullptr;
 }