Closed Bug 1755725 Opened 6 months ago Closed 6 months ago

WeakRefs don't work with cross-zone targets


(Core :: JavaScript: GC, defect, P3)




99 Branch
Tracking Status
firefox99 --- fixed


(Reporter: jonco, Assigned: jonco)




(4 files)

When investigating optimising the way we implement the kept objects set used by WeakRefs, I noticed they didn't work at all when their target is in another zone. Doing this results in the WeakRef returning undfined from the deref() method after GC, even if the target is still alive.

I don't know how often these are used with cross-zone targets or how to arrange this in the browser but I assume it's possible.

Depends on: 1756568
Priority: -- → P3

This renames crossZoneWarppers to crossZoneRecordWrappers and makes
add/RemoveCrossZoneWarpper take the set as an argument.

Depends on D139835

This fixes weak ref behaviour with cross zone targets. Previously the wrapper
died because there was nothing to keep it alive and the weak ref target was
cleared, even if the target was still alive.

Depends on D139836

Pushed by
Part 1: Factor out crossZoneWrappers checks and do them before we calculate sweep groups r=sfink
Part 2: Refactor FinalizationObservers in preparation to add a weak set for weak refs r=sfink
Part 3: Add cross-zone WeakRef wrappers to a weak set to keep them alive r=sfink
Part 4: Add WeakRef tests where the weak ref and its target are in different zones r=sfink
Depends on: 1770266
You need to log in before you can comment on or make changes to this bug.