Open Bug 1750065 Opened 2 years ago Updated 6 months ago

Improve performance of getBrowserById with a map of UUID to browser element

Categories

(Remote Protocol :: Agent, defect, P2)

defect
Points:
3

Tracking

(Not tracked)

People

(Reporter: jdescottes, Unassigned, Mentored)

References

(Blocks 1 open bug)

Details

(Keywords: perf, Whiteboard: [webdriver:backlog][lang=js])

In Bug 1747222 we are introducing a getBrowserById method on remote/shared/TabManager.js which loops on all windows & tabs to see if any browser element matches the provided id.

Instead we could maintain a map from UUID to browser elements, but we therefore need to cleanup this map whenever a browser element is removed.

We will most likely have to keep track of all existing browser elements, similar to what is done in TargetObserver https://searchfox.org/mozilla-central/rev/ad732108b073742d7324f998c085f459674a6846/remote/cdp/observers/TargetObserver.sys.mjs, and everytime a browser element is removed, cleanup the appropriate entry in the map. Note that our UUIDs are bound to the permanentKey of <browser> elements. We will have to make sure there are no scenarios where the same permanent key might be reused for several browser elements, or we'll need to take this into account in our cleanup logic.

Severity: -- → S3
Points: --- → 8
Priority: -- → P3
Whiteboard: [webdriver:triage] → [bidi-m3-mvp]

We might have to fix bug 1691494 first to get parity between CDP and WebDriver even when we have to accept a performance regression.

Depends on: 1691494
Depends on: 1646289
No longer depends on: 1691494
Keywords: perf
Summary: Improve performance of getBrowserById with a map of UUID to browser el → Improve performance of getBrowserById with a map of UUID to browser element
See Also: → 1758996
Points: 8 → 3
Priority: P3 → P2
Whiteboard: [bidi-m3-mvp] → [webdriver:backlog]
Mentor: jdescottes
Whiteboard: [webdriver:backlog] → [webdriver:backlog][lang=js]

This can be a mentored bug, but not setting as good-first-bug as this will require to understand a bit how the browser handles browsing contexts. Hopefully we can rely on the current implementation in https://searchfox.org/mozilla-central/rev/ad732108b073742d7324f998c085f459674a6846/remote/cdp/observers/TargetObserver.sys.mjs as a starting point.

There is a BrowsingContext.getCurrentTopByBrowserId() helper available which actually let us find the current top-level browsing context based on the browser id. If we really have to use the browser element then we could get it via .embedderElement.

I'm not sure yet but with the work on bug 1274251 we might not necessarily need this anymore. Lets mark as dependency for now.

Depends on: 1274251

Let me actually fix that issue separately via this bug. I'll have a patch that is using the above method later today.

Assignee: nobody → hskupin
Blocks: 1274251
Mentor: jdescottes
Status: NEW → ASSIGNED
Points: 3 → 1
No longer depends on: 1274251
Priority: P2 → P1
Summary: Improve performance of getBrowserById with a map of UUID to browser element → Improve performance of getBrowserById by not having to iterate through all open tabs
Whiteboard: [webdriver:backlog][lang=js] → [webdriver:m9]

I was totally wrong here. The source id here is actually not the browserId but the unique navigable id. As such the proposed solution will not work.

Assignee: hskupin → nobody
No longer blocks: 1274251
Mentor: jdescottes
Status: ASSIGNED → NEW
Points: 1 → 3
Priority: P1 → P2
Summary: Improve performance of getBrowserById by not having to iterate through all open tabs → Improve performance of getBrowserById with a map of UUID to browser element
Whiteboard: [webdriver:m9] → [webdriver:backlog][lang=js]
You need to log in before you can comment on or make changes to this bug.