Open Bug 813540 Opened 12 years ago Updated 2 years ago

Add 'critical memory event' in addition to current 'memory pressure event's

Categories

(Core :: Graphics: CanvasWebGL, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: jgilbert, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [games:p?])

Currently, in response to memory pressure events, we drop all WebGLContexts with context-lost. What we should consider is doing a first round of memory freeing in response to memory pressure events, where we drop all caches and all non-required memory buffers. That is, we should do a pass where we try to benignly free up memory before doing a second 'critical memory event' pass where we break anything.

Concept:
Memory pressure event:
Drop cached memory
JS content memory pressure event? (bug 813530)
GC/CC
Lose old/unused WebGL contexts? [1]

Critical memory pressure event:
Lose WebGL contexts


This could allow us to reduce memory usage without always killing the WebGLContext. This could allow webgl content to continue running, with only a hiccup while we tear down caches and GC. If we still haven't freed enough[2] after the low memory event, we could trigger a critical memory event and axe webgl contexts. (Restoring GL data can be very expensive for an app, even when implemented properly)

[1] If a webgl context hasn't been used in the last, say, 10m, we might want to consider these 'expendable' for the purposes of freeing memory.
[2] This is probably the big questionmark here. Maybe we could check our memory usage before and after the low-memory event, and only trigger critical-memory if we don't manage to free much. (Perhaps as a percent of total usage?)
OS: Linux → All
Hardware: x86_64 → All
Flagging this as p2; it's a good idea to be more fine-grained for memory, though it mainly matters for mobile.  There we have other work to do to get to significant viability before this becomes an issue.

I do like losing old/unused WebGL contexts first though; unused + in inactive tabs could be good.
Whiteboard: [games:p?] → [games:p2]
Blocks: gecko-games
Whiteboard: [games:p2] → [games:p?]
Type: defect → enhancement
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.