Accessing offset properties while traversing the DOM hierarchy is slow

Confirmed Issue #7636678 • Assigned to Shuo D.

Details

Author
Kin B.
Created
May 20, 2016
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
20.10240
Reports
Reported by 2 people

Sign in to watch or report this issue.

Steps to reproduce

I have a method that manually calculates the document offset of a given element manually by crawling up the element’s ancestor hierarchy and accumulating offsetLeft/offsetTop and taking into account scrollLeft/scrollTop properties. This is used instead of getClientBoundingRect() because we don’t want to take any CSS transforms into account.

This particular method seems to run at least 25 times slower than in Chrome or Firefox. Below are the test results generated by hitting the “Time It” button in the attached test case 10 times for each browser.

===================================
Lenovo Think Pad Ultrabook (2.6Ghz i7 Windows 10)
===================================

MS Edge:

min: 28 max: 55 avg: 34.08
min: 38 max: 76 avg: 58.72
min: 34 max: 130 avg: 51.34
min: 34 max: 68 avg: 51.69
min: 37 max: 78 avg: 54.61
min: 30 max: 112 avg: 41.55
min: 31 max: 85 avg: 42.32
min: 29 max: 55 avg: 37.61
min: 28 max: 66 avg: 44.25
min: 38 max: 65 avg: 50.56

Chrome:

min: 1 max: 3 avg: 1.34
min: 0 max: 2 avg: 1.12
min: 0 max: 3 avg: 1.16
min: 0 max: 2 avg: 1.04
min: 0 max: 2 avg: 0.99
min: 0 max: 2 avg: 1
min: 0 max: 2 avg: 0.99
min: 0 max: 2 avg: 0.99
min: 0 max: 2 avg: 0.99
min: 0 max: 2 avg: 0.99

Firefox

min: 1 max: 4 avg: 2.01
min: 1 max: 3 avg: 1.55
min: 0 max: 3 avg: 1.38
min: 0 max: 2 avg: 1.02
min: 0 max: 3 avg: 1.45
min: 0 max: 3 avg: 1.58
min: 1 max: 3 avg: 2.03
min: 0 max: 3 avg: 1.59
min: 0 max: 2 avg: 1.02
min: 0 max: 3 avg: 1.07

Just before submitting this bug I did some quick modifications to try and narrow down whether the perf problems are due to traversal, access of scrollLeft/scrollTop, or the offset Properties:


MS Edge

Original Test Case:

min: 36 max: 67 avg: 43.72

No Scroll Props:

min: 24 max: 45 avg: 27.51

No Scroll Props, No offset Top/Left:

min: 10 max: 30 avg: 11.65

No Scroll Props, No offset top/left, No offset parent:

min: 2 max: 7 avg: 2.6

Chrome:

Original Test Case:

min: 0 max: 2 avg: 1.06

No Scroll Props:

min: 0 max: 2 avg: 0.67

No Scroll Props, No offset Top/Left:

min: 0 max: 1 avg: 0.18

No Scroll Props, No offset top/left, No offset parent:

min: 0 max: 1 avg: 0.04

Attachments

1 attachment

Comments and activity

  • Microsoft Edge Team

    Changed Assigned To to “Travis L.”

    Changed Assigned To from “Travis L.” to “Shuo D.”

    Changed Status to “Confirmed”

You need to sign in to your Microsoft account to add a comment.

Sign in