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 raised the priority of this task from to High.
Krinkle updated the task description. (Show Details)
Krinkle added subscribers: Krinkle, ori, TheDJ.
Krinkle set Security to None.

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)

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)`

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.

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.

Screen Shot 2015-09-14 at 22.56.21.png (1×1 px, 149 KB)

Screen Shot 2015-09-14 at 22.56.35.png (1×1 px, 135 KB)

Screen Shot 2015-09-14 at 22.56.32.png (1×1 px, 145 KB)

Properties randomly disappear, at random times.

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

I made a recording of the upstream test case:

r26cn.gif (159×260 px, 557 KB)

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