Revert "[Reland] webaudio: Always delete handlers in a non-nestable task on the main thread."

This reverts commit 02090026451f32dfc651f6dd2e384bf2c4f45b69.

Reason for revert: Causing crashes in canary.

Original change's description:
> [Reland] webaudio: Always delete handlers in a non-nestable task on the main thread.
> Deleting handlers does considerable non-trivial work that requires the
> graph lock. Allowing this to happen during finalization introduces
> considerable complexity because it can happen during any GC heap allocation,
> including ones that occur while the graph lock is already held.
> Instead, when the last reference is dropped, the handler is not deleted
> immediately, but a non-nestable task to delete it is enqueued. Since the
> task is non-nestable, it will not run while the graph lock is held by the
> main thread (and if it is held by another thread, it will block on it).
> This slightly extends the lifetime of audio handlers, during which time
> it is illegal to take a new reference (and RefCounted checks this in
> debug builds). So a flag is set in the destructor (though it could be
> sensibly set as early as the ref count reaches zero) that prevents the
> handler from adding itself to the tail processing queue if it is already
> being destroyed.
> The cycle collection layout test is updated to handle the fact that the
> handler count does not go to zero immediately on GC, but shortly thereafter.
> This has been done by merging with another recently added unit test, which
> tests something very similar (a cycle of one element).
> The leak detector has been augmented to wait for audio handlers that are
> awaiting deletion, if there are any.
> Bug: 884059
> Change-Id: I818bcdbf87dc3e83359ad7a62aa56547dea2d7a5
> Reviewed-on:
> Reviewed-by: Kentaro Hara <>
> Reviewed-by: Hongchan Choi <>
> Commit-Queue: Jeremy Roman <>
> Cr-Commit-Position: refs/heads/master@{#621840},,

Change-Id: Ib13b613f6fa696935f64362f65eb94cba50acdfd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 884059,921018
Commit-Queue: Jeremy Roman <>
Reviewed-by: Jeremy Roman <>
Cr-Commit-Position: refs/heads/master@{#622109}
14 files changed