Closed Bug 1760910 Opened 3 years ago Closed 3 years ago

Console does not remain always remain scrolled to bottom

Categories

(DevTools :: Console, defect, P2)

defect

Tracking

(firefox101 fixed)

RESOLVED FIXED
101 Branch
Tracking Status
firefox101 --- fixed

People

(Reporter: jdescottes, Assigned: alexical)

Details

Attachments

(1 file)

I was looking at https://discourse.mozilla.org/t/how-to-make-the-console-automatically-scroll/36677/15 and I found a way to make the console lose its scroll to bottom
STRs

  • open console (scrolled to bottom)
  • run:
for (var i = 1; i < 100; i++) {
  window["a" + i] = (function(j) { window["a" + j]() }).bind(null, i+1)
}
function a100() {
  console.warn(new Error("test"));
}
window.setInterval(() => a1(), 1000)

Just a convoluted way to get a warning with a stacktrace. I feel like very tall messages are leading to this issue. To be confirmed.

Note that if your toolbox is very tall (eg 1000px tall), you might not reproduce the issue.

This seems related to the intersection observer at https://searchfox.org/mozilla-central/rev/1f617334179cf28b4b310d1d116ddbc8ef3348ea/devtools/client/webconsole/components/Output/ConsoleOutput.js#99

    this.lastMessageIntersectionObserver = new IntersectionObserver(
      entries => {
        for (const entry of entries) {
          // Consider that we're not pinned to the bottom anymore if the last message is
          // less than half-visible.
          this.scrolledToBottom = entry.intersectionRatio >= 0.5;
        }
      },
      { root: this.outputNode, threshold: [0.5] }
    );

Tall messages will consistently fail this check depending on the toolbox' height.

oh right, I never thought of this like that but if the observed element is taller than the root, it will impact the intersectionRatio (as well as how the observer callback will be called in regard to the defined thresholds)

At some point I tried having a dedicated invisible element at the bottom of the console output that would serve as the observed element instead of observing messages, I may try that again

Severity: -- → S3
Priority: -- → P2
Assignee: nobody → dothayer
Status: NEW → ASSIGNED

This fixes the test included in the patch. However, it makes no guarantees to not
break other things without the virtualization patch, which changes this to observe
the bottom buffer element instead of the last message.

Pushed by dothayer@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/07a9fe270e8f Use root margin instead of half-visibility for scroll pinning r=nchevobbe
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 101 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: