Changeset 274264 in webkit
- Timestamp:
- Mar 10, 2021, 6:40:35 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/platform/wk2/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/HTMLMediaElement.cpp (modified) (2 diffs)
-
Source/WebCore/html/HTMLMediaElement.h (modified) (2 diffs)
-
Source/WebCore/rendering/RenderVideo.cpp (modified) (2 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp (modified) (2 diffs)
-
Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.h (modified) (1 diff)
-
Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.messages.in (modified) (1 diff)
-
Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp (modified) (1 diff)
-
Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (modified) (1 diff)
-
Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm (modified) (1 diff)
-
Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (modified) (5 diffs)
-
Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h (modified) (2 diffs)
-
Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.messages.in (modified) (1 diff)
-
Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r274244 r274264 1 2021-03-10 Peng Liu <peng.liu6@apple.com> 2 3 [GPU Process] Assertion under RenderLayerCompositor::computeCompositingRequirements() 4 https://bugs.webkit.org/show_bug.cgi?id=220375 5 6 Reviewed by Eric Carlson. 7 8 * platform/wk2/TestExpectations: 9 1 10 2021-03-10 Chris Gambrell <cgambrell@apple.com> 2 11 -
trunk/LayoutTests/platform/wk2/TestExpectations
r274244 r274264 255 255 256 256 webkit.org/b/221783 [ Debug ] loader/change-src-during-iframe-load-crash.html [ Skip ] 257 258 # webkit.org/b/220375259 [ Debug ] imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/event_loadedmetadata.html [ Crash Pass ]260 [ Debug ] imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/event_progress.html [ Crash Pass ]261 [ Debug ] imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/readyState_during_loadeddata.html [ Crash Pass ]262 257 263 258 webkit.org/b/222569 fast/mediastream/media-stream-track-interrupted.html [ Crash Pass ] -
trunk/Source/WebCore/ChangeLog
r274258 r274264 1 2021-03-10 Peng Liu <peng.liu6@apple.com> 2 3 [GPU Process] Assertion under RenderLayerCompositor::computeCompositingRequirements() 4 https://bugs.webkit.org/show_bug.cgi?id=220375 5 6 Reviewed by Eric Carlson. 7 8 `MediaPlayer` calls `HTMLMediaElement::mediaEngineWasUpdated()` when a media element 9 loads a new URL and `MediaPlayer::supportsAcceleratedRendering()` may change from 10 false to true at the same time. However, `HTMLMediaElement::mediaEngineWasUpdated()` 11 does not notify the renderer about the change in the same run loop. Instead, it 12 schedules a task to do that. This leads to a race condition that 13 `RenderLayerBacking::contentChanged(VideoChanged)` gets called after the compositing 14 update where `RenderLayerCompositor::canAccelerateVideoRendering()` returns true. 15 This happens because renderer checks `MediaPlayer::supportsAcceleratedRendering()` 16 in `RenderLayerCompositor::canAccelerateVideoRendering()`, which changes its value 17 when `MediaPlayer` calls `HTMLMediaElement::mediaEngineWasUpdated()`. 18 19 To fix this race condition, `HTMLMediaElement` needs to notify `RenderVideo` and 20 changes the `supportsAcceleratedRendering` property seen from renderer's perspective 21 in the same run loop. With this patch, `HTMLMediaElement` keeps a cached value of 22 `MediaPlayer::supportsAcceleratedRendering()`, and only updates its value when 23 `HTMLMediaElement` notifies the renderer. In addition, `RenderVideo` checks 24 `HTMLMediaElement::supportsAcceleratedRendering()` instead of 25 `MediaPlayer::supportsAcceleratedRendering()`, so that the renderer will 26 see the new value of `supportsAcceleratedRendering` and receive the content 27 change notification in the same run loop. 28 29 No new tests. Fix assertion failures in tests. 30 31 * html/HTMLMediaElement.cpp: 32 (WebCore::HTMLMediaElement::mediaEngineWasUpdated): 33 (WebCore::HTMLMediaElement::clearMediaPlayer): 34 * html/HTMLMediaElement.h: 35 (WebCore::HTMLMediaElement::supportsAcceleratedRendering const): 36 * rendering/RenderVideo.cpp: 37 (WebCore::RenderVideo::paintReplaced): 38 (WebCore::RenderVideo::supportsAcceleratedRendering const): 39 1 40 2021-03-10 Chris Dumez <cdumez@apple.com> 2 41 -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r274175 r274264 5006 5006 5007 5007 beginProcessingMediaPlayerCallback(); 5008 m_cachedSupportsAcceleratedRendering = m_player && m_player->supportsAcceleratedRendering(); 5008 5009 updateRenderer(); 5009 5010 endProcessingMediaPlayerCallback(); … … 5516 5517 m_player->invalidate(); 5517 5518 m_player = nullptr; 5519 m_cachedSupportsAcceleratedRendering = false; 5518 5520 } 5519 5521 schedulePlaybackControlsManagerUpdate(); -
trunk/Source/WebCore/html/HTMLMediaElement.h
r274175 r274264 147 147 148 148 RefPtr<MediaPlayer> player() const { return m_player; } 149 bool supportsAcceleratedRendering() const { return m_cachedSupportsAcceleratedRendering; } 149 150 150 151 virtual bool isVideo() const { return false; } … … 1018 1019 1019 1020 RefPtr<MediaPlayer> m_player; 1021 bool m_cachedSupportsAcceleratedRendering { false }; 1020 1022 1021 1023 MediaPlayer::Preload m_preload { Preload::Auto }; -
trunk/Source/WebCore/rendering/RenderVideo.cpp
r269407 r274264 230 230 if (displayingPoster) 231 231 paintIntoRect(paintInfo, rect); 232 else if (!videoElement().isFullscreen() || ! mediaPlayer->supportsAcceleratedRendering()) {232 else if (!videoElement().isFullscreen() || !videoElement().supportsAcceleratedRendering()) { 233 233 if (paintInfo.paintBehavior.contains(PaintBehavior::FlattenCompositingLayers)) 234 234 context.paintFrameForMedia(*mediaPlayer, rect); … … 295 295 bool RenderVideo::supportsAcceleratedRendering() const 296 296 { 297 if (auto player = videoElement().player()) 298 return player->supportsAcceleratedRendering(); 299 return false; 297 return videoElement().supportsAcceleratedRendering(); 300 298 } 301 299 -
trunk/Source/WebKit/ChangeLog
r274252 r274264 1 2021-03-10 Peng Liu <peng.liu6@apple.com> 2 3 [GPU Process] Assertion under RenderLayerCompositor::computeCompositingRequirements() 4 https://bugs.webkit.org/show_bug.cgi?id=220375 5 6 Reviewed by Eric Carlson. 7 8 When "GPU Process: Media" is enabled, `MediaPlayer` will call `mediaPlayerEngineUpdated()` 9 three times when a media element tries to load a URL. The three calls happen at the 10 following time points: 11 1) `MediaPlayer` creates a `MediaPlayerPrivateRemote`. 12 2) `MediaPlayerPrivateRemote` receives the response of a "createMediaPlayer" message 13 from the GPU process and gets the initial configurations of the "remote" media player. 14 3) The `RemoteMediaPlayerProxy` creates a `MediaPlayerPrivate` in the GPU process and 15 notify the `MediaPlayerPrivateRemote` in the WebContent process. 16 17 The second call of `mediaPlayerEngineUpdated()` is unnecessary because the player's 18 configuration at that time is similar to `NullMediaPlayerPrivate`. This patch removes it. 19 20 For the third call of `mediaPlayerEngineUpdated()`, we have to make sure that 21 the `MediaPlayerPrivateRemote` has received the configuration update from the GPU 22 process before the call. Therefore, this patch removes the message 23 `MediaPlayerPrivateRemote::EngineUpdated`, and let `MediaPlayerPrivateRemote` 24 decide when to call `mediaPlayerEngineUpdated()`. 25 26 * GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp: 27 (WebKit::RemoteMediaPlayerManagerProxy::createMediaPlayer): 28 * GPUProcess/media/RemoteMediaPlayerManagerProxy.h: 29 * GPUProcess/media/RemoteMediaPlayerManagerProxy.messages.in: 30 The `playerConfiguration` is meaningless in this step so we can remove it. 31 32 * GPUProcess/media/RemoteMediaPlayerProxy.cpp: 33 (WebKit::RemoteMediaPlayerProxy::mediaPlayerEngineUpdated): Deleted. 34 * GPUProcess/media/RemoteMediaPlayerProxy.h: 35 * GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm: 36 (WebKit::RemoteMediaPlayerProxy::prepareForPlayback): 37 38 * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp: 39 (WebKit::MediaPlayerPrivateRemote::MediaPlayerPrivateRemote): 40 (WebKit::MediaPlayerPrivateRemote::load): 41 (WebKit::MediaPlayerPrivateRemote::setConfiguration): Deleted. 42 (WebKit::MediaPlayerPrivateRemote::engineUpdated): Deleted. 43 * WebProcess/GPU/media/MediaPlayerPrivateRemote.h: 44 * WebProcess/GPU/media/MediaPlayerPrivateRemote.messages.in: 45 46 * WebProcess/GPU/media/RemoteMediaPlayerManager.cpp: 47 (WebKit::RemoteMediaPlayerManager::createRemoteMediaPlayer): 48 1 49 2021-03-10 Chris Dumez <cdumez@apple.com> 2 50 -
trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.cpp
r274189 r274264 58 58 } 59 59 60 void RemoteMediaPlayerManagerProxy::createMediaPlayer(MediaPlayerIdentifier identifier, MediaPlayerEnums::MediaEngineIdentifier engineIdentifier, RemoteMediaPlayerProxyConfiguration&& proxyConfiguration , CompletionHandler<void(RemoteMediaPlayerConfiguration&)>&& completionHandler)60 void RemoteMediaPlayerManagerProxy::createMediaPlayer(MediaPlayerIdentifier identifier, MediaPlayerEnums::MediaEngineIdentifier engineIdentifier, RemoteMediaPlayerProxyConfiguration&& proxyConfiguration) 61 61 { 62 62 ASSERT(RunLoop::isMain()); … … 66 66 ASSERT(!m_proxies.contains(identifier)); 67 67 68 RemoteMediaPlayerConfiguration playerConfiguration;69 70 68 auto proxy = makeUnique<RemoteMediaPlayerProxy>(*this, identifier, m_gpuConnectionToWebProcess->connection(), engineIdentifier, WTFMove(proxyConfiguration)); 71 proxy->getConfiguration(playerConfiguration);72 69 m_proxies.add(identifier, WTFMove(proxy)); 73 74 completionHandler(playerConfiguration);75 70 } 76 71 -
trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.h
r274189 r274264 72 72 bool didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, UniqueRef<IPC::Encoder>&) final; 73 73 74 void createMediaPlayer(WebCore::MediaPlayerIdentifier, WebCore::MediaPlayerEnums::MediaEngineIdentifier, RemoteMediaPlayerProxyConfiguration&& , CompletionHandler<void(RemoteMediaPlayerConfiguration&)>&&);74 void createMediaPlayer(WebCore::MediaPlayerIdentifier, WebCore::MediaPlayerEnums::MediaEngineIdentifier, RemoteMediaPlayerProxyConfiguration&&); 75 75 void deleteMediaPlayer(WebCore::MediaPlayerIdentifier); 76 76 -
trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerManagerProxy.messages.in
r274021 r274264 25 25 26 26 messages -> RemoteMediaPlayerManagerProxy NotRefCounted { 27 CreateMediaPlayer(WebCore::MediaPlayerIdentifier identifier, enum:uint8_t WebCore::MediaPlayerEnums::MediaEngineIdentifier remoteEngineIdentifier, struct WebKit::RemoteMediaPlayerProxyConfiguration proxyConfiguration) -> (struct WebKit::RemoteMediaPlayerConfiguration playerConfiguration) Async27 CreateMediaPlayer(WebCore::MediaPlayerIdentifier identifier, enum:uint8_t WebCore::MediaPlayerEnums::MediaEngineIdentifier remoteEngineIdentifier, struct WebKit::RemoteMediaPlayerProxyConfiguration proxyConfiguration) 28 28 DeleteMediaPlayer(WebCore::MediaPlayerIdentifier identifier) 29 29 -
trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp
r273526 r274264 631 631 } 632 632 633 void RemoteMediaPlayerProxy::mediaPlayerEngineUpdated()634 {635 m_webProcessConnection->send(Messages::MediaPlayerPrivateRemote::EngineUpdated(), m_id);636 }637 638 633 void RemoteMediaPlayerProxy::mediaPlayerActiveSourceBuffersChanged() 639 634 { -
trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h
r274189 r274264 214 214 void mediaPlayerResourceNotSupported() final; 215 215 void mediaPlayerEngineFailedToLoad() const final; 216 void mediaPlayerEngineUpdated() final;217 216 void mediaPlayerActiveSourceBuffersChanged() final; 218 217 void mediaPlayerBufferedTimeRangesChanged() final; -
trunk/Source/WebKit/GPUProcess/media/cocoa/RemoteMediaPlayerProxyCocoa.mm
r273568 r274264 55 55 m_player->setPreload(preload); 56 56 m_player->setPreservesPitch(preservesPitch); 57 m_player->prepareForRendering(); 57 if (prepareForRendering) 58 m_player->prepareForRendering(); 58 59 m_videoContentScale = videoContentScale; 59 60 if (!m_inlineLayerHostingContext) -
trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp
r274174 r274264 112 112 , m_remoteEngineIdentifier(engineIdentifier) 113 113 , m_id(playerIdentifier) 114 , m_documentSecurityOrigin(player->documentSecurityOrigin()) 114 115 { 115 116 INFO_LOG(LOGIDENTIFIER); … … 129 130 m_audioSourceProvider->close(); 130 131 #endif 131 }132 133 void MediaPlayerPrivateRemote::setConfiguration(RemoteMediaPlayerConfiguration&& configuration, WebCore::SecurityOriginData&& documentSecurityOrigin)134 {135 m_configuration = WTFMove(configuration);136 m_documentSecurityOrigin = WTFMove(documentSecurityOrigin);137 m_player->mediaEngineUpdated();138 132 } 139 133 … … 182 176 } 183 177 184 connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::Load(url, sandboxExtensionHandle, contentType, keySystem), [weakThis = makeWeakPtr(*this)](auto&& configuration) { 185 if (weakThis) 186 weakThis->m_configuration = WTFMove(configuration); 178 connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::Load(url, sandboxExtensionHandle, contentType, keySystem), [weakThis = makeWeakPtr(*this), this](auto&& configuration) { 179 if (!weakThis) 180 return; 181 182 m_configuration = WTFMove(configuration); 183 m_player->mediaEngineUpdated(); 187 184 }, m_id); 188 185 } … … 662 659 if (m_remoteEngineIdentifier == MediaPlayerEnums::MediaEngineIdentifier::AVFoundationMSE) { 663 660 auto identifier = RemoteMediaSourceIdentifier::generate(); 664 connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::LoadMediaSource(url, contentType, RuntimeEnabledFeatures::sharedFeatures().webMParserEnabled(), identifier), [weakThis = makeWeakPtr(*this)](auto&& configuration) { 665 if (weakThis) 666 weakThis->m_configuration = WTFMove(configuration); 661 connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::LoadMediaSource(url, contentType, RuntimeEnabledFeatures::sharedFeatures().webMParserEnabled(), identifier), [weakThis = makeWeakPtr(*this), this](auto&& configuration) { 662 if (!weakThis) 663 return; 664 665 m_configuration = WTFMove(configuration); 666 m_player->mediaEngineUpdated(); 667 667 }, m_id); 668 668 m_mediaSourcePrivate = MediaSourcePrivateRemote::create(m_manager.gpuProcessConnection(), identifier, m_manager.typeCache(m_remoteEngineIdentifier), *this, client); … … 1222 1222 } 1223 1223 1224 void MediaPlayerPrivateRemote::engineUpdated()1225 {1226 m_player->mediaEngineUpdated();1227 }1228 1229 1224 void MediaPlayerPrivateRemote::activeSourceBuffersChanged() 1230 1225 { -
trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h
r274172 r274264 82 82 ~MediaPlayerPrivateRemote(); 83 83 84 void setConfiguration(RemoteMediaPlayerConfiguration&&, WebCore::SecurityOriginData&&);85 86 84 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; 87 85 … … 144 142 void resourceNotSupported(); 145 143 146 void engineUpdated();147 148 144 void activeSourceBuffersChanged(); 149 145 -
trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.messages.in
r270563 r274264 72 72 ResourceNotSupported() 73 73 74 EngineUpdated()75 76 74 ActiveSourceBuffersChanged() 77 75 -
trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.cpp
r274021 r274264 166 166 167 167 auto identifier = MediaPlayerIdentifier::generate(); 168 RemoteMediaPlayerConfiguration playerConfiguration; 169 auto completionHandler = [this, weakThis = makeWeakPtr(this), identifier, documentSecurityOrigin = WTFMove(documentSecurityOrigin)](auto&& playerConfiguration) mutable { 170 if (!weakThis) 171 return; 172 173 if (const auto& player = m_players.get(identifier)) 174 player->setConfiguration(WTFMove(playerConfiguration), WTFMove(documentSecurityOrigin)); 175 }; 176 177 gpuProcessConnection().connection().sendWithAsyncReply(Messages::RemoteMediaPlayerManagerProxy::CreateMediaPlayer(identifier, remoteEngineIdentifier, proxyConfiguration), completionHandler, 0); 168 gpuProcessConnection().connection().send(Messages::RemoteMediaPlayerManagerProxy::CreateMediaPlayer(identifier, remoteEngineIdentifier, proxyConfiguration), 0); 178 169 179 170 auto remotePlayer = MediaPlayerPrivateRemote::create(player, remoteEngineIdentifier, identifier, *this);
Note:
See TracChangeset
for help on using the changeset viewer.