Closed Bug 1919633 Opened 5 months ago Closed 5 months ago

JS actors in dead ContentParents can receive messages after their protocol is unregistered

Categories

(Core :: DOM: Content Processes, defect)

defect

Tracking

()

RESOLVED FIXED
132 Branch
Tracking Status
firefox132 --- fixed

People

(Reporter: mccr8, Assigned: mccr8)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

While I don't think this happens in regular browser usage, tests can unregister protocols.

One of these is browser_html_warning_messages.js, which has a subtest testUnsignedDisabled that disables SpecialPowers, which ends up running this onShutdown method that unregisters both the SpecialPowers and AppTestDelegate actors.

As part of bug 1885221 (typing JS window actor messages) I have added a special type testOnly. If a message is testOnly, we don't check the message, but instead check that the actor's current module URI matches an allow list of testing URIs. Anyways, when running the part of browser_html_warning_messages.js I mentioned above, this checking intermittently fails for the load message of the actor AppTestDelegate with the error (from my type checking patch): "couldn't get module URI for an actor with a testOnly type: no actor protocol found". This means we're inside JSActorManager::ReceiveRawMessage, and the GetActor call has succeeded, but our protocol is not actually currently registered, which seems bad.

I debugged it a bit and it looks like we never call JSActorManager::JSActorUnregister on the actor manager that has the relevant instance of AppTestDelegate. In the occasional instance where we don't hit the type error, it looks like JSActorDidDestroy runs before JSActorManager::ReceiveRawMessage, so we avoid getting the message that way.

With some further debugging, it appears that we skip over this actor manager here in JSActorService::UnregisterWindowActor because the relevant ContentParent is dead. It seems to fix the problem if we iterate over all ContentParents and not just live ones, and simply skip the SendUnregisterJSWindowActor call if the ContentParent is not alive, but maybe there's some bigger problem here and we should check that our ContentParent is alive in JSActorManager::ReceiveRawMessage? That being said, I added logging in WindowGlobalParent::RecvRawMessage for when the ContentParent is not alive, and it is happening quite a bit so maybe we can't do that easily.

It looks like UnregisterProcessActor has the same issue as UnregisterWindowActor.

Nika, any ideas? Thanks.

Flags: needinfo?(nika)
Assignee: nobody → continuation

I think it's normal for a JSActor to potentially receive messages from "dead" ContentParent objects, because being "dead" actually just means that the process is in the process of dying, and can no longer be re-used (yes, it's an unfortunate naming). The process when being marked dead doesn't even necessarily have to have been sent a shutdown message yet - it might not be sent until a tab which is in the process of closing finishes exiting.

Flags: needinfo?(nika)
Pushed by amccreight@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3227b078a10c Unregister JS actors even if the ContentParent is not alive. r=nika
Status: NEW → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 132 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: