Open Bug 1970541 Opened 7 months ago Updated 1 day ago

Precompute more drag-drop data structures on tab strip dragstart

Categories

(Firefox :: Tabbed Browser, task, P4)

task

Tracking

()

REOPENED

People

(Reporter: sthompson, Assigned: astor, Mentored, NeedInfo)

References

(Blocks 1 open bug)

Details

(Keywords: perf, Whiteboard: [fidefe-tabgrps])

Attachments

(2 files)

The drag-drop code in the <tabs> component:

  • stores movingTabs as an array of the moving tabs on the dragged tab's dragdata object on dragstart, but _animateTabMove will reverse that on every dragover if the locale is RTL
  • has several places where we slice the array of tab strip items, filter out moving tabs, or otherwise process the array every dragover

Technically, we're wasting CPU cycles by doing the same work over and over during a drag, although we don't actually have hard evidence from profiles that this is a performance issue.

The larger opportunity is to be more explicit about:

  1. what data is required to implement our drag-drop logic
  2. how we use that data

For example, on https://searchfox.org/mozilla-central/rev/3b58bde321bf705a91c32c7a6574a3427ce81d3f/browser/components/tabbrowser/content/tabs.js#2363 we have tabs = tabs.filter(t => !movingTabs.includes(t) || t == draggedTab);. The main purpose for this data structure is to calculate the element index in getOverlappedElement where the dragged items should be dropped for purposes of animating how the non-moving tabs shift out of the way. It's not intuitive that we should exclude moving tabs but still have the dragged tab in the case where we are dragging several tabs at once. On dragstart, we could build this array once, call it something like dropIndexSearchArray, save it on the dragged tab's dragdata object, and use it without modification during the entire drag operation. Similarly, we could precompute an array of unmovingTabStripItems instead of reusing the tabs array from before and skipping the draggedTab https://searchfox.org/mozilla-central/rev/3b58bde321bf705a91c32c7a6574a3427ce81d3f/browser/components/tabbrowser/content/tabs.js#2661-2664

Whiteboard: [fidefe-tabgrps]
Mentor: sthompson
Blocks: tab-groups
Keywords: perf

Moves data structure creation to the on_dragstart event

Assignee: nobody → gaastorgano
Status: NEW → ASSIGNED
Pushed by sthompson@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/bf027a10140b https://hg.mozilla.org/integration/autoland/rev/3894e0ec2ad7 Precompute unmovingTabStripItems and dropIndexSearchArray r=sthompson,tabbrowser-reviewers
Pushed by ctuns@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/4cef53c557c8 https://hg.mozilla.org/integration/autoland/rev/5d3dd040050b Revert "Bug 1970541 Precompute unmovingTabStripItems and dropIndexSearchArray r=sthompson,tabbrowser-reviewers" for causing bc failures in browser_move_unpinned_not_overflowing.js

Backed out for causing bc failures

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: TEST-UNEXPECTED-FAIL | browser/components/tabbrowser/test/browser/dragdrop/browser_move_unpinned_not_overflowing.js | Uncaught exception in test bound test_move_unpinned_horizontal_rtl - at chrome://global/content/customElements.js:676 - InternalError: too much recursion
Flags: needinfo?(gaastorgano)
Flags: needinfo?(gaastorgano)
Pushed by sthompson@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/ffb83bad2eef https://hg.mozilla.org/integration/autoland/rev/70b01d56b33c Precompute unmovingTabStripItems and dropIndexSearchArray r=sthompson,tabbrowser-reviewers
Pushed by agoloman@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/8537def8afc3 https://hg.mozilla.org/integration/autoland/rev/1020df6307c5 Revert "Bug 1970541 Precompute unmovingTabStripItems and dropIndexSearchArray r=sthompson,tabbrowser-reviewers" for causing failures @browser_multiselect_tabs_reorder.js.

Backed out for causing bc failures @browser_multiselect_tabs_reorder.js.

Flags: needinfo?(gaastorgano)

Authored by agoloman
https://github.com/mozilla-firefox/firefox/commit/28328852faef8df1ee41e277a56ec6855020cead
[main] Revert "Bug 1970541 Precompute unmovingTabStripItems and dropIndexSearchArray r=sthompson,tabbrowser-reviewers" for causing failures @browser_multiselect_tabs_reorder.js.

Status: ASSIGNED → RESOLVED
Closed: 1 day ago
Resolution: --- → FIXED
Pushed by smolnar@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/28328852faef https://hg.mozilla.org/mozilla-central/rev/b3e58208064e Revert "Bug 1970541 Precompute unmovingTabStripItems and dropIndexSearchArray r=sthompson,tabbrowser-reviewers" for causing failures @browser_multiselect_tabs_reorder.js.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: 149 Branch → ---
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: