Closed Bug 1762334 Opened 2 years ago Closed 2 years ago

Use EventsDispatcher to subscribe to all MessageHandler events in the root layer

Categories

(Remote Protocol :: Agent, task, P1)

task
Points:
2

Tracking

(firefox106 fixed)

RESOLVED FIXED
106 Branch
Tracking Status
firefox106 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

Details

(Whiteboard: [webdriver:m4])

Attachments

(2 files)

This is a follow up to the discussion at https://phabricator.services.mozilla.com/D141583?id=560866#inline-784526

The goal is to create a class that simplifies subscribing to events, potentially from multiple consumers, ensuring we only add and remove the actual platform listeners when needed.

This is challenging because events can follow different subscription logic and can originate from different processes.

We have two types of events in the MessageHandler framework: protocol events and internal events. Protocol events should follow the specs for the session.subscribe command, which means they don't really behave like a add/removeEventListener API. Whereas for internal events, we usually want a typical add/remoteEventListener behavior.

Those events can come from the parent process (eg browsingContext.contextCreated) or from content processes (eg browsingContext.domContentLoaded). When the events come from the content process, we usually have to set them up using SessionData. However for parent process events, they can bypass SessionData (that's the case for contextCreated right now).

And finally, those events usually rely on listener classes which provide a consistent API (start/stop/on/off) right on top of platform events. The listener class therefore lives right next to where the event is created. But we can have a single listener responsible for emitting several events. Typically browsingContext.contextDestroyed could be handled by the same listener class as browsingContext.contextCreated. In that case, calling start or stop depends on how the consumer wants to listen to 2 different events.

It's not clear if this should only be addressed with a single "helper", and I think we should also discuss:

  • which data should be in session data
  • should we allow to count references for some session data
  • should listener classes accept optional arguments to start/stop to do lightweight ref counting

This could be helpful to get sorted out before handling Bug 1694390

Priority: -- → P3
See Also: → 1694390
Whiteboard: [bidi-m3-mvp]
Blocks: 1694390
Points: --- → 2
Priority: P3 → P2
See Also: 1694390
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED

Moving back to the backlog

Status: ASSIGNED → NEW
Priority: P2 → P3
Priority: P3 → P2
Whiteboard: [bidi-m3-mvp] → [webdriver:backlog]
Assignee: jdescottes → nobody
Depends on: 1783177

Based on the current work in Bug 1783177, updating the summary.

We no longer distringuish internal and protocol events. However, not all the consumers of events in the root module are using the EventsDispatcher yet. In particular, the session module is directly listening to message handler events (this.#messageHandler.on) after Bug 1783177.

It should use the EventsDispatcher instead.

Summary: Add helper to subscribe to message handler events & internal events → Use EventsDispatcher to subscribe to all MessageHandler events in the root layer

Depends on D155061

All events now only react to SessionData and the session module can directly add/remove session data instead of using internal commands.
In the next patch, it will start relying on EventsDispatcher directly.

Assignee: nobody → jdescottes
Status: NEW → ASSIGNED

Depends on 1762334

Some additional corrections had to be made on the EventsDispatcher module at the same time.

Attachment #9290860 - Attachment description: Bug 1783177 - [messagehandler] Use EventsDispatcher in session module → Bug 1762334 - [messagehandler] Use EventsDispatcher in session module
Priority: P2 → P1
Whiteboard: [webdriver:backlog] → [webdriver:m4]
Pushed by jdescottes@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/025507e99cbf
[messagehandler] Remove _subscribe/_unsubscribeEvent commands in favor of SessionData r=webdriver-reviewers,whimboo
https://hg.mozilla.org/integration/autoland/rev/eb78ce4eb12a
[messagehandler] Use EventsDispatcher in session module r=webdriver-reviewers,whimboo
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: