Changeset 280723 in webkit
- Timestamp:
- Aug 6, 2021, 8:09:20 AM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 7 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp (modified) (2 diffs)
-
WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (modified) (2 diffs)
-
WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (modified) (8 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (modified) (1 diff)
-
WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r280721 r280723 1 2021-08-06 Jer Noble <jer.noble@apple.com> 2 3 [Cocoa] Remove support for AVAssetImageGenerator 4 https://bugs.webkit.org/show_bug.cgi?id=228560 5 <rdar://problem/81336280> 6 7 Reviewed by Eric Carlson. 8 9 A much more minimal approach to removing support for AVAssetImageGenerator. 10 11 The only time we use an AVAssetImageGenerator (as opposed to an AVPlayerItemVideoOutput) 12 is when the latter does not currently have an available image enqueued. Because painting 13 is a synchronous operation, we use a synchronous API (the generator) to create an image 14 for that operation. However, this can create deadlocks if (for example) the resource needs 15 to load data on the main thread in order to complete the painting operation. 16 17 Instead, allow the main runloop to spin while waiting (up to 1_s) for the video output 18 to receive a decoded frame. 19 20 Drive-by fixes: 21 - Don't create an AVPlayerLayer at AVPlayer-creation; this causes the AVPlayerItemVideoOutput 22 to never receive a decoded frambe (as the layer is not in a CALayer-heirarchy). 23 - preferredRenderingMode() shouldn't be "none" when the page isn't visible. We already 24 just mark the layer as "hidden" in that case. 25 - Don't tear down the AVPlayerItemVideoOutput when creating an AVPlayerLayer; it'll just 26 get re-created anyway. 27 28 * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: 29 (WebCore::MediaPlayerPrivateAVFoundation::preferredRenderingMode const): 30 (WebCore::MediaPlayerPrivateAVFoundation::setUpVideoRendering): 31 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: 32 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 33 (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer): 34 (WebCore::MediaPlayerPrivateAVFoundationObjC::paintCurrentFrameInContext): 35 (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoOutput): 36 (WebCore::MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput): 37 (WebCore::MediaPlayerPrivateAVFoundationObjC::waitForVideoOutputMediaDataWillChange): 38 (WebCore::MediaPlayerPrivateAVFoundationObjC::outputMediaDataWillChange): 39 (-[WebCoreAVFPullDelegate outputMediaDataWillChange:]): 40 (-[WebCoreAVFPullDelegate setParent:]): 41 1 42 2021-08-06 Antti Koivisto <antti@apple.com> 2 43 -
trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp
r280624 r280723 106 106 MediaPlayerPrivateAVFoundation::MediaRenderingMode MediaPlayerPrivateAVFoundation::preferredRenderingMode() const 107 107 { 108 if ( !m_visible ||assetStatus() == MediaPlayerAVAssetStatusUnknown)108 if (assetStatus() == MediaPlayerAVAssetStatusUnknown) 109 109 return MediaRenderingNone; 110 110 … … 123 123 MediaRenderingMode preferredMode = preferredRenderingMode(); 124 124 125 if (preferredMode == MediaRenderingNone)126 preferredMode = MediaRenderingToContext;127 128 125 if (currentMode == preferredMode && currentMode != MediaRenderingNone) 129 126 return; 130 131 if (currentMode != MediaRenderingNone)132 tearDownVideoRendering();133 127 134 128 switch (preferredMode) { 135 129 case MediaRenderingNone: 130 tearDownVideoRendering(); 131 break; 132 136 133 case MediaRenderingToContext: 134 destroyVideoLayer(); 137 135 createContextVideoRenderer(); 138 136 break; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
r280624 r280723 118 118 119 119 MediaTime currentMediaTime() const final; 120 void outputMediaDataWillChange(); 120 121 121 122 private: … … 436 437 bool m_shouldPlayToPlaybackTarget { false }; 437 438 #endif 439 bool m_runningModalPaint { false }; 438 440 }; 439 441 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r280624 r280723 197 197 BinarySemaphore m_semaphore; 198 198 } 199 - (id)initWithPlayer:(WeakPtr<MediaPlayerPrivateAVFoundationObjC>&&)player; 199 200 - (void)outputMediaDataWillChange:(AVPlayerItemOutput *)sender; 200 201 - (void)outputSequenceWasFlushed:(AVPlayerItemOutput *)output; … … 1071 1072 } 1072 1073 1073 if (player()->isVideoPlayer())1074 createAVPlayerLayer();1075 1076 1074 if (m_avPlayerItem) 1077 1075 setAVPlayerItem(m_avPlayerItem.get()); … … 1803 1801 BEGIN_BLOCK_OBJC_EXCEPTIONS 1804 1802 1805 // Callers of this will often call copyVideoTextureToPlatformTexture first, 1806 // which calls updateLastPixelBuffer, which clears m_lastImage whenever the 1807 // video delivers a new frame. This breaks videoOutputHasAvailableFrame's 1808 // short-circuiting when m_lastImage is non-null, but the video often 1809 // doesn't have a new frame to deliver since the last time 1810 // hasNewPixelBufferForItemTime was called against m_videoOutput. To avoid 1811 // changing the semantics of videoOutputHasAvailableFrame in ways that might 1812 // break other callers, look for production of a recent pixel buffer from 1813 // the video output, too. 1814 if (videoOutputHasAvailableFrame() || (m_videoOutput && m_lastPixelBuffer)) 1815 paintWithVideoOutput(context, rect); 1816 else 1817 paintWithImageGenerator(context, rect); 1803 paintWithVideoOutput(context, rect); 1818 1804 1819 1805 END_BLOCK_OBJC_EXCEPTIONS … … 2440 2426 } 2441 2427 2442 m_videoOutputDelegate = adoptNS([[WebCoreAVFPullDelegate alloc] init ]);2428 m_videoOutputDelegate = adoptNS([[WebCoreAVFPullDelegate alloc] initWithPlayer:makeWeakPtr(*this)]); 2443 2429 [m_videoOutput setDelegate:m_videoOutputDelegate.get() queue:globalPullDelegateQueue()]; 2444 2430 … … 2524 2510 void MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput(GraphicsContext& context, const FloatRect& outputRect) 2525 2511 { 2526 // It's crucial to not wait synchronously for the next image. Videos that 2527 // come down this path are performing slow-case software uploads, and such 2528 // videos may not return metadata in a timely fashion. Use the most recently 2529 // available pixel buffer, if any. 2530 updateLastImage(); 2512 updateLastImage(UpdateType::UpdateSynchronously); 2531 2513 if (!m_lastImage) 2532 2514 return; … … 2568 2550 2569 2551 // Wait for 1 second. 2570 bool satisfied = [m_videoOutputDelegate semaphore].waitFor(1_s); 2552 MonotonicTime start = MonotonicTime::now(); 2553 2554 RunLoop::Timer<MediaPlayerPrivateAVFoundationObjC> timeoutTimer { RunLoop::main(), [] { 2555 RunLoop::main().stop(); 2556 } }; 2557 timeoutTimer.startOneShot(1_s); 2558 2559 m_runningModalPaint = true; 2560 RunLoop::run(); 2561 m_runningModalPaint = false; 2562 2563 bool satisfied = timeoutTimer.isActive(); 2571 2564 if (!satisfied) 2572 2565 ERROR_LOG(LOGIDENTIFIER, "timed out"); 2566 else 2567 INFO_LOG(LOGIDENTIFIER, "waiting for videoOutput took ", (MonotonicTime::now() - start).seconds()); 2568 } 2569 2570 void MediaPlayerPrivateAVFoundationObjC::outputMediaDataWillChange() 2571 { 2572 if (m_runningModalPaint) 2573 RunLoop::main().stop(); 2573 2574 } 2574 2575 … … 3900 3901 @end 3901 3902 3902 @implementation WebCoreAVFPullDelegate 3903 @implementation WebCoreAVFPullDelegate { 3904 WeakPtr<WebCore::MediaPlayerPrivateAVFoundationObjC> _player; 3905 } 3903 3906 3904 3907 @synthesize semaphore = m_semaphore; 3908 3909 - (id)initWithPlayer:(WeakPtr<MediaPlayerPrivateAVFoundationObjC>&&)player 3910 { 3911 self = [super init]; 3912 if (!self) 3913 return nil; 3914 _player = WTFMove(player); 3915 return self; 3916 } 3905 3917 3906 3918 - (void)outputMediaDataWillChange:(AVPlayerItemVideoOutput *)output … … 3908 3920 UNUSED_PARAM(output); 3909 3921 m_semaphore.signal(); 3922 RunLoop::main().dispatch([player = _player] { 3923 if (player) 3924 player->outputMediaDataWillChange(); 3925 }); 3910 3926 } 3911 3927 -
trunk/Source/WebKit/ChangeLog
r280722 r280723 1 2021-08-06 Jer Noble <jer.noble@apple.com> 2 3 [Cocoa] Remove support for AVAssetImageGenerator 4 https://bugs.webkit.org/show_bug.cgi?id=228560 5 <rdar://problem/81336280> 6 7 Reviewed by Eric Carlson. 8 9 Drive-by fix: we're passing the wrong value into acceleratedRenderingStateChanged(), and 10 we're not setting the correct initial value on MediaPlayerPrivateRemote creation. 11 12 * GPUProcess/media/RemoteMediaPlayerProxy.h: 13 * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp: 14 (WebKit::MediaPlayerPrivateRemote::MediaPlayerPrivateRemote): 15 (WebKit::MediaPlayerPrivateRemote::acceleratedRenderingStateChanged): 16 1 17 2021-08-06 Eric Carlson <eric.carlson@apple.com> 2 18 -
trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h
r279786 r280723 354 354 355 355 bool m_bufferedChanged { true }; 356 bool m_renderingCanBeAccelerated { true };356 bool m_renderingCanBeAccelerated { false }; 357 357 358 358 #if ENABLE(LEGACY_ENCRYPTED_MEDIA) && ENABLE(ENCRYPTED_MEDIA) -
trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp
r280624 r280723 115 115 { 116 116 INFO_LOG(LOGIDENTIFIER); 117 118 acceleratedRenderingStateChanged(); 117 119 } 118 120 #endif … … 456 458 { 457 459 if (auto player = makeRefPtr(m_player.get())) 458 connection().send(Messages::RemoteMediaPlayerProxy::AcceleratedRenderingStateChanged(player-> supportsAcceleratedRendering()), m_id);460 connection().send(Messages::RemoteMediaPlayerProxy::AcceleratedRenderingStateChanged(player->renderingCanBeAccelerated()), m_id); 459 461 } 460 462
Note:
See TracChangeset
for help on using the changeset viewer.