Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55ad2efd authored by Chris Craik's avatar Chris Craik
Browse files

Fix tile benchmark tool stalls

bug:5062896
Change-Id: I2969e95481d65d5f87ce4399f09becc7b66d540a
parent 151763d3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@
    <string name="viewport_coverage">Coverage</string>
    <!-- Milliseconds taken to inval, and re-render the page [CHAR LIMIT=15] -->
    <string name="render_millis">RenderMillis</string>
    <!-- Number of rendering stalls while running the test [CHAR LIMIT=15] -->
    <string name="render_stalls">Stalls</string>
    <!-- Format string for stat value overlay [CHAR LIMIT=15] -->
    <string name="format_stat">%4.4f</string>

+1 −13
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.util.Pair;
import android.view.KeyEvent;
import android.view.View;
@@ -55,8 +54,6 @@ public class ProfileActivity extends Activity {
    }

    public static final String TEMP_FILENAME = "profile.tiles";
    private static final int LOAD_TEST_DELAY = 1000; // nr of millis after load,
                                                     // before test

    Button mInspectButton;
    ToggleButton mCaptureButton;
@@ -136,17 +133,8 @@ public class ProfileActivity extends Activity {
            super.onPageFinished(view, url);
            view.requestFocus();

            new CountDownTimer(LOAD_TEST_DELAY, LOAD_TEST_DELAY) {
                @Override
                public void onTick(long millisUntilFinished) {
                }

                @Override
                public void onFinish() {
            startViewProfiling(true);
        }
            }.start();
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
+43 −8
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.test.tilebenchmark;

import android.content.Context;
import android.os.CountDownTimer;
import android.util.AttributeSet;
import android.util.Log;
import android.webkit.WebView;
@@ -27,10 +28,14 @@ import com.test.tilebenchmark.RunData.TileData;
public class ProfiledWebView extends WebView {
    private int mSpeed;

    private boolean isTesting = false;
    private boolean isScrolling = false;
    private boolean mIsTesting = false;
    private boolean mIsScrolling = false;
    private ProfileCallback mCallback;
    private long mContentInvalMillis;
    private boolean mHadToBeForced = false;
    private int mTestCount = 0;
    private static final int LOAD_STALL_MILLIS = 5000; // nr of millis after load,
                                                       // before test is forced

    public ProfiledWebView(Context context) {
        super(context);
@@ -51,12 +56,12 @@ public class ProfiledWebView extends WebView {

    @Override
    protected void onDraw(android.graphics.Canvas canvas) {
        if (isTesting && isScrolling) {
        if (mIsTesting && mIsScrolling) {
            if (canScrollVertically(1)) {
                scrollBy(0, mSpeed);
            } else {
                stopScrollTest();
                isScrolling = false;
                mIsScrolling = false;
            }
        }
        super.onDraw(canvas);
@@ -68,13 +73,36 @@ public class ProfiledWebView extends WebView {
     * scrolling, invalidate all content and redraw it, measuring time taken.
     */
    public void startScrollTest(ProfileCallback callback, boolean autoScrolling) {
        isScrolling = autoScrolling;
        mIsScrolling = autoScrolling;
        mCallback = callback;
        isTesting = false;
        mIsTesting = false;
        mContentInvalMillis = System.currentTimeMillis();
        registerPageSwapCallback();
        contentInvalidateAll();
        invalidate();

        mTestCount++;
        final int testCount = mTestCount;

        if (autoScrolling) {
            // after a while, force it to start even if the pages haven't swapped
            new CountDownTimer(LOAD_STALL_MILLIS, LOAD_STALL_MILLIS) {
                @Override
                public void onTick(long millisUntilFinished) {
                }

                @Override
                public void onFinish() {
                    if (testCount == mTestCount && !mIsTesting) {
                        mHadToBeForced = true;
                        Log.d("ProfiledWebView", "num " + testCount
                                + " forcing a page swap with a scroll...");
                        scrollBy(0, 1);
                        invalidate(); // ensure a redraw so that auto-scrolling can occur
                    }
                }
            }.start();
        }
    }

    /*
@@ -87,7 +115,7 @@ public class ProfiledWebView extends WebView {
        super.pageSwapCallback();
        Log.d("ProfiledWebView", "REDRAW TOOK " + mContentInvalMillis
                + "millis");
        isTesting = true;
        mIsTesting = true;
        invalidate(); // ensure a redraw so that auto-scrolling can occur
        tileProfilingStart();
    }
@@ -97,7 +125,7 @@ public class ProfiledWebView extends WebView {
     */
    public void stopScrollTest() {
        tileProfilingStop();
        isTesting = false;
        mIsTesting = false;

        if (mCallback == null) {
            tileProfilingClear();
@@ -105,8 +133,15 @@ public class ProfiledWebView extends WebView {
        }

        RunData data = new RunData(super.tileProfilingNumFrames());
        // record the time spent (before scrolling) rendering the page
        data.singleStats.put(getResources().getString(R.string.render_millis),
                (double)mContentInvalMillis);
        // record if the page render timed out
        Log.d("ProfiledWebView", "hadtobeforced = " + mHadToBeForced);
        data.singleStats.put(getResources().getString(R.string.render_stalls),
                             mHadToBeForced ? 1.0 : 0.0);
        mHadToBeForced = false;

        for (int frame = 0; frame < data.frames.length; frame++) {
            data.frames[frame] = new TileData[
                    tileProfilingNumTilesInFrame(frame)];
+1 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ public class PerformanceTest extends
    private static final String URL_POSTFIX = "/index.html?skip=true";
    private static final int MAX_ITERATIONS = 4;
    private static final String TEST_DIRS[] = {
            "alexa_us"//, "android", "dom", "intl1", "intl2", "moz", "moz2"
        "intl1"//, "alexa_us", "android", "dom", "intl2", "moz", "moz2"
    };

    public PerformanceTest() {