Changeset 223452 in webkit
- Timestamp:
- Oct 16, 2017 5:35:12 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r223451 r223452 1 2017-10-16 Jer Noble <jer.noble@apple.com> 2 3 ImageDecoderAVFObjC fails to create more CMSampleBuffers after creating about 32MB worth. 4 https://bugs.webkit.org/show_bug.cgi?id=178360 5 6 Reviewed by Eric Carlson. 7 8 AVSampleBufferGenerator has a constrained memory pool of about 32MB in size. Once 9 CMSampleBuffers representing about 32MB of memory are allocated, no more can be created 10 until previously created ones are released. So rather than (only) creating the sample 11 buffers up front in readSampleMetadata(), also create them dynamically, if missing, in 12 createFrameImageAtIndex(...) and release them in storeSampleBuffer(...) after they have been 13 decoded. 14 15 Drive-by fix: the expected content length was never actually set by the owner of ImageDecoderAVFObjC. 16 Now that the expected content length is available, we don't have to wait until the data is complete 17 to respond to requests. 18 19 * platform/graphics/ImageSource.cpp: 20 (WebCore::ImageSource::ensureDecoderAvailable): 21 * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h: 22 * platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm: 23 (SOFT_LINK_POINTER_OPTIONAL): 24 (-[WebCoreSharedBufferResourceLoaderDelegate canFulfillRequest:]): 25 (-[WebCoreSharedBufferResourceLoaderDelegate fulfillRequest:]): 26 (-[WebCoreSharedBufferResourceLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): 27 (WebCore::imageDecoderAssetOptions): 28 (WebCore::ImageDecoderAVFObjC::firstEnabledTrack): 29 (WebCore::ImageDecoderAVFObjC::storeSampleBuffer): 30 (WebCore::ImageDecoderAVFObjC::createFrameImageAtIndex): 31 (WebCore::ImageDecoderAVFObjC::setExpectedContentSize): 32 1 33 2017-10-12 Matt Rajca <mrajca@apple.com> 2 34 -
trunk/Source/WebCore/platform/graphics/ImageSource.cpp
r223091 r223452 80 80 return false; 81 81 82 if (auto expectedContentLength = m_frameCache->expectedContentLength()) 83 m_decoder->setExpectedContentSize(expectedContentLength); 84 82 85 m_frameCache->setDecoder(m_decoder.get()); 83 86 return true; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.h
r222225 r223452 120 120 Lock m_sampleGeneratorLock; 121 121 bool m_isAllDataReceived { false }; 122 long long m_expectedContentSize { 0 };123 122 std::optional<IntSize> m_size; 124 123 std::optional<RotationProperties> m_rotation; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/ImageDecoderAVFObjC.mm
r222326 r223452 33 33 #import "FloatRect.h" 34 34 #import "FloatSize.h" 35 #import "Logging.h" 35 36 #import "MIMETypeRegistry.h" 36 37 #import "SharedBuffer.h" … … 64 65 SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMediaCharacteristicVisual, NSString *) 65 66 SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVURLAssetReferenceRestrictionsKey, NSString *) 67 SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVURLAssetUsesNoPersistentCacheKey, NSString *) 66 68 #define AVMediaCharacteristicVisual getAVMediaCharacteristicVisual() 67 69 #define AVURLAssetReferenceRestrictionsKey getAVURLAssetReferenceRestrictionsKey() 70 #define AVURLAssetUsesNoPersistentCacheKey getAVURLAssetUsesNoPersistentCacheKey() 68 71 69 72 #pragma mark - … … 128 131 129 132 if (auto dataRequest = request.dataRequest) { 130 if (dataRequest.requestedOffset + dataRequest.requestedLength> static_cast<long long>(_data.get().length))133 if (dataRequest.requestedOffset > static_cast<long long>(_data.get().length)) 131 134 return NO; 132 135 } … … 178 181 179 182 [dataRequest respondWithData:requestedData]; 183 184 if (dataRequest.requestsAllDataToEndOfResource) { 185 if (!_complete) 186 return; 187 } else if (dataRequest.requestedOffset + dataRequest.requestedLength > dataRequest.currentOffset) 188 return; 180 189 } 181 190 … … 191 200 if ([self canFulfillRequest:loadingRequest]) { 192 201 [self fulfillRequest:loadingRequest]; 193 return NO; 202 if (loadingRequest.finished) 203 return NO; 194 204 } 195 205 … … 223 233 { 224 234 static NeverDestroyed<RetainPtr<NSDictionary>> options; 225 if (!options.get()) 226 options.get() = @{ AVURLAssetReferenceRestrictionsKey: @(AVAssetReferenceRestrictionForbidAll) }; 235 if (!options.get()) { 236 options.get() = @{ 237 AVURLAssetReferenceRestrictionsKey: @(AVAssetReferenceRestrictionForbidAll), 238 AVURLAssetUsesNoPersistentCacheKey: @YES, 239 }; 240 } 227 241 228 242 return options.get().get(); … … 308 322 }]; 309 323 310 if (firstEnabledIndex == NSNotFound) 324 if (firstEnabledIndex == NSNotFound) { 325 LOG(Images, "ImageDecoderAVFObjC::firstEnabledTrack(%p) - asset has no enabled video tracks", this); 311 326 return nil; 327 } 312 328 313 329 return [videoTracks objectAtIndex:firstEnabledIndex]; … … 366 382 { 367 383 auto pixelBuffer = m_decompressionSession->decodeSampleSync(sampleBuffer); 368 if (!pixelBuffer) 384 if (!pixelBuffer) { 385 LOG(Images, "ImageDecoderAVFObjC::storeSampleBuffer(%p) - could not decode sampleBuffer", this); 369 386 return false; 387 } 370 388 371 389 auto presentationTime = PAL::toMediaTime(CMSampleBufferGetPresentationTimeStamp(sampleBuffer)); … … 406 424 407 425 CGImageRef rawImage = nullptr; 408 if (noErr != VTCreateCGImageFromCVPixelBuffer(pixelBuffer.get(), nullptr, &rawImage)) 426 if (noErr != VTCreateCGImageFromCVPixelBuffer(pixelBuffer.get(), nullptr, &rawImage)) { 427 LOG(Images, "ImageDecoderAVFObjC::storeSampleBuffer(%p) - could not create CGImage from pixelBuffer", this); 409 428 return false; 429 } 410 430 411 431 ASSERT(indexIter->second < m_sampleData.size()); 412 432 auto& sampleData = m_sampleData[indexIter->second]; 413 433 sampleData.image = adoptCF(rawImage); 434 sampleData.sample = nullptr; 414 435 415 436 auto alphaInfo = CGImageGetAlphaInfo(rawImage); … … 576 597 auto& cursorSampleData = m_sampleData[indexIter->second]; 577 598 599 if (!cursorSampleData.sample) { 600 auto request = adoptNS([allocAVSampleBufferRequestInstance() initWithStartCursor:frameCursor]); 601 cursorSampleData.sample = adoptCF([m_generator createSampleBufferForRequest:request.get()]); 602 } 603 578 604 if (!cursorSampleData.sample) 579 605 return nullptr; … … 592 618 void ImageDecoderAVFObjC::setExpectedContentSize(long long expectedContentSize) 593 619 { 594 if (m_expectedContentSize == expectedContentSize) 595 return; 596 597 m_loader.get().expectedContentSize = m_expectedContentSize; 620 m_loader.get().expectedContentSize = expectedContentSize; 598 621 } 599 622
Note: See TracChangeset
for help on using the changeset viewer.