Bug 134208 - Reduce synchronous layout triggered by JavaScript-based media controls
Summary: Reduce synchronous layout triggered by JavaScript-based media controls
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 412.x
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Depends on:
Reported: 2014-06-23 12:36 PDT by Joseph Pecoraro
Modified: 2014-06-23 14:01 PDT (History)
9 users (show)

See Also:

[PATCH] Proposed Fix (9.20 KB, patch)
2014-06-23 12:47 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2014-06-23 12:36:25 PDT
JavaScript-based media controls are triggering synchronous layout potentially multiple times during page loads with media elements. This causes unnecessary work during page loads. 

Specifically, the Apple and iOS media controls updateProgress methods, querying the offsetWidth/offsetHeight of the timeline:

>    updateProgress: function() {
>        Controller.prototype.updateProgress.call(this);
>        var width = this.controls.timeline.offsetWidth;
>        var height = this.controls.timeline.offsetHeight;
>        ...
>    }

During a normal page load of a <video controls url="..."> this gets triggered 8 times. We should be able to reduce that.
Comment 1 Joseph Pecoraro 2014-06-23 12:47:59 PDT
Created attachment 233628 [details]
[PATCH] Proposed Fix

Based on measurements from Andreas this improved PLT by ~0.5%. It reduces the number of calls to offsetWidth from 8 to 3 when just loading a page with a video and controls.

I see one possible issue with this patch, if the media element itself changes size the cached values may be wrong. That is because the timeline is flex based and we do not know when the element itself changed size. So that may be a regression that could be addressed later.
Comment 2 WebKit Commit Bot 2014-06-23 14:01:44 PDT
Comment on attachment 233628 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 233628

Committed r170315: <http://trac.webkit.org/changeset/170315>
Comment 3 WebKit Commit Bot 2014-06-23 14:01:48 PDT
All reviewed patches have been landed.  Closing bug.