Page MenuHomePhabricator

TypeError: undefined is not a function (evaluating 'performance.mark('mwLoadEnd')')
Closed, ResolvedPublic

Description

When using Safari, often when logged-in and loading the edit page (or viewing articles) this error shows up in the console.

TypeError: undefined is not a function (evaluating 'performance.mark('mwLoadEnd')')

It is more often triggered on the first page load after localStorage.clear();.

The oddest part is that when this error happens, even way after the page is loaded, manually checking the performance global, it still shows performance.mark as undefined. So it's not a race condition, it's permanently gone.

However it's defined in the startup module. There is no way it can't run. And there is no error for performance.mark('mwLoadStart');, only for performance.mark('mwLoadEnd');.

Event Timeline

Krinkle created this task.Sep 11 2015, 4:35 PM
Krinkle updated the task description. (Show Details)
Krinkle raised the priority of this task from to High.
Krinkle added subscribers: Krinkle, ori, TheDJ.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 11 2015, 4:35 PM
Krinkle updated the task description. (Show Details)Sep 11 2015, 4:37 PM
Krinkle set Security to None.
TheDJ reopened this task as Open.Sep 13 2015, 9:59 AM

I just encountered it again this morning 2 time.s

"[Error] TypeError: performance.mark is not a function. (In 'performance.mark('mwLoadEnd')', 'performance.mark' is undefined) – TypeError: performance.mark is not a function. (In 'performance.mark('mwLoadEnd')', 'performance.mark' is undefined)
log
handler
fire
fireWith
fire
track
handlePending
markModuleReady
(anonymous function)
fire
add
always
runScript
checkCssHandles
(anonymous function)
fire
fireWith
fire
fireCallbacks
addEmbeddedCSS
(anonymous function)

Krinkle moved this task from Inbox to Doing on the Performance-Team board.Sep 14 2015, 6:14 PM
Krinkle claimed this task.

Getting it myself at odd times. The stack trace looks the same but with added line numbers:

`[Error] TypeError: undefined is not a function (evaluating 'performance.mark('mwLoadEnd')') Error
log (load.php, line 177)
handler (load.php, line 155)
fire (load.php, line 45)
fireWith (load.php, line 46)
fire (load.php, line 46)
track (load.php, line 155)
handlePending (load.php, line 159)
markModuleReady (load.php, line 162)
(anonymous function) (load.php, line 162)
fire (load.php, line 45)
add (load.php, line 45)
always (load.php, line 46)
runScript (load.php, line 162)
checkCssHandles (load.php, line 163)
(anonymous function) (load.php, line 163)
fire (load.php, line 45)
fireWith (load.php, line 46)
fire (load.php, line 46)
fireCallbacks (load.php, line 158)
addEmbeddedCSS (load.php, line 158)
(anonymous function) (load.php, line 158)`

Gilles added a subscriber: Gilles.Sep 14 2015, 6:44 PM

From the meeting discussion, it seems like the safest approach is to wrap performance.mark in a function that checks the existence of the native function at call time. It might be worth reporting back with EL when it's missing, to check if there are more browsers than Safari displaying that suspect behavior of sometimes not having the property defined.

Krinkle added a comment.EditedSep 14 2015, 6:50 PM

I'm able to reproduce this in isolation on CodePen.io:

Entry point to actually test: http://codepen.io/Krinkle/debug/YywQJb

When opened in Chrome it works fine. Opened in Safari, sometimes all three checkpoints work. Sometimes only the first. Sometimes only the first two.



Properties randomly disappear, at random times.

Krinkle added a comment.EditedSep 14 2015, 10:09 PM

Upstream bug report confirms:
https://bugs.webkit.org/show_bug.cgi?id=137407

I made a recording of the upstream test case:

Change 238367 had a related patch set uploaded (by Krinkle):
resourceloader: Proxy 'window.performance' to support Safari bug

https://gerrit.wikimedia.org/r/238367

Change 238368 had a related patch set uploaded (by Krinkle):
resourceloader: Proxy 'window.performance' to support Safari bug

https://gerrit.wikimedia.org/r/238368

Change 238367 merged by jenkins-bot:
resourceloader: Proxy 'window.performance' to support Safari bug

https://gerrit.wikimedia.org/r/238367

Change 238368 merged by jenkins-bot:
resourceloader: Proxy 'window.performance' to support Safari bug

https://gerrit.wikimedia.org/r/238368

Krinkle closed this task as Resolved.Sep 15 2015, 2:18 AM