Closed Bug 1499908 Opened 6 years ago Closed 6 years ago

Standalone texture cache entries for rasterized blobs persist indefinitely

Categories

(Core :: Graphics: WebRender, defect, P2)

defect

Tracking

()

VERIFIED FIXED
mozilla65
Tracking Status
firefox-esr60 --- unaffected
firefox63 --- disabled
firefox64 --- verified
firefox65 --- verified

People

(Reporter: bholley, Assigned: bholley)

References

Details

(Keywords: memory-leak)

Attachments

(4 files)

STR:
(1) Enable gfx.webrender.debug.texture-cache
(2) Visit https://fivethirtyeight.com/politics/
(3) Scroll down past the various SVG charts on the right
(4) You should see the various charts appear as standalone textures
(5) Close the tab, continue browsing. The textures remain indefinitely.

Glenn thinks this is because of the manual eviction policy [1] for rasterized blobs, which presumably isn't working correctly.

[1] https://searchfox.org/mozilla-central/rev/eef79962ba73f7759fd74da658f6e5ceae0fc730/gfx/webrender/src/resource_cache.rs#1574
In theory all images and their texture cache entries should get evicted when you close the tab if not that's worrying, it would suggest that the image key isn't removed upon closing the tab.

Some background about the manual eviction policy: the initial problem is that blobs are rasterized asynchronously during scene building so what could happen is:

 - a blob entry is in the cache
 - an update arrives that repaints half of the blob
 - asynchronously we start painting that half-blob
 - scrolling happens and the entry gets evicted from the cache
 - rasterization completes,
 - the render backend receives half of the blob's rasterized image and doesn't have an entry to update anymore.

We could allow evicting a blob image's texture cache entry if it isn't referenced anymore by the display list (so you'd need to scroll way past it but it could still be evicted).
But first we need to figure out if/why the image key isn't deleted when we close the tab.
Ok, NI nical to have a look at this next week. High priority since it's a potential leak on beta. Let me know if you can't repro.
Flags: needinfo?(nical.bugzilla)
Assignee: nobody → nical.bugzilla
Flags: needinfo?(nical.bugzilla)
So far I haven't been able to reproduce the same issue. I can observe two scenarios:

# If the page isn't zoomed (not a hidpi screen)

- Blobs all go into shared entries.
- We don't collect shared entries very often (from a look of the code we seem to collect them when running out of space in the shared cache), after scrolling the provided link I scrolled wikipedia's front page for ~30 seconds and expire_old_shared_entries was never called.

# If I zoom enough for the graphs to be standalone entries (probably better matches Bobby's configuration).

- the standalone entries get evicted quite aggressively (they seem to get evicted more or less as soon as they are off-screen).


Either way, if I go to about:memory and minimize the memory usage, everything gets purged out of the cache.


It wouldn't hurt to evict shared entries a bit more aggressively. If anything, evicting entries that were marked as unused when their image key was deleted would probably help newer allocation fill space at the beginning of the storage and make it easier  to shrink back after an allocation spike.
Assignee: nical.bugzilla → bobbyholley
Priority: -- → P2
Dzmitry asked for this during review on another bug - submitting it as
a ridealong with this one.

Depends on D9953
Oh, and for the record: This can be reproduced more reliably by visiting [1], scrolling down past the ex-president graphs, and closing the tab.

[1] https://projects.fivethirtyeight.com/trump-approval-ratings/?ex_cid=rrpromo
Depends on: 1502342
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Comment on attachment 9020455 [details]
Bug 1499908 - Don't bypass cleanup logic in clear_namespace().

[Beta/Release Uplift Approval Request]

Feature/Bug causing the regression: None

User impact if declined: Potential leak for qualified beta WR users. No impact in release, since WR won't ride the 64 release train.

Is this code covered by automated tests?: No

Has the fix been verified in Nightly?: Yes

Needs manual test from QE?: No

If yes, steps to reproduce: 

List of other uplifts needed: None

Risk to taking this patch: Low

Why is the change risky/not risky? (and alternatives if risky): Relatively low risk. I suggest baking for a few days on nightly and then approving for beta if we haven't seen any regressions. Please ping kats to handle the uplift mechanics.

String changes made/needed:
Attachment #9020455 - Flags: approval-mozilla-beta?
Flags: qe-verify+
Keywords: memory-leak
Target Milestone: --- → mozilla65
Comment on attachment 9020455 [details]
Bug 1499908 - Don't bypass cleanup logic in clear_namespace().

[Triage Comment]
Fixes a possible WebRender leak for Beta users opted into the study. Approved for 64.0b6.
Attachment #9020455 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: