Closed Bug 1653165 Opened 7 months ago Closed 6 months ago

receive two navigation notifications of PerformanceObserver

Categories

(Core :: Performance, defect, P3)

77 Branch
defect

Tracking

()

RESOLVED FIXED
81 Branch
Tracking Status
firefox-esr68 --- unaffected
firefox-esr78 --- wontfix
firefox79 --- wontfix
firefox80 --- wontfix
firefox81 --- fixed

People

(Reporter: bh7578, Assigned: sefeng)

References

(Regression)

Details

(Keywords: regression)

Attachments

(4 files)

Attached file per_observer_test.html

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36

Steps to reproduce:

I wrote a page, use the PerformanceObserver to get the content load and load time of the page, the sample page is attached. You can open it with Firefox 77 to reproduce it. Also I tried the developer version firefox 79.0b7, it also has the same behavior. However on the Firefox 71, it only receive one time notification. Not sure it's a bug or not.

Actual results:

Assumed I only can receive one time navigation notification when open this page, but actually I received two times, and the first time happened before document receive DOMContentLoaded event.
Following is the page code:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="timeInfo" style="padding-left:20px"></div>
<script>

function addNavigationResult(entry) {
	console.log(JSON.stringify(entry.toJSON()));
    document.getElementById("timeInfo").innerHTML += "<BR><span id='unload'> Unload time: " + (entry.unloadEventEnd - entry.unloadEventStart) +
            " (ms) </span><BR><span id='dom_content_loaded'> DOM Content Loaded: " + (entry.domContentLoadedEventEnd - entry.domContentLoadedEventStart) + " (ms) </span>";
    if ((entry.domInteractive - entry.connectStart) > 0) {
        document.getElementById("timeInfo").innerHTML += " <BR><span id='dom_interactive'> DOM Interactive: " + (entry.domInteractive - entry.connectStart) + " (ms) </span>";
    }
    document.getElementById("timeInfo").innerHTML += " <BR> <span id='load'> Load time: " +
    (entry.loadEventEnd - entry.loadEventStart) + " (ms) </span><BR><BR>";
}

function addPerformanceObserver() {
    function perf_observer(list, observer) {
        var entries = list.getEntries();
        for (var i = 0; i < entries.length; i++) {
            if (entries[i].entryType === "navigation") {
                addNavigationResult(entries[i]);
            }
        }
    }

    var observer = new PerformanceObserver(perf_observer);
    observer.observe({entryTypes: ["navigation"]});
}

document.addEventListener('DOMContentLoaded', function(){
	console.log("*** DOMContentLoaded ***");
});

window.addEventListener('load', function(){
	console.log("*** load ***");
});

addPerformanceObserver();

</script>
</body>
</html>

Expected results:

I only can receive one time navigation notification.

Attached image ff71.0b5.png
Attached image ff77.png

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
Component: DOM: Core & HTML → Performance
Severity: -- → S3
Status: UNCONFIRMED → NEW
Has Regression Range: --- → no
Has STR: --- → yes
Ever confirmed: true
Priority: -- → P3
Regressed by: 1613140

Currently, we are not only updating the timing, but also sending
the timing to observers, which is not correct. According
to the Processing Modal of PerformanceNavigationTiming
(https://www.w3.org/TR/navigation-timing-2/#processing-model),
Queuing the task should be happened after user agent completes
the load event.

Assignee: nobody → sefeng
QA Whiteboard: [qa-regression-triage]
Pushed by sefeng@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5b5c9a90187b
Update PerformanceNavigationTiming before load event fires r=baku
Status: NEW → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch

Since the regressor bug was found and the issue is already fixed, I'm removing [qa-regression-triage].

QA Whiteboard: [qa-regression-triage]
You need to log in before you can comment on or make changes to this bug.