Open Bug 1603449 Opened 4 years ago Updated 2 years ago

Sync layout flush at the end of page load due to poor interaction between reader mode and add-ons

Categories

(Toolkit :: Reader Mode, defect, P3)

defect

Tracking

()

Performance Impact low

People

(Reporter: florian, Unassigned)

Details

(Keywords: perf, perf:frontend, perf:responsiveness)

See this profile https://perfht.ml/2t6umZS and look at the 'Styles' marker (the light blue one).

onPaintWhenWaitedFor (AboutReaderChild.jsm) triggered off the MozAfterPaint event causes a sync layout flush when isNodeVisible (Readerable.jsm) calls element.clientHeight.

Layout has been invalidated by:
inject/cssPromise< [resource://gre/modules/ExtensionContent.jsm:507:54]
runSafeSyncWithoutClone [resource://gre/modules/ExtensionCommon.jsm:73:32]
nsDOMWindowUtils::AddSheet(nsIPreloadedStyleSheet*, unsigned int) [XUL]
mozilla::dom::Document::AddAdditionalStyleSheet(mozilla::dom::Document::additionalSheetType, mozilla::StyleSheet*) [XUL]

This CSS is likely injected by uBlock Origin.

The simplest solution here is going to be:

  1. bring back the old isNodeVisible helper that uses getBoundsWithoutFlushing.
  2. optionally, move getBoundsWithoutFlushing to Element as a ChromeOnly method, cf. bug 1477239, to reduce the xpconnect overhead, which was a concern in the discussion in https://phabricator.services.mozilla.com/D3687#inline-14071 .

Because this is in isProbablyReaderable, which runs on almost every page users will open (ie not only when actually using reader mode), this is probably a fairly serious performance concern... but P3 for reader mode because it's unstaffed atm. We can probably prio from an fxperf perspective.

OS: Unspecified → All
Priority: -- → P3
Hardware: Unspecified → All
Whiteboard: [fxperf]

Marking as fxperf:p2 because of how frequently this problem occurs

Whiteboard: [fxperf] → [fxperf:p2]
Performance Impact: --- → ?
Whiteboard: [fxperf:p2]
Performance Impact: ? → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.