RESOLVED FIXED 120448
[Windows] Video inside a web page always falls back to non-hardware accelerated
https://bugs.webkit.org/show_bug.cgi?id=120448
Summary [Windows] Video inside a web page always falls back to non-hardware accelerated
Brent Fulgham
Reported 2013-08-28 17:40:51 PDT
If you render a web page that embeds a video element, WebKit is turning off compositing mode forcing the system to render through the non-hardware accelerated path. This is happening because RenderLayerCompositor::computeCompositingRequirements initially decides to turn compositing off (since the media element is usually represented as a static image before playing). Once the user interacts with the media element (to scrub video or play the movie), RenderLayerCompositor::computeCompositingRequirements recognizes that it needs to begin compositing and switches to the correct mode. However, the media player element has already been constructed in "non-hardware accelerated mode", and continues its lifetime without using hardware acceleration. We need to do one of the following: 1. When the render tree switches to compositing mode, destroy/recreate the player -or- 2. Somehow attache the D3D device to the player after construction?
Attachments
Patch (1.79 KB, patch)
2013-08-30 09:21 PDT, Brent Fulgham
no flags
Patch (2.68 KB, patch)
2013-08-30 12:05 PDT, Brent Fulgham
no flags
Patch (7.10 KB, patch)
2013-08-30 13:24 PDT, Brent Fulgham
no flags
Patch (7.11 KB, patch)
2013-08-30 14:59 PDT, Brent Fulgham
darin: review+
Radar WebKit Bug Importer
Comment 1 2013-08-28 17:41:25 PDT
Brent Fulgham
Comment 2 2013-08-30 09:19:33 PDT
*** Bug 120447 has been marked as a duplicate of this bug. ***
Brent Fulgham
Comment 3 2013-08-30 09:21:26 PDT
Eric Carlson
Comment 4 2013-08-30 09:27:27 PDT
Comment on attachment 210119 [details] Patch Nice simple fix!
Brent Fulgham
Comment 5 2013-08-30 09:39:21 PDT
Unscientific numbers: Before patch: Video playback consumed ~5% CPU on test page. After patch: Video playback consumed ~1% CPU on test page.
Brent Fulgham
Comment 6 2013-08-30 09:42:55 PDT
Simon Fraser (smfr)
Comment 7 2013-08-30 10:49:27 PDT
Comment on attachment 210119 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=210119&action=review > Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:415 > + player()->frameView()->enterCompositingMode(); Layering violation :(
Brent Fulgham
Comment 8 2013-08-30 10:56:05 PDT
(In reply to comment #7) > (From update of attachment 210119 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=210119&action=review > > > Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:415 > > + player()->frameView()->enterCompositingMode(); > > Layering violation :( Jer and I were discussing this, too. We could add a mediaPlayerClient method to handle this logic to avoid this happening.
Brent Fulgham
Comment 9 2013-08-30 11:59:34 PDT
This has triggered a regression. The contents around the video are not being repainted properly after flipping into compositing mode.
Brent Fulgham
Comment 10 2013-08-30 12:05:46 PDT
Brent Fulgham
Comment 11 2013-08-30 13:24:25 PDT
Eric Carlson
Comment 12 2013-08-30 13:29:12 PDT
Comment on attachment 210155 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=210155&action=review > Source/WebCore/rendering/RenderLayerCompositor.cpp:2076 > + return video->requiresImmediateCompositing() || (video->shouldDisplayVideo() && canAccelerateVideoRendering(video)); Parens would make this clearer: return (video->requiresImmediateCompositing() || (video->shouldDisplayVideo()) && canAccelerateVideoRendering(video)); > Source/WebCore/rendering/RenderVideo.cpp:287 > + MediaPlayer* p = mediaElement()->player(); > + if (p) This can be done on a single line.
Simon Fraser (smfr)
Comment 13 2013-08-30 14:00:18 PDT
Comment on attachment 210155 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=210155&action=review Is this testable? >> Source/WebCore/rendering/RenderLayerCompositor.cpp:2076 >> + return video->requiresImmediateCompositing() || (video->shouldDisplayVideo() && canAccelerateVideoRendering(video)); > > Parens would make this clearer: > > return (video->requiresImmediateCompositing() || (video->shouldDisplayVideo()) && canAccelerateVideoRendering(video)); WebKit style is to not add the outer parens.
Brent Fulgham
Comment 14 2013-08-30 14:59:31 PDT
Darin Adler
Comment 15 2013-08-30 15:33:49 PDT
Comment on attachment 210165 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=210165&action=review > Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h:88 > + virtual bool requiresImmediateCompositing() const { return true; } I’d like you to use OVERRIDE. I’d like to see a comment explaining why this player requires this; the comment in the change log is good, but I think it should be in the code too. To have a good place for the comment, I suggest not inlining this, since virtual calls won’t be inlined anyway. > Source/WebCore/rendering/RenderVideo.cpp:287 > + MediaPlayer* p = mediaElement()->player(); > + return p ? p->requiresImmediateCompositing() : false; I would write it like this: MediaPlayer* player = mediaElement()->player(); return player && player->requiresImmediateCompositing();
Darin Adler
Comment 16 2013-08-30 15:41:52 PDT
Did you see my comments? Looks like you landed this as-is and decided not to do the things I mentioned in the comments.
Brent Fulgham
Comment 17 2013-08-30 15:44:17 PDT
(In reply to comment #16) > Did you see my comments? Looks like you landed this as-is and decided not to do the things I mentioned in the comments. I'm making the changes now. I had set "webkit-patch land" to go after simon reviewed it, and didn't see your review until I had hit <enter>. Whoops!
Brent Fulgham
Comment 18 2013-08-30 15:50:42 PDT
Note You need to log in before you can comment on or make changes to this bug.