Open
Bug 2005554
Opened 8 months ago
Updated 7 months ago
flushQueuedInitialTasks can block the main thread and still miss additional tasks
Categories
(Data Platform and Tools :: Glean: SDK, defect, P1)
Data Platform and Tools
Glean: SDK
Tracking
(Not tracked)
NEW
People
(Reporter: janerik, Assigned: janerik)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
We currently use a dispatcher to delay certain metric/ping methods.
This is to avoid calling into libxul (where the glean-core functions are), as that itself might cause a libxul load. We don't want that load until Gecko itself does it (and Glean is initialized).
However the current implementation is buggy:
- While asked to queue things (
queueInitialTasks=true) we append tasks to a concurrent queue - On init we call
flushQueuedInitialTasks, which- locks the dispatcher
- copies tasks from the queue and clears it
- runs each task
- sets
flushQueuedInitialTasks=false
- Continues with work
Any task that tries to queue during step 2, just after the dispatcher is locked, gets blocked. When it unlocks it adds to the queue. The task stays there and is never executed.
This can lose tasks, while also blocking the calling thread trying to enqueue a task.
Visible in this profile: https://share.firefox.dev/4427Ekt
setEnabledis calledDelayedTaskQueue.launchis called- this causes an
art::Monitor::lock()call, which blocks.
| Assignee | ||
Updated•8 months ago
|
Comment 1•8 months ago
|
||
You need to log in
before you can comment on or make changes to this bug.
Description
•