[Bug]: Performance regression in rc.11: waitForConnectedDescendants always defers via requestAnimationFrame
Component
Menu
Package version
3.0.0-rc.11
@microsoft/fast-element version
2.10.2
Environment
Windows environment.
Current Behavior
After upgrading @fluentui/web-components from rc.9/rc.10 to rc.11+, we observe significant performance regressions across multiple metrics in Microsoft Edge internal pages that use FluentUI web components (menu, tablist, dropdown, listbox, accordion).
Root Cause
In packages/web-components/src/utils/request-idle-callback.ts, the
waitForConnectedDescendants function was changed to always call
requestAnimationFrame(callback) even when querySelector(':not(:defined)')
returns null (i.e., all descendants are already defined).
Previously, when all descendants were defined, callback() was called
synchronously. The unconditional rAF deferral pushes component initialization
past vsync boundaries, causing timing regressions.
Impact (measured via A/B testing in Edge)
- timeToFirstContentfulPaint: 164ms (rc.9) → 464ms (rc.12) — 2.8× slower
- 5 components affected: Menu, Tablist, Dropdown, Listbox, Accordion
Suggested Fix
Restore the synchronous fast-path in waitForConnectedDescendants:
const scheduleCheck = (deadline?: IdleDeadline) => {
if (target.querySelector(selector) === null || (deadline && deadline.timeRemaining() <= 0)) {
- requestAnimationFrame(callback);
+ callback();
return;
}
requestIdleCallback(scheduleCheck, { timeout });
};
When all descendants are already defined (non-SSR scenario), there's no reason to defer. The rAF should only be needed when actually waiting for descendants to upgrade.
### Expected Behavior
No performance issues expected.
### Reproduction
Reproduce in Edge
### Steps to reproduce
Compare FCP of before and after version update c.9/rc.10 to rc.11
### Are you reporting an Accessibility issue?
None
### Suggested severity
Urgent - No workaround and Products/sites are affected
### Products/sites affected
_No response_
### Are you willing to submit a PR to fix?
no
### Validations
- [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [x] The provided reproduction is a minimal reproducible example of the bug.
The performance regression has happened due to #35838
Thanks for the detailed root-cause analysis and the A/B metrics — really helpful. Flagging this to the web-components owner (@chrisdholt) as Shield: P1.