Commit 7cca8293 authored by newt's avatar newt Committed by Commit bot

Fix jank caused by infobars appearing.

When the InfoBarContainer is first attached to the window,
View.initialAwakenScrollBars() is called on it. Even though the scrollbars
aren't visible, this schedules a delayed runnable to fade out the scrollbars
1.2 seconds later. This delayed runnable (View$ScrollabilityCache) then calls
View.invalidate() repeatedly as it fades out the (already invisible) scrollbar,
which pauses scroll updates and touch event handling for 10 to 15 frames.

This CL disables the scrollbars on the InfoBarContainer, except in the rare
case that the container is actually scrollable (i.e. when infobars take up the
entire screen). In that case, page jank doesn't matter since the user can't
even see the webpage!

BUG=407149
NOTRY=true

Review URL: https://codereview.chromium.org/588843002

Cr-Commit-Position: refs/heads/master@{#295849}
parent 3d6e847d
......@@ -114,6 +114,9 @@ public class InfoBarContainer extends ScrollView {
int tabId, ViewGroup parentView, WebContents webContents) {
super(activity);
// Workaround for http://crbug.com/407149. See explanation in onMeasure() below.
setVerticalScrollBarEnabled(false);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
int topMarginDp = DeviceFormFactor.isTablet(activity)
......@@ -143,6 +146,19 @@ public class InfoBarContainer extends ScrollView {
mNativeInfoBarContainer = nativeInit(webContents, mAutoLoginDelegate);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// Only enable scrollbars when the view is actually scrollable.
// This prevents 10-15 frames of jank that would otherwise occur 1.2 seconds after the
// InfoBarContainer is attached to the window. See: http://crbug.com/407149
boolean canScroll = mLinearLayout.getMeasuredHeight() > getMeasuredHeight();
if (canScroll != isVerticalScrollBarEnabled()) {
setVerticalScrollBarEnabled(canScroll);
}
}
/**
* @return The LinearLayout that holds the infobars (i.e. the ContentWrapperViews).
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment