Closed Bug 1596756 Opened 5 years ago Closed 5 years ago

Support FinalizationGroup objects in the browser

Categories

(Core :: JavaScript Engine, task, P1)

task

Tracking

()

RESOLVED FIXED
mozilla74
Tracking Status
firefox74 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

Following on from bug 1587096, add browser support for FinalizationGroup object.s

Add browser support for FinalizationGroup by setting the HostCleanupFinalizationGroupCallback in CycleCollectedJSContext. The callback adds groups pending cleanup to a vector stored in a PersistentRooted. A runnable is dispatched to call back into the JS engine and perform cleanup at a later time as a separate task. Using AutoEntryScript reports errors to the console.

I've tested this manually with test262 tests, which are currently not enabled in CI for this feature.

These are mochitests because there's currently no way to trigger a GC from WPT. I tried to do this with xpcshell tests but I couldn't get the pref to enable weak refs to work.

Depends on D53248

Attachment #9109109 - Attachment description: Bug 1596756 - Support FinalizationGroup objects in the browser r?mccr8 → Bug 1596756 - Support FinalizationGroup objects in the browser r=mccr8
Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/dbd7b3de1ce6 Support FinalizationGroup objects in the browser r=mccr8 https://hg.mozilla.org/integration/autoland/rev/37d24b36ce31 Add browser tests for FinalizationGroup r=mccr8

Backed out 4 changesets (Bug 1596756, Bug 1593698, Bug 1608069) for causing mochitest leakchecks.

Push with failure: https://treeherder.mozilla.org/#/jobs?repo=autoland&group_state=expanded&resultStatus=testfailed%2Cbusted%2Cexception&classifiedState=unclassified&revision=37d24b36ce318b86179bae59b11a487da555e7be

Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=284440348&repo=autoland&lineNumber=3619

Backout link: https://treeherder.mozilla.org/#/jobs?repo=autoland&group_state=expanded&selectedJob=284440348&resultStatus=testfailed%2Cbusted%2Cexception&classifiedState=unclassified&revision=166a6d535af3b4122cb9f8648d4a76e8e87b9608

[task 2020-01-10T19:06:19.706Z] 19:06:19     INFO - TEST-PASS | leakcheck | tab no leaks detected!
[task 2020-01-10T19:06:19.706Z] 19:06:19     INFO - leakcheck | Processing leak log file /tmp/tmpqrzFWB.mozrunner/runtests_leaks_tab_pid1656.log
[task 2020-01-10T19:06:19.707Z] 19:06:19     INFO - 
[task 2020-01-10T19:06:19.707Z] 19:06:19     INFO - == BloatView: ALL (cumulative) LEAK AND BLOAT STATISTICS, tab process 1656
[task 2020-01-10T19:06:19.708Z] 19:06:19     INFO - 
[task 2020-01-10T19:06:19.708Z] 19:06:19     INFO -      |<----------------Class--------------->|<-----Bytes------>|<----Objects---->|
[task 2020-01-10T19:06:19.709Z] 19:06:19     INFO -      |                                      | Per-Inst   Leaked|   Total      Rem|
[task 2020-01-10T19:06:19.709Z] 19:06:19     INFO -    0 |TOTAL                                 |       34       16| 4438547        1|
[task 2020-01-10T19:06:19.710Z] 19:06:19     INFO -  305 |JS Object                             |       16       16|       1        1|
[task 2020-01-10T19:06:19.712Z] 19:06:19     INFO - 
[task 2020-01-10T19:06:19.713Z] 19:06:19     INFO - nsTraceRefcnt::DumpStatistics: 1264 entries
[task 2020-01-10T19:06:19.713Z] 19:06:19     INFO - TEST-INFO | leakcheck | tab leaked 1 JS Object
[task 2020-01-10T19:06:19.713Z] 19:06:19     INFO - TEST-UNEXPECTED-FAIL | leakcheck | tab 16 bytes leaked (JS Object)
[task 2020-01-10T19:06:19.713Z] 19:06:19     INFO - 
[task 2020-01-10T19:06:19.713Z] 19:06:19     INFO - runtests.py | Running tests: end.
[task 2020-01-10T19:06:19.735Z] 19:06:19     INFO - Buffered messages finished
[task 2020-01-10T19:06:19.735Z] 19:06:19     INFO - Running manifest: layout/base/tests/mochitest.ini
[task 2020-01-10T19:06:19.736Z] 19:06:19     INFO - The following extra prefs will be set:
[task 2020-01-10T19:06:19.736Z] 19:06:19     INFO -   plugin.load_flash_only=false
[task 2020-01-10T19:06:19.756Z] 19:06:19     INFO -  Setting pipeline to PAUSED ...
[task 2020-01-10T19:06:19.757Z] 19:06:19     INFO -  Pipeline is PREROLLING ...
[task 2020-01-10T19:06:19.757Z] 19:06:19     INFO -  Pipeline is PREROLLED ...
[task 2020-01-10T19:06:19.757Z] 19:06:19     INFO -  Setting pipeline to PLAYING ...
[task 2020-01-10T19:06:19.757Z] 19:06:19     INFO -  New clock: GstSystemClock
[task 2020-01-10T19:06:19.793Z] 19:06:19     INFO -  Got EOS from element "pipeline0".
[task 2020-01-10T19:06:19.793Z] 19:06:19     INFO -  Execution ended after 33393731 ns.
[task 2020-01-10T19:06:19.793Z] 19:06:19     INFO -  Setting pipeline to PAUSED ...
[task 2020-01-10T19:06:19.793Z] 19:06:19     INFO -  Setting pipeline to READY ...
[task 2020-01-10T19:06:19.793Z] 19:06:19     INFO -  Setting pipeline to NULL ...
[task 2020-01-10T19:06:19.793Z] 19:06:19     INFO -  Freeing pipeline ...
[task 2020-01-10T19:06:20.101Z] 19:06:20     INFO -  pk12util: PKCS12 IMPORT SUCCESSFUL
Flags: needinfo?(jcoppeard)

It doesn't make sense to queue callbacks at this point because they will never run, and without this we get leaks at shutdown. I also refactored GCRuntime::sweepFinalizationGroups a little.

Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cad0b62c6074 Don't queue finalization groups for cleanup during shutdown r=sfink https://hg.mozilla.org/integration/autoland/rev/9db35ebe3759 Support FinalizationGroup objects in the browser r=mccr8 https://hg.mozilla.org/integration/autoland/rev/c71d1ca78e2d Add browser tests for FinalizationGroup r=mccr8
Flags: needinfo?(jcoppeard)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: