# Code maintenance AGILE-425 - Reduce style recalculation during native drag startup

Project: Stream agile
Status: new
URL: https://community.openproject.org/work_packages/AGILE-425

## OPEN POINTS

_No work packages_

## Subtasks

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Designer |  |
| Developers |  |
| Requires doc change | No |
| Date |  |
| Priority | Medium |
| Target versions |  |
| Sprint |  |
| Backlog bucket |  |
| Module |  |
| Accessibility | No |
| List |  |
| Labels |  |

## Estimates and progress

| Attribute | Value |
| --- | --- |
| Work |  |
| Remaining work |  |

## Description

## Problem

Starting a native drag on a large Backlogs page still produces a visible pause. Follow-up to [AGILE-278](https://community.openproject.org/wp/AGILE-278) / [PR <mention class="mention" data-id="24778" data-type="work_package" data-text="#24778">#24778</mention>](https://github.com/opf/openproject/pull/24778); preview/popover performance is explicitly deferred from that PR.

## Evidence

September 9 measurements at commit `ace4b43c7b2`, using 506 rendered cards (501 in a sprint, five in a bucket), a non-admin project member, and headed Chromium 149 on an M4 Pro with no throttling. Rails/Vite development builds; these are lab results, not production or cross-browser guarantees.

  - Three native-pointer samples each at 1/50/300/500 selected, 501 refused, and unselected-source cases. Current drag-start frames take roughly 180–195 ms, largely independent of selection size.
  - Separate probes locate approximately 54 ms each in `showPopover()` inside Pragmatic's `setCustomNativeDragPreview`, the rectangle read inside `preserveOffsetOnSource`, and `showPopover()` inside its `mountHoneyPot` pointer-event workaround. Traces show broad style recalculation over roughly 15,000 elements. The expensive selector/invalidation trigger is not yet established.
  - Temporarily disabling only the custom preview reduces untraced longest-frame medians from 181 to 74 ms for one selected card and 194 to 85 ms for 500. This is a diagnostic experiment, not an acceptable fix.
  - Incremental selection presentation already improves selection work. Repeated dragover dispatch is median 0.08 ms, maximum 0.23 ms in this fixture; batch data preparation is also inexpensive.

## Work

Identify and reduce broad style invalidation during native drag preview and pointer-workaround setup. Investigate the top-layer/popover lifecycle and geometry read/write ordering together; moving a rectangle read alone does not explain both costly `showPopover()` calls. Select an implementation from measured evidence, including upstream or shared-style changes if warranted.

## Merge checklist

- [ ] Reproduce the startup hitch and identify the costly invalidation trigger using native pointer input and style/layout traces.
- [ ] Implement a measured improvement and retain comparable before/after evidence with constant rendered-card counts, repeated samples, and separate startup/dragover timings. Verify in a production build and record remaining costs.
- [ ] Preserve native drag previews, batch count badges, pointer-relative grab offsets, Firefox overhang alignment, cancellation, and external drag data. Retain the protection supplied by Pragmatic's pointer-event workaround.
- [ ] Check single-card and batch drags in Chromium, Firefox and WebKit, including selected/unselected sources, the 500-item boundary, 501-item refusal, and other consumers of any shared code changed.
- [ ] Add regression coverage for the chosen implementation at the appropriate seam; automated tests supplement native-browser performance and visual checks.

## Scope

No selection-policy changes, removal of previews, persistent selection/destination caches, or virtualization as incidental scope. The primary target is drag-start style work, not the already inexpensive repeated dragover path.
