Open
Bug 1451381
Opened 6 years ago
Updated 2 years ago
Worker event listeners can leak owning window
Categories
(Core :: DOM: Workers, enhancement, P2)
Core
DOM: Workers
Tracking
()
NEW
People
(Reporter: bkelly, Unassigned)
References
(Blocks 1 open bug)
Details
(Whiteboard: [MemShrink:P2], DWS_NEXT)
Attachments
(2 files)
2.37 KB,
patch
|
Details | Diff | Splinter Review | |
1.65 KB,
patch
|
bkelly
:
review+
|
Details | Diff | Splinter Review |
In bug 1450358 I am adding some new runtime leak checking. The Worker API appears to fail this test.
Reporter | ||
Comment 1•6 years ago
|
||
This test needs the infrastructure patches from bug 1450358 to work. Currently the Worker API fails all three leak cases. Andrea, can you take a look at what is going on?
Flags: needinfo?(amarchesini)
Reporter | ||
Updated•6 years ago
|
Whiteboard: [MemShrink]
Updated•6 years ago
|
Whiteboard: [MemShrink] → [MemShrink:P1]
Reporter | ||
Updated•6 years ago
|
Blocks: event-target-leaks
Reporter | ||
Comment 2•6 years ago
|
||
I tried writing a simple DisconnectFromOwner() that did Terminate(), but that doesn't fix the leak here.
Comment 3•6 years ago
|
||
Here a patch but I don't think we should land the test because it will be probably intermittent: the releasing of the window happens when the worker ends its shutdown steps. This could take more than a couple of ForceGC() calls.
Assignee: nobody → amarchesini
Flags: needinfo?(amarchesini)
Attachment #8969341 -
Flags: review?(bkelly)
Updated•6 years ago
|
Priority: -- → P2
Reporter | ||
Comment 4•6 years ago
|
||
Comment on attachment 8969341 [details] [diff] [review] patch Review of attachment 8969341 [details] [diff] [review]: ----------------------------------------------------------------- Shouldn't we call Terminate() from DisconnectFromOwner()? Otherwise the worker thread will run between the window being closed and CC running. Also, if you don't like the test using event_leak_utils.js, can you write another test like it that waits for the worker to shutdown?
Attachment #8969341 -
Flags: review?(bkelly) → review+
Reporter | ||
Comment 5•6 years ago
|
||
(In reply to Ben Kelly [:bkelly] from comment #4) > Also, if you don't like the test using event_leak_utils.js, can you write > another test like it that waits for the worker to shutdown? For example, you could have a test where the worker spins periodically calling BroadcastChannel.postmessage(). Then the test could listen for when the broadcast messages stop before triggering GC.
Comment 6•6 years ago
|
||
Ok... this is going to be interesting: the current worker code doesn't ends the event-loop when all the 'blocking' holders are released, but when _all_ the holders are released. The difference between blocking and non-blocking holders is only related to the busy-count value and when the worker is GCed/CCed. My patch fixes this but, it introduces an important issue with MozPromise. Take a look at: https://searchfox.org/mozilla-central/source/xpcom/threads/MozPromise.h#461-466 Here, there is not a check of the return value of ::Dispatch(). But we should have a check, because, MozPromise doesn't use any WorkerHolder internally and the worker could be already shutting down when ::Dispatch() is called. The issue is easily reproducible with DOM Cache + workers, because DOM Cache is the only API using MozPromise exposed to workers (for now). I'm still debugging this issue. I'll propose a solution soon.
Reporter | ||
Comment 7•6 years ago
|
||
As we discussed in IRC, the patches in bug 1456466 may help. Specifically P5, P6, and P8.
Reporter | ||
Comment 8•6 years ago
|
||
Andrea, now that bug 1457157 is fixed, can this move forward?
Flags: needinfo?(amarchesini)
Comment 9•6 years ago
|
||
Yes. I did some tests today. The leak is gone, but not immediately how the test wants. I'll rewrite it tomorrow using a ping/pong with BroadcastChannel or... with a timer.
Flags: needinfo?(amarchesini)
Comment 10•6 years ago
|
||
Hey Andrea, what else has to happen for this bug to land?
Flags: needinfo?(amarchesini)
Comment 11•6 years ago
|
||
Pushed to try to see the state of these 2 patches. Keeping the NI.
Updated•6 years ago
|
Flags: needinfo?(amarchesini)
Comment 12•6 years ago
|
||
Andrew, do you know who can pick this back up again?
Flags: needinfo?(bugmail)
Comment 13•6 years ago
|
||
Putting this in the DWS_NEXT queue to be picked up.
Assignee: amarchesini → nobody
Flags: needinfo?(bugmail)
Whiteboard: [MemShrink:P1] → [MemShrink:P1], DWS_NEXT
Comment 14•5 years ago
|
||
Is DWS_NEXT still a thing?
Flags: needinfo?(bugmail)
Whiteboard: [MemShrink:P1], DWS_NEXT → [MemShrink:P2], DWS_NEXT
Comment 15•5 years ago
|
||
Yes, although this bug also benefits from being a P2.
Note for when we pick this up:
- Bug 1522246 potentially fixed the delay comment 9 was talking about.
- I could swear I saw some bug traffic go by recently about edge-cases relating to what/when DOMEventTargetHelper tries to help us drop things.
Flags: needinfo?(bugmail)
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•