Open Bug 1424374 Opened 7 years ago Updated 2 years ago

DOM Cache API should consider using PromiseWindowProxy and weak-refs

Categories

(Core :: Storage: Cache API, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: bkelly, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [MemShrink:P2])

Currently the DOM Cache API is holding strong refs to the promise, parent object, and global for every operation it performs: https://searchfox.org/mozilla-central/source/dom/cache/CacheOpChild.h#75 We should investigate if we can make these weak and use the new PromiseWindowProxy.
Andrew, I was thinking about this a bit more and I actually started to think maybe every API that returns a Promise backed by some internal native operation should use PromiseWindowProxy. If thats the case, though, maybe we should make Promise do that automatically? For example, if we created a separate internal PromisePrivate structure then the Promise itself could have the weak reference to it and the window. Fixing this in Promise itself would avoid having to roto-till a bunch of code through the tree and complicating the API. What do you think?
Flags: needinfo?(continuation)
(In reply to Ben Kelly [:bkelly] from comment #1) > Fixing this in Promise itself would avoid having to roto-till a bunch of > code through the tree and complicating the API. What do you think? That sounds reasonable. I don't know how Promises are used.
Flags: needinfo?(continuation)
I think nearly every DOM returned Promise is held alive by some system activity. We rely on these being resolved at some point or at window close. As we learned with the SW job queue that can fail. So I think fixing this in the Promise class itself would be worth it.
Priority: -- → P3
Whiteboard: [MemShrink] → [MemShrink:P2]
Component: DOM → DOM: Core & HTML
Component: DOM: Core & HTML → Storage: Cache API
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.