Skip to content
Permalink
Browse files
Leak of CMSampleBufferRef (up to 2.25 KB each) in com.apple.WebKit.GP…
…U.Development process

<https://webkit.org/b/229262>
<rdar://problem/82076765>

Reviewed by Darin Adler.

Covered by running layout tests with --leaks plus future patch
to check for leaks in the GPU process.

* platform/mediarecorder/cocoa/AudioSampleBufferCompressor.h:
(WebCore::AudioSampleBufferCompressor::sampleBufferWithNumPackets):
- Update signature to return RetainPtr<CMSampleBufferRef>.

* platform/mediarecorder/cocoa/AudioSampleBufferCompressor.mm:
(WebCore::AudioSampleBufferCompressor::sampleBufferWithNumPackets):
- Update signature to return RetainPtr<CMSampleBufferRef>.
- Rename `sampleBuffer` to `rawSampleBuffer` to match similar
  pattern used in other code, then use `sampleBuffer` to store
  `rawSampleBuffer` wrapped in a RetainPtr<>.
(WebCore::AudioSampleBufferCompressor::processSampleBuffersUntilLowWaterTime):
- Add get() to `buffer` variable since it is now a RetainPtr<>.


Canonical link: https://commits.webkit.org/240657@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281220 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
David Kilzer committed Aug 19, 2021
1 parent 2b92275 commit a0d143005e6856da2102044385875c9a7c2a1634
@@ -1,3 +1,27 @@
2021-08-18 David Kilzer <ddkilzer@apple.com>

Leak of CMSampleBufferRef (up to 2.25 KB each) in com.apple.WebKit.GPU.Development process
<https://webkit.org/b/229262>
<rdar://problem/82076765>

Reviewed by Darin Adler.

Covered by running layout tests with --leaks plus future patch
to check for leaks in the GPU process.

* platform/mediarecorder/cocoa/AudioSampleBufferCompressor.h:
(WebCore::AudioSampleBufferCompressor::sampleBufferWithNumPackets):
- Update signature to return RetainPtr<CMSampleBufferRef>.

* platform/mediarecorder/cocoa/AudioSampleBufferCompressor.mm:
(WebCore::AudioSampleBufferCompressor::sampleBufferWithNumPackets):
- Update signature to return RetainPtr<CMSampleBufferRef>.
- Rename `sampleBuffer` to `rawSampleBuffer` to match similar
pattern used in other code, then use `sampleBuffer` to store
`rawSampleBuffer` wrapped in a RetainPtr<>.
(WebCore::AudioSampleBufferCompressor::processSampleBuffersUntilLowWaterTime):
- Add get() to `buffer` variable since it is now a RetainPtr<>.

2021-08-18 Chris Dumez <cdumez@apple.com>

Unreviewed, reverting r281206.
@@ -60,7 +60,7 @@ class AudioSampleBufferCompressor {
size_t computeBufferSizeForAudioFormat(AudioStreamBasicDescription, UInt32, Float32);
void attachPrimingTrimsIfNeeded(CMSampleBufferRef);
RetainPtr<NSNumber> gradualDecoderRefreshCount();
CMSampleBufferRef sampleBufferWithNumPackets(UInt32 numPackets, AudioBufferList);
RetainPtr<CMSampleBufferRef> sampleBufferWithNumPackets(UInt32 numPackets, AudioBufferList);
void processSampleBuffersUntilLowWaterTime(CMTime);
OSStatus provideSourceDataNumOutputPackets(UInt32*, AudioBufferList*, AudioStreamPacketDescription**);

@@ -262,7 +262,7 @@
return retainPtr([NSNumber numberWithInt:(primeInfo.leadingFrames / m_destinationFormat.mFramesPerPacket)]);
}

CMSampleBufferRef AudioSampleBufferCompressor::sampleBufferWithNumPackets(UInt32 numPackets, AudioBufferList fillBufferList)
RetainPtr<CMSampleBufferRef> AudioSampleBufferCompressor::sampleBufferWithNumPackets(UInt32 numPackets, AudioBufferList fillBufferList)
{
Vector<char> cookie;
if (!m_destinationFormatDescription) {
@@ -302,15 +302,17 @@
return nil;
}

CMSampleBufferRef sampleBuffer;
auto error = PAL::CMAudioSampleBufferCreateWithPacketDescriptions(kCFAllocatorDefault, buffer.get(), true, NULL, NULL, m_destinationFormatDescription.get(), numPackets, m_currentNativePresentationTimeStamp, m_destinationPacketDescriptions.data(), &sampleBuffer);
CMSampleBufferRef rawSampleBuffer;
auto error = PAL::CMAudioSampleBufferCreateWithPacketDescriptions(kCFAllocatorDefault, buffer.get(), true, NULL, NULL, m_destinationFormatDescription.get(), numPackets, m_currentNativePresentationTimeStamp, m_destinationPacketDescriptions.data(), &rawSampleBuffer);
if (error) {
RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor CMAudioSampleBufferCreateWithPacketDescriptions failed with %d", error);
return nil;
}

auto sampleBuffer = adoptCF(rawSampleBuffer);

if ([m_gdrCountNum intValue])
PAL::CMSetAttachment(sampleBuffer, PAL::kCMSampleBufferAttachmentKey_GradualDecoderRefresh, (__bridge CFTypeRef)m_gdrCountNum.get(), kCMAttachmentMode_ShouldPropagate);
PAL::CMSetAttachment(sampleBuffer.get(), PAL::kCMSampleBufferAttachmentKey_GradualDecoderRefresh, (__bridge CFTypeRef)m_gdrCountNum.get(), kCMAttachmentMode_ShouldPropagate);

return sampleBuffer;
}
@@ -480,21 +482,21 @@

auto buffer = sampleBufferWithNumPackets(numOutputPackets, fillBufferList);

attachPrimingTrimsIfNeeded(buffer);
attachPrimingTrimsIfNeeded(buffer.get());

error = CMSampleBufferSetOutputPresentationTimeStamp(buffer, m_currentOutputPresentationTimeStamp);
error = CMSampleBufferSetOutputPresentationTimeStamp(buffer.get(), m_currentOutputPresentationTimeStamp);
if (error) {
RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor CMSampleBufferSetOutputPresentationTimeStamp failed with %d", error);
return;
}

CMTime nativeDuration = CMSampleBufferGetDuration(buffer);
CMTime nativeDuration = CMSampleBufferGetDuration(buffer.get());
m_currentNativePresentationTimeStamp = CMTimeAdd(m_currentNativePresentationTimeStamp, nativeDuration);

CMTime outputDuration = CMSampleBufferGetOutputDuration(buffer);
CMTime outputDuration = CMSampleBufferGetOutputDuration(buffer.get());
m_currentOutputPresentationTimeStamp = CMTimeAdd(m_currentOutputPresentationTimeStamp, outputDuration);

error = CMBufferQueueEnqueue(m_outputBufferQueue.get(), buffer);
error = CMBufferQueueEnqueue(m_outputBufferQueue.get(), buffer.get());
if (error) {
RELEASE_LOG_ERROR(MediaStream, "AudioSampleBufferCompressor CMBufferQueueEnqueue failed with %d", error);
return;

0 comments on commit a0d1430

Please sign in to comment.