Closed Bug 1635002 Opened 4 years ago Closed 4 years ago

Firefox freezes when inspecting element with many CSS variables (youtube.com)

Categories

(DevTools :: Inspector, defect)

75 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1623988

People

(Reporter: nyanpasu64, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0

Steps to reproduce:

Actual results:

Browser hangs for several seconds loading Inspect Element / Developer Tools / Inspector. This is because Youtube defines hundreds/thousands of CSS variables at the html element level, and Firefox takes a long time to load them.

Expected results:

Firefox Inspect Element doesn't freeze while loading many CSS variables.

Test Case

I attached a synthetic test case which defines CSS variables in the <b> tag scope. The more times you press the button, the more variables are created. Pressing F12 (which highlights the <body> tag) does not freeze Firefox, but focusing the <b> tag (sometimes you need to press the right arrow key) makes the browser freeze for varying lengths of time.

On my computer in a nearly-fresh profile (uBlock Origin installed but disabled), I timed how long Firefox freezes:

  • 400: 600ms
  • 800: 1.8s
  • 1600: 4.9s
  • 3200: 17.5s
  • 6400: 107s

The growth appears to be somewhere near quadratic, but not fitting a quadratic curve cleanly. 6400 is significantly slower than expected.

Analysis

The main process freezes, not the content process. If I terminate the process burning CPU, the entire browser closes down.

Firefox Profiler trace (1600 elements) at https://perfht.ml/2Wm3sbv . The CPU usage occurs in Parent Process, with the process being stuck in the following function:

hasCSSVariable
hasCSSVariable
_hasUpdatedCSSVariable
updateDeclarations
onRuleUpdated
populate/populated<
js::RunScript
promise callback
XREMain::XRE_main
(root)

I don't know the codebase well enough to diagnose and fix the bug though.

Component: Untriaged → Inspector
Product: Firefox → DevTools

Thanks for investigating and filing this issue.
The fix is being worked on in bug 1623988

Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE

The fix for bug 1623988 landed in Firefox Nightly 78. Inspecting nodes on YouTube.com should be substantially faster.

Thanks for the original investigation, nyanpasu64!

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: