Window object leak on cnn.com |
|||
Issue descriptionThis issue was reported internally by wez@. Steps to reproduce: 1. Open http://edition.cnn.com 2. Decrease the window size to ~200px. 3. Maximize the window. Repeat steps 2, 3 and observe increase in memory usage. The number of window objects also increases with every window resize (this can be checked by taking a heap snapshot in DevTools and looking up "Window /" object count). The leak of window object is caused either by a bug in JS code of the webpage or by a bug in Chrome.
,
Jul 5 2017
,
Jul 6 2017
TL;DR: the leak is caused by moatad.js script that adds (and never removes) event listeners that retain iframe window objects.
The event type is "webdriver-evaluate", "webdriver-evaluate-response", which explains why the listeners never fire in Chrome.
Details follow.
I instrumented V8 GC to print retaining paths for all window objects during marking.
Here is what a typical retaining path looks like
1. A leaking window object
2. which is stored in field "target" of a JS object with fields {evt, target}
3. which is stored in field "ME-271255637387" of a JS object with properties {ME-271255637387, ME-678715737272, globalMouseDown1eb9-1156-106c-124d, ...}
4. which is stored in field "xscd" of a JS object with properties {sxdc, cdxs, xscd, swde}
5. which is stored in a single element JS array
6. which is a context allocated variable of a JS function with source code "(){c.apply(d||null,b.concat(b.slice.call(arguments)))}"
8. which is a context allocated variable of a JS function with source code "(c){return b(c)}"
10. which is stored in a JS array of listeners.
11. which is stored in an internal field of the main window object.
Searching the JS source code for these field names, I found that moatad.js creates listeners that captures the leaking window objects.
A breakpoint in moatad.js showed that it is adding two listeners for events "webdriver-evaluate", "webdriver-evaluate-response" for document on every window resize (screenshot attached).
I instrumented EventListenerMap::Add in Blink and confirmed that the size of the listener vector corresponding to the webdriver events is growing after every window resize.
This proves wez@'s theory in comment #1 that the leak is caused by listeners.
|
|||
►
Sign in to add a comment |
|||
Comment 1 by w...@chromium.org
, Jul 5 2017