peek / peek-performance_bar

Take a peek into the window.performance timing behind your Rails app.
MIT License
57 stars 20 forks source link

Incorrect time displayed for frontend when request is made via PJAX/Turbolinks in Firefox #18

Closed brandonweiss closed 8 years ago

brandonweiss commented 10 years ago

This is what I'm seeing:

y13i82j5ipnnsrylxzakiowaas7058mxm0fmnf6jlzy

The backend time is being correctly calculated, although it's being shoved offscreen because of the incorrect frontend time.

brandonweiss commented 10 years ago

When the page is first loaded, the start and end times that are passed to the frontend bar look like this:

"start: 1399493087380"
"end: 1399493087910"

When a PJAX/Turbolinks request is made, I logged both the ajaxStart and ajaxEnd values, as well as the start and end values passed to the frontend bar.

"ajaxStart: 1399493273103421"
"ajaxEnd: 1399493273252544"
"start: 1399493273252544"
"end: 1399493273288"

Both ajaxStart and ajaxEnd are longer (more accurate) than start and end were previously. They're pulled from event.timeStamp. ajaxEnd becomes start in this instance, and end is calculated from new Date().getTime(). So this is why the time is off; subtracting the less accurate end from the more accurate start results in a negative, incorrect number. Not totally sure what the fix is yet.

brandonweiss commented 10 years ago

Ah, this is apparently a bug in Firefox regarding the definition of "epoch". Awesome.

dewski commented 8 years ago

It's been resolved upstream, thanks for reporting.