Closed Bug 1832820 Opened 2 years ago Closed 2 years ago

Remove uniqueness constraint from nsAsyncShutdown

Categories

(Toolkit :: Async Tooling, task, P3)

task

Tracking

()

RESOLVED FIXED
115 Branch
Tracking Status
firefox115 --- fixed

People

(Reporter: pehrsons, Assigned: pehrsons)

References

(Blocks 7 open bugs)

Details

Attachments

(2 files)

We should remove the uniqueness constraint in the underlying
nsAsyncShutdownService instead.

nsAsyncShutdownService is a common way to handle async shutdown in C++. The
uniqueness constraint on the name of the blocker is however an ergonomy problem.
Several classes will append a pointer, or even generate a random id, to satisfy
the uniqueness constraint and allow registering multiple blockers of the same
type.

This patch removes the uniqueness constraint, and changes from registering
blockers in a Map to a WeakMap as it seems to be in line with the original
author's intention, and is now possible.

Some test coverage of this exists through media::ShutdownBlockingTicket, see
https://phabricator.services.mozilla.com/D177616.

(In reply to Andreas Pehrson [:pehrsons] from comment #0)

This case is interesting because the author has included two kinds of information in the name:

  1. The userInteractionTimerId is there for uniqueness, and is unlikely to be useful for any kind of debugging.
  2. The aDocument is added even though the userInteractionTimerId is sufficient for uniqueness, presumably because this pointer may be useful to match against other pointers in debugging.

So while the uniqueness requirement is unnecessary and causes extra pain in implementing an nsIAsyncShutdownBlocker, some of the pointers in blocker names could be useful for debugging, so we don't want to remove them all.

I'd agree that nsIAsyncShutdownBlocker need not impose uniqueness, just as AsyncShutdown does not. The client can choose what information is readily available and useful for debugging.

Attachment #9333610 - Attachment description: Bug 1832820 - Don't require unique names for blockers added through nsAsyncShutdownService. r?mak!, r?mccr8! → Bug 1832820 - Don't require unique names for blockers added through nsAsyncShutdownService. r?mak!, r?mccr8
Pushed by pehrsons@gmail.com: https://hg.mozilla.org/integration/autoland/rev/dc94b7583a39 In media::ShutdownBlocker don't make the name unique. r=karlt https://hg.mozilla.org/integration/autoland/rev/5580f52f3e0b Don't require unique names for blockers added through nsAsyncShutdownService. r=mak
Blocks: 1834750
Blocks: 1834751
Blocks: 1834753
Blocks: 1834754
Blocks: 1834755
Blocks: 1834756
Blocks: 1834759
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 115 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: