Open Bug 1843850 Opened 1 year ago Updated 4 months ago

puppeteer: window.performance.fetchStart is negative after page navigation

Categories

(Core :: DOM: Performance, defect, P3)

Firefox 117
defect

Tracking

()

People

(Reporter: aslushnikov, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36

Steps to reproduce:

Consider the following Puppeteer 20.8.2 script that runs Firefox 117.0a1:

import pptr from 'puppeteer'

const browser = await pptr.launch({
  product: 'firefox',
});

const page = await browser.newPage();
await page.goto('https://example.com');
console.log(await page.evaluate(() => {
  return performance.getEntries()[0].fetchStart;
}));

await page.close();
await browser.close();

Actual results:

This script prints -1 for the fetchStart performance entry.

Expected results:

fetchStart should never be negative.

This was reported downstream to Playwright: https://github.com/microsoft/playwright/issues/21532

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Performance' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Performance
Product: Firefox → Core

The severity field is not set for this bug.
:fdoty, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(fdoty)
Performance Impact: --- → ?

This sounds like a valid bug, but it's a "bug" bug, not a performance bug. We'll need somebody to reproduce it (I haven't tried).

Status: UNCONFIRMED → NEW
Performance Impact: ? → ---
Ever confirmed: true
Severity: -- → S4
Flags: needinfo?(fdoty)

yeah this is a real bug, anybody around to take a look at this?

sefeng can you review to determine next steps, or if this is actionable?

Flags: needinfo?(sefeng)

I am able to reproduce this and Bug 1429422 sounds similar to this.

sefeng can you review to determine next steps, or if this is actionable?

This is actionable and the next step is someone to do the work :)

From https://bugzilla.mozilla.org/show_bug.cgi?id=1429422#c13, it looks like we need to change how navigationStart is computed, and since it's the baseline of all other metrics, this negative fetchStart issue may just be resolved once we've done that.

We might also be able to fix this without the above mentioned bug, it's just that someone needs to investigate this a bit further.

To reproduce this, I just used node to run the provided snippet. Something like, run these commands first

mkdir my-puppeteer-project
cd my-puppeteer-project
npm init -y
npm install puppeteer

and then run this script with node index.js

const pptr = require('puppeteer');

async function run() {
  const browser = await pptr.launch({
    product: 'firefox',
    executablePath: '/home/sefeng/.local/workspace/mozilla/mozilla-unified5/.build-obj/debug/dist/bin/firefox',
    headless: false  // Set to false to see the browser UI
  });

  const page = await browser.newPage();
  await page.goto('https://example.com');
  const fetchStart = await page.evaluate(() => {
    return performance.getEntries()[0].fetchStart;
  });
  console.log(fetchStart);

  await page.close();
  await browser.close();
}

run().catch(console.error);
Flags: needinfo?(sefeng)
See Also: → 1429422
Severity: S4 → S3
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.