Project

General

Profile

Actions

Defect #43742

closed

Missing #wrapper positioning may increase reflow cost

Added by Jimmy Westberg 23 days ago. Updated 9 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Performance
Target version:
Resolution:
Fixed
Affected version:

Description

I have an issue type with a lot of long text input (full width). In the desktop mode the input latency was average 2000ms but in phone mode it was below 10ms. I looked at the wrapper element and this fixed my issue in desktop mode:

#wrapper {
    position: relative;
}

Files

Actions #1

Updated by Jimmy Westberg 23 days ago

  1. Performance Issue Root Cause and Fix (Desktop vs Mobile Breakpoint)

We investigated a severe input latency problem on Redmine issue pages with many form fields.

In desktop layout (≥900px width), typing in input fields caused extreme delays (2–6 seconds per keystroke).
In responsive/mobile layout (<900px), the same page performed normally (~10–30ms latency).


  1. Key Finding

The performance difference was not caused by the menu itself or by the number of event handlers.
Instead, the root cause was a layout/positioning behavior related to the main page container:

- Desktop layout: `#wrapper` uses the default `position: static`
- Mobile layout: `#wrapper` becomes `position: relative`

Adding the following CSS rule immediately eliminated the input lag:

#wrapper {
  position: relative;
}

  1. Why This Fix Works

Although `position: relative` does not visually move the wrapper, it changes browser layout behavior in an important way:

- It creates a stable containing block for absolutely positioned UI elements (dropdowns, autocompletes, datepickers, overlays).
- Without a positioned ancestor, such elements may be positioned relative to the document/body, which can trigger expensive global reflow/repaint operations.
- On large pages with many inputs, this can cause layout thrashing during typing (forced synchronous reflows on each key event).

Once `#wrapper` becomes a positioned ancestor, layout calculations become more localized and much cheaper, restoring normal responsiveness.


  1. Evidence

A breakpoint diff at 900px → 899px showed:

- `#wrapper` changes from `position: static` → `position: relative`
- Menus/sidebar are moved into an offscreen flyout structure
- Input latency drops from seconds to milliseconds


  1. Recommendation

Consider setting `#wrapper { position: relative; }` (or applying it specifically on issue pages) as a default, since it prevents catastrophic reflow behavior on large forms.

This appears to be a browser layout containment issue triggered by missing positioned ancestors in desktop mode.

Actions #2

Updated by Go MAEDA 22 days ago

Thanks for the report. To reproduce this, could you share roughly how many full-width long text fields are on the issue edit form?

Actions #3

Updated by Jimmy Westberg 22 days ago

21 to be exact but I got a feeling it's starting to be noticeable with 8-10

Actions #4

Updated by Go MAEDA 12 days ago

I could not reproduce the performance issue in my environment.

However, adding position: relative; to #wrapper does not cause layout problems, and it may help reduce potential reflow cost. Since mobile layout already uses this setting, I would like to apply the same change on desktop as a preventive improvement.

Actions #5

Updated by Jimmy Westberg 12 days ago

Yes that would probably be a good thing. My plugins (Additionals being a candidate) adds GUI elements which might be what's triggering this issue. Thank you for looking into this.

Actions #6

Updated by Go MAEDA 11 days ago

  • Target version changed from Candidate for next major release to 7.0.0

Setting the target version to 7.0.0.

Actions #7

Updated by Go MAEDA 9 days ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the fix in r24429. Thank you.

Actions #8

Updated by Go MAEDA 9 days ago

  • Subject changed from Missing #wrapper positioning may increase reflow cost on large forms to Missing #wrapper positioning may increase reflow cost
Actions

Also available in: Atom PDF