Closed Bug 2022378 Opened 15 days ago Closed 14 days ago

Messages queued during port entaglement are never sent if main thread blocks

Categories

(Core :: DOM: postMessage, defect, P2)

defect

Tracking

()

RESOLVED FIXED
150 Branch
Tracking Status
firefox150 --- fixed

People

(Reporter: bholley, Assigned: bholley)

References

Details

Attachments

(1 file)

See bug 1752287 comment 33. Patch forthcoming.

When a MessagePort is transferred to a worker, it enters eStateEntangling
while waiting for an async IPC round-trip (PMessagePortConstructor ->
RequestEntangling -> Entangled) to complete. Previously, PostMessage()
during this state queued messages in mMessagesForTheOtherPort, which were
only flushed when the Entangled() callback fired. If the worker blocked
the thread (e.g. via Atomics.wait() or sync XHR) before that callback
arrived, the queued messages were never sent.

Conceptually, it's safer to buffer pre-entanglement in the parent
PBackground thread, which never blocks. By the time we're in
eStateEntangling, the parent should be guaranteed to be set up enough to
receive the message.

On the parent side, RecvPostMessages() now buffers messages received before
Entangled() is called (in mPendingMessages), rather than returning IPC_FAIL.
These buffered messages are flushed via PostMessages() when Entangled() is
called. This handles the multi-transfer edge case where a port's parent
actor is queued in mNextParents and hasn't become active yet.

Severity: -- → S3
Priority: -- → P2
Status: NEW → RESOLVED
Closed: 14 days ago
Resolution: --- → FIXED
Target Milestone: --- → 150 Branch
QA Whiteboard: [qa-triage-done-c151/b150]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: