Closed Bug 1722659 Opened 3 years ago Closed 3 years ago

Stop using singleton for MessageHandlerRegistry

Categories

(Remote Protocol :: WebDriver BiDi, task, P2)

task
Points:
2

Tracking

(firefox94 fixed)

RESOLVED FIXED
94 Branch
Tracking Status
firefox94 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

(Blocks 1 open bug)

Details

(Whiteboard: [bidi-m2-mvp])

Attachments

(1 file)

In the initial implementation for MessageHandler, we have a single MessageHandlerRegistry per process, and consumers can use it in order to retrieve a MessageHandler instance.

In a given process, you can have MessageHandlers for various context types (Root, WindowGlobal, Worker...), for various contexts (browsing context 1, browsing context 2, ...) and finally for various sessions.

The platform APIs we are using to cross process/thread boundaries should remain tied by nature to a given context & context id. For instance, a MessageHandlerFrame JSWindowActor pair is tied to a specific BrowsingContext and is only dealing with WindowGlobalMessageHandlers. Also all MessageHandlers related to this JSWindowActor pair cannot outlive the JSWindowActor. For this reason, it doesn't really help to have a single registry which knows about all MessageHandler for all the contexts.

Instead, the proposal is to instantiate MessageHandlerRegistry for each context and make the Registry only care about sessions. For instance for WindowGlobalMessageHandlers, a MessageHandlerFrameChild will own a MessageHandlerRegistry and will use it to resolve the MessageHandler corresponding to a specific session. In the parent process, Root MessageHandlers should still be owned by a "singleton". This could either be a new dedicated singleton, or we could reuse RemoteAgent.

This will avoid having to craft complex MessageHandler keys combining the type + contextId + sessionId information, and should also simplify the ownership model for MessageHandlers. For instance when the MessageHandlerFrameChild is destroyed, it can simply destroy its Registry, which will in turn destroy all the MessageHandlers.

Thanks for filing this bug Julian. Maybe you could have an updated drawing of how this would look like when we discuss this topic in the next triage meeting?

Priority: -- → P3
Whiteboard: [webdriver:triage] → [bidi-m1-mvp]
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Whiteboard: [bidi-m1-mvp] → [bidi-m2-mvp]
Priority: P3 → --
Points: --- → 2
Priority: -- → P2
Pushed by jdescottes@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5a0a47013cb0 [remote] Stop using singleton for MessageHandlerRegistry r=webdriver-reviewers,whimboo
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 94 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: