Closed Bug 1755725 Opened 2 years ago Closed 2 years ago

WeakRefs don't work with cross-zone targets

Categories

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

defect

Tracking

()

RESOLVED FIXED
99 Branch
Tracking Status
firefox99 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

Details

Attachments

(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: 1756567
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 jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/59ae32a4a0a3
Part 1: Factor out crossZoneWrappers checks and do them before we calculate sweep groups r=sfink
https://hg.mozilla.org/integration/autoland/rev/8e7816b5ea2a
Part 2: Refactor FinalizationObservers in preparation to add a weak set for weak refs r=sfink
https://hg.mozilla.org/integration/autoland/rev/eac621ee0ea8
Part 3: Add cross-zone WeakRef wrappers to a weak set to keep them alive r=sfink
https://hg.mozilla.org/integration/autoland/rev/2f4c3dcd4a8d
Part 4: Add WeakRef tests where the weak ref and its target are in different zones r=sfink
Regressions: 1757573
Depends on: 1770266
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: