Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
display:none HTMLMediaElement with a camera track as source is leakin…
…g video frames https://bugs.webkit.org/show_bug.cgi?id=242939 rdar://96677785 Reviewed by Eric Carlson. AVSampleBufferDisplayLayer is keeping CVPixelBuffers when it cannot display them, which happens on iOS in case HTMLMediaElement is display:none. In that case, the camera buffer pool might get exhausted and this will fail camera capture. We fixed this by making sure to not enqueue frames in that case, but this got broken in d126b89. We reintroduce a specific callback renderVideoWillBeDestroyed so that only MediaPlayerPrivateMediaStreamAVFObjC is changed. To make our mock camera closer to actual cameras, we create CVPixelBuffer from a pool with kCVPixelBufferPoolAllocationThresholdKey. This should allow to test CVPixelBuffer camera leaks. Update LayoutTests/fast/mediastream/resources/getUserMedia-to-canvas.js to make sure we do not keep a VideoFrame for each video element as otherwise, we can run out of camera frames. * LayoutTests/fast/mediastream/getUserMedia-media-element-display-none-expected.txt: Added. * LayoutTests/fast/mediastream/getUserMedia-media-element-display-none.html: Added. * LayoutTests/fast/mediastream/resources/getUserMedia-to-canvas.js: (createUserMediaToCanvasTests): * Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp: * Source/WebCore/platform/cocoa/CoreVideoSoftLink.h: * Source/WebCore/platform/graphics/MediaPlayer.cpp: (WebCore::MediaPlayer::renderVideoWillBeDestroyed): * Source/WebCore/platform/graphics/MediaPlayer.h: * Source/WebCore/platform/graphics/MediaPlayerPrivate.h: (WebCore::MediaPlayerPrivateInterface::renderVideoWillBeDestroyed): * Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * Source/WebCore/platform/graphics/cv/CVUtilities.h: * Source/WebCore/platform/graphics/cv/CVUtilities.mm: (WebCore::createCVPixelBufferFromPool): * Source/WebCore/platform/graphics/cv/ImageTransferSessionVT.h: (WebCore::ImageTransferSessionVT::setMaximumBufferPoolSize): * Source/WebCore/platform/graphics/cv/ImageTransferSessionVT.mm: (WebCore::ImageTransferSessionVT::convertPixelBuffer): * Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h: * Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm: (WebCore::MockRealtimeVideoSourceMac::updateSampleBuffer): * Source/WebCore/rendering/RenderVideo.cpp: (WebCore::RenderVideo::willBeDestroyed): Canonical link: https://commits.webkit.org/252871@main
- Loading branch information
Showing
16 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
LayoutTests/fast/mediastream/getUserMedia-media-element-display-none-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS Media element should not store video frames in display=none case | ||
|
22 changes: 22 additions & 0 deletions
22
LayoutTests/fast/mediastream/getUserMedia-media-element-display-none.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<script src="../../resources/testharness.js"></script> | ||
<script src="../../resources/testharnessreport.js"></script> | ||
</head> | ||
<body> | ||
<video id="video" autoplay></video> | ||
<script> | ||
promise_test(async (test) => { | ||
video.srcObject = await navigator.mediaDevices.getUserMedia({ video: true }); | ||
await video.play(); | ||
video.style.display = 'none'; | ||
return new Promise((resolve, reject) => { | ||
video.srcObject.getVideoTracks()[0].onended = () => reject('capture failed'); | ||
setTimeout(resolve, 3000); | ||
}); | ||
}, "Media element should not store video frames in display=none case"); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters