tracerbench icon indicating copy to clipboard operation
tracerbench copied to clipboard

Could not find Paint event in trace after last mark

Open lifeart opened this issue 3 years ago • 3 comments

This issue is not regular, but appear quite often on same HAR file if we have a lot of samples and it cause the whole compare run to fail.

image

wondering, is a way to enforce paint event inside tracerbench or ignore this assert?

or rerun exact experiment, because it's quite painful to catch this event on attempt №99 (of 100)

looks like closest logic to it landed in https://github.com/TracerBench/tracerbench/pull/200, especially https://github.com/TracerBench/tracerbench/pull/200/files#diff-0f54ca8abebf7489fe5914256d43426b584a7cbca147eeb2bb25c506c62a4299R41

in theory, we could enforce Paint event, like Modernizr do it: https://github.com/Modernizr/Modernizr/blob/master/test/browser/src/mq.js#L29

function enforcePaintEvent() {

    const docElem = document.documentElement;
    const refNode = docElem.firstElementChild || docElem.firstChild;
    const fakeBody = document.createElement('body');
    const div = document.createElement('div');

    div.id = 'mq-test-1';
    div.style.cssText = 'position:absolute;top:-100em';
    fakeBody.style.background = 'none';
    fakeBody.appendChild(div);
    div.innerHTML = '&shy;<style> #mq-test-1 { width: 42px; }</style>';
    docElem.insertBefore(fakeBody, refNode);

    try {
        return div.offsetWidth === 42;
    } finally {
        fakeBody.removeChild(div);
        docElem.removeChild(fakeBody);
    }

}


requestAnimationFrame(() => {
    enforcePaintEvent();
    requestIdleCallback(() => {          __tracerbench.stop();        });
});

lifeart avatar Apr 28 '21 17:04 lifeart

@lifeart can we observe observe({type: 'largest-contentful-paint', buffered: true}) when using the navigation timing marks? also, you shouldn't need to use both requestAnimationFrame and requestIdleCallback, requestIdleCallback is supposed to come in the idle space after paint already.

krisselden avatar Sep 01 '21 21:09 krisselden

We have a todo to add web-vitals metrics, so waiting for them maybe a good idea.

krisselden avatar Sep 01 '21 21:09 krisselden

@krisselden I think so, but this code sometimes throw mentioned error:

image

without paint event fired

lifeart avatar Sep 02 '21 09:09 lifeart