Open Bug 822011 Opened 12 years ago Updated 2 years ago

Discard decoded images passed to WebGL tex[Sub]Image2D

Categories

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

enhancement

Tracking

()

People

(Reporter: bjacob, Unassigned)

References

Details

(Whiteboard: webgl-next [MemShrink:P2])

Attachments

(1 file)

See bug 820217 comment 27 for context.

A typical scenario is:
 - take a 256M device
 - load a game that was designed for higher-spec devices
 - OOM
 - most of the game's memory usage is textures
 - at the time of the OOM, the images are stored twice in memory: once as decoded image data and once as WebGL textures.

We could ease that by immediately discarding decoded image data as soon as it's been uploaded as WebGL textures. It should be very uncommon to continue using the decoded image data in any way after uploading to a WebGL texture.

That could considerably push back the limit of how big games we can hope to run on 256 M phones. If the game uploads the images as 16 bpp RGBA textures, the decoded image data is twice bigger (BGRA8) so we could divide memory usage by 3 in this case. If the game uploads as 32bpp textures, we could still divided memory usage by 2.
The updated game link in bug 820217 seems like a prime example of what this could be useful for. It requires 51 M of WebGL texture memory, which should run on B2G hardware but currently runs out of memory.
Blocks: 820217
We've gotten into /so/ much trouble with various "immediate discard" heuristics in imagelib that I think anything we do here should have a backoff so we can't get into a loop where we continuously discard/re-decode an image.
Whiteboard: webgl-next [MemShrink] → webgl-next [MemShrink:P2]
Genrally, I think the app author should have to clean up those resource as they do for native applicatoins. This is a common upload-and-release pattern to avoid image data remain in main memory but do not use them anymore, or even forget to delete them at leave.
Since I am not that familiar with Javvascript manipulation about image objecct, I just found:
http://stackoverflow.com/questions/7488866/unloading-resources-on-html-with-javascript
Type: defect → enhancement
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: