Open Bug 1890261 Opened 2 years ago Updated 4 months ago

The content inside the New Tab page is shaking after opening a new tab

Categories

(Firefox :: Toolbars and Customization, defect, P3)

Desktop
All
defect

Tracking

()

Performance Impact none
Tracking Status
firefox-esr115 --- unaffected
firefox124 --- wontfix
firefox125 --- wontfix
firefox126 --- wontfix
firefox127 --- wontfix
firefox128 --- fix-optional
firefox129 --- fix-optional

People

(Reporter: atrif, Unassigned, NeedInfo)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression)

Attachments

(3 files)

Attached image new_tab.gif

Found in

  • 126.0a1 (2024-04-07)

Affected versions

  • 126.0a1 (2024-04-07)
  • 125.0b9
  • 124.0.2

Tested platforms

  • Affected platforms: macOS 12, Windows 10x64, Ubuntu 23
  • Unaffected platforms: none

Preconditions

  • Recommended by pocket and recent activity disabled

Steps to reproduce

  1. Open Firefox and a new tab.
  2. Observe the new tabs content.

Expected result

  • Content is not moved.

Actual result

  • Content shakes when a new tab is opened.

Regression range

Additional notes

  • Attached a screen recording.
  • The issue can happen on a good build but it’s very rare.

:dao, since you are the author of the regressor, bug 1705215, could you take a look?

For more information, please visit BugBot documentation.

Flags: needinfo?(dao+bmo)
Component: Toolbars and Customization → New Tab Page

Actually, considering the regression range, I think the original component was right. Sorry about the noise.

Component: New Tab Page → Toolbars and Customization

Set release status flags based on info from the regressing bug 1705215

Priority: -- → P3
See Also: → 1892388

Given bug 1890261 and talking to Emilio, this is likely something to do with the viewport size changing and that change somehow happening after the page's initial paint. However, it's not clear to me why that would be the case, despite some digging. Trying to make sure all the relevant attributes get set for the preloaded tabs also didn't help. Emilio, any chance you could help crystallize what is going on here?

Flags: needinfo?(emilio)

Is there an easy way to reproduce this? I haven't been able to notice the shift myself, which makes it hard to investigate...

Flags: needinfo?(emilio) → needinfo?(gijskruitbosch+bugs)

On a debug build, I see the bookmarks toolbar sometimes disappear briefly when opening a new tab, which I suspect is related tho...

(In reply to Emilio Cobos Álvarez (:emilio) from comment #5)

Is there an easy way to reproduce this? I haven't been able to notice the shift myself, which makes it hard to investigate...

I can trivially reproduce by just hammering ctrl-t (cmd-t on my mac, but same deal...). Does that not work for you?

Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(emilio)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #6)

On a debug build, I see the bookmarks toolbar sometimes disappear briefly when opening a new tab, which I suspect is related tho...

This also seems unexpected to me if the bar was visible before, and I'm not sure why it would happen - but that would indeed likely be related.

(In reply to :Gijs (he/him) from comment #7)

I can trivially reproduce by just hammering ctrl-t (cmd-t on my mac, but same deal...). Does that not work for you?

No, that reproduces the bookmarks toolbar issue mentioned in comment 6, not comment 0. But ok, I think given that and some logging, what seems to be going on is that briefly, we think that we have about:blank rather than about:newtab.

Logging:

diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index 7f27f70c2fea3..662368874dbf4 100644
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6116,6 +6116,10 @@ function setToolbarVisibility(
             } catch (ex) {}
           }
         }
+        dump(currentURI?.spec + "\n");
+        if (currentURI?.spec == "about:blank") {
+          dump(new Error().stack + "\n");
+        }
         isVisible = BookmarkingUI.isOnNewTabPage(currentURI);
         document.documentElement.toggleAttribute(overlapAttr, isVisible);
         break;

I get entries like:

about:blank
setToolbarVisibility@chrome://browser/content/browser.js:6121:16
updateBookmarkToolbarVisibility@chrome://browser/content/browser.js:749:23
onLocationChange@chrome://browser/content/browser.js:4692:7
callListeners@chrome://browser/content/tabbrowser.js:983:31
_callProgressListeners@chrome://browser/content/tabbrowser.js:997:22
updateCurrentBrowser@chrome://browser/content/tabbrowser.js:1226:12
_setupEventListeners/<@chrome://browser/content/tabbrowser.js:6064:16
set selectedIndex@chrome://global/content/elements/tabbox.js:236:14
set selectedPanel@chrome://global/content/elements/tabbox.js:246:54
set selectedIndex@chrome://global/content/elements/tabbox.js:599:9
set selectedItem@chrome://global/content/elements/tabbox.js:617:35
set selectedTab@chrome://global/content/elements/tabbox.js:80:11
set selectedTab@chrome://browser/content/tabbrowser.js:423:7
addTab@chrome://browser/content/tabbrowser.js:2844:9
openLinkIn@resource:///modules/URILoadingHelper.sys.mjs:570:41
openTrustedLinkIn@resource:///modules/URILoadingHelper.sys.mjs:727:10
openTrustedLinkIn@chrome://browser/content/utilityOverlay.js:122:20
openTab/<.wrappedJSObject<@chrome://browser/content/browser-commands.js:339:28
openTab@chrome://browser/content/browser-commands.js:325:26
oncommand@chrome://browser/content/browser.xhtml:1:17

I think that should explain the issue? So now the question I guess is why the currentURI is about:blank... I can dig into that if you need?

Flags: needinfo?(emilio)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #9)

(In reply to :Gijs (he/him) from comment #7)

I can trivially reproduce by just hammering ctrl-t (cmd-t on my mac, but same deal...). Does that not work for you?

No, that reproduces the bookmarks toolbar issue mentioned in comment 6, not comment 0. But ok, I think given that and some logging, what seems to be going on is that briefly, we think that we have about:blank rather than about:newtab.

Do you have the "recommended by pocket" stories and recent activity disabled (using the settings bit on the new tab page)? That's the thing that just confused me.

Logging:

diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index 7f27f70c2fea3..662368874dbf4 100644
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6116,6 +6116,10 @@ function setToolbarVisibility(
             } catch (ex) {}
           }
         }
+        dump(currentURI?.spec + "\n");
+        if (currentURI?.spec == "about:blank") {
+          dump(new Error().stack + "\n");
+        }
         isVisible = BookmarkingUI.isOnNewTabPage(currentURI);
         document.documentElement.toggleAttribute(overlapAttr, isVisible);
         break;

I get entries like:

about:blank
setToolbarVisibility@chrome://browser/content/browser.js:6121:16
updateBookmarkToolbarVisibility@chrome://browser/content/browser.js:749:23
onLocationChange@chrome://browser/content/browser.js:4692:7
callListeners@chrome://browser/content/tabbrowser.js:983:31
_callProgressListeners@chrome://browser/content/tabbrowser.js:997:22
updateCurrentBrowser@chrome://browser/content/tabbrowser.js:1226:12
_setupEventListeners/<@chrome://browser/content/tabbrowser.js:6064:16
set selectedIndex@chrome://global/content/elements/tabbox.js:236:14
set selectedPanel@chrome://global/content/elements/tabbox.js:246:54
set selectedIndex@chrome://global/content/elements/tabbox.js:599:9
set selectedItem@chrome://global/content/elements/tabbox.js:617:35
set selectedTab@chrome://global/content/elements/tabbox.js:80:11
set selectedTab@chrome://browser/content/tabbrowser.js:423:7
addTab@chrome://browser/content/tabbrowser.js:2844:9
openLinkIn@resource:///modules/URILoadingHelper.sys.mjs:570:41
openTrustedLinkIn@resource:///modules/URILoadingHelper.sys.mjs:727:10
openTrustedLinkIn@chrome://browser/content/utilityOverlay.js:122:20
openTab/<.wrappedJSObject<@chrome://browser/content/browser-commands.js:339:28
openTab@chrome://browser/content/browser-commands.js:325:26
oncommand@chrome://browser/content/browser.xhtml:1:17

I think that should explain the issue? So now the question I guess is why the currentURI is about:blank... I can dig into that if you need?

I added logging to updateCurrentBrowser and do not see it being hit with about:blank. I can see some occasionally in setToolbarVisibility but they do not correlate with the flickering and if I add an early return there for the about:blank case, I don't see any improvement.

Flags: needinfo?(emilio)

Do you have the "recommended by pocket" stories and recent activity disabled (using the settings bit on the new tab page)? That's the thing that just confused me.

Gah, I did not, and that explains it. The issue is that those add up enough content for the center-aligned flex item in the new tab page to overflow the viewport. So it doesn't shift on resize.

So if I early-return (well, early-break) to the about:blank case in setToolbarVisibility I definitely see an improvement, which is that the bookmarks toolbar no longer flickers when hammering Ctrl+T.

However, I can repro this now consistently, and I see what's going on. The issue is that the browser gets dynamically resized, and that the content in the new tab page is center aligned. So the shift is just what you see when you add and remove this padding.

In fact, if you do this, which I thought was a clever simplification:

diff --git a/browser/base/content/tabbrowser.js b/browser/base/content/tabbrowser.js
index f319fd5d46c64..9627ff1f1ae2c 100644
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -3050,10 +3050,6 @@
         usingPreloadedContent,
       };

-      if (BookmarkingUI.isOnNewTabPage(uri)) {
-        this.getPanel(b).classList.add("newTabBrowserPanel");
-      }
-
       // Hack to ensure that the about:newtab, and about:welcome favicon is loaded
       // instantaneously, to avoid flickering and improve perceived performance.
       this.setDefaultIcon(tab, uri);
@@ -7091,13 +7087,6 @@
             this.mTab.linkedBrowser.mute();
           }

-          gBrowser
-            .getPanel(this.mBrowser)
-            .classList.toggle(
-              "newTabBrowserPanel",
-              BookmarkingUI.isOnNewTabPage(aLocation)
-            );
-
           if (gBrowser.isFindBarInitialized(this.mTab)) {
             let findBar = gBrowser.getCachedFindBar(this.mTab);

diff --git a/browser/themes/shared/browser-shared.css b/browser/themes/shared/browser-shared.css
index 9e513830a9d9e..35646a6ea4704 100644
--- a/browser/themes/shared/browser-shared.css
+++ b/browser/themes/shared/browser-shared.css
@@ -315,7 +315,7 @@
     z-index: 1;
   }

-  .newTabBrowserPanel,
+  .browserSidebarContainer.deck-selected,
   #sidebar-box {
     /* Make room for the bookmarks toolbar so that it won't visibly overlap the
        new tab page and sidebar contents. We do not put this padding on #browser

You also see it when ctrl-tabbing between newtab pages.

So it's just really a race between when the next layout happens in the parent process (which determines when the resize in content happens) and the ongoing load in the child process...

So I think the most reliable way to prevent this from happening would be to just move that padding to the child process, so that the newtab page applies it unconditionally when that setting is on, rather than async...

There are other possible fixes tho... But most of them would require some coordination between newtab and the browser anyways so...

Flags: needinfo?(emilio)

Something like this (I had to manually apply the change to
activity-stream-linux.css to test it, ugh) seems to work, but would
still need to pass down the settings (maybe via contentTheme.js?).

(In reply to Emilio Cobos Álvarez (:emilio) from comment #11)

So I think the most reliable way to prevent this from happening would be to just move that padding to the child process, so that the newtab page applies it unconditionally when that setting is on, rather than async...

There are other possible fixes tho... But most of them would require some coordination between newtab and the browser anyways so...

Hm. Unfortunately the resizing applies also to custom new tab pages (provided by web extensions) and to blank tabs. Obviously for blank tabs it doesn't make any visual difference when we resize or overlap, so that part is fine. But webextension new tab pages are a different matter - if the BMT ends up overlapping the top of those (which AIUI is what the WIP would cause to happen as-is?) that is likely to interfere with their styling (page would get cut off at the top). Or am I misunderstanding the patch?

The thing is, because we preload the new tab page, I would have thought that if we set the correct size when creating the browser in which we preload (or the new browser created when preload is off / we haven't created a new preload browser yet after using the last few), that would fix this, and then there wouldn't be any kind of race possible? New tab loads are supposed to be very fast because of this preloading, and I would have thought we could deal with this as part of that...
If we do this for newly created tabs that we know are "new tab"s (ie besides the preloading, which is turned off if the new tab page isn't provided by us), then that'd even address this in the webextension case.

Flags: needinfo?(emilio)

(In reply to :Gijs (he/him) from comment #13)

Hm. Unfortunately the resizing applies also to custom new tab pages (provided by web extensions) and to blank tabs. Obviously for blank tabs it doesn't make any visual difference when we resize or overlap, so that part is fine. But webextension new tab pages are a different matter - if the BMT ends up overlapping the top of those (which AIUI is what the WIP would cause to happen as-is?) that is likely to interfere with their styling (page would get cut off at the top). Or am I misunderstanding the patch?

No, that's correct, wasn't aware of that.

The thing is, because we preload the new tab page, I would have thought that if we set the correct size when creating the browser in which we preload (or the new browser created when preload is off / we haven't created a new preload browser yet after using the last few), that would fix this, and then there wouldn't be any kind of race possible? New tab loads are supposed to be very fast because of this preloading, and I would have thought we could deal with this as part of that...
If we do this for newly created tabs that we know are "new tab"s (ie besides the preloading, which is turned off if the new tab page isn't provided by us), then that'd even address this in the webextension case.

Yeah, that sounds right. It'd basically be a matter of adding the .newTabBrowserPanel class earlier or so...

Flags: needinfo?(emilio)

Gijs, I notice this regression has a fair amount of discussion last month, but also has a low severity and priority set.
Do you think the impact/severity should be higher? If so then maybe you can help find an owner for this.

But otherwise, let's mark it fix-optional across all current releases so that it will drop from weekly regression triage. Thanks!

Flags: needinfo?(gijskruitbosch+bugs)

I think the severity of this is probably accurate in terms of the immediately-user-felt effect of the flicker. However, I was hoping to come back to it because I suspect there are performance implications to this bug (as we're resizing the new tab page and that takes CPU and GPU work that we shouldn't be doing) that we'd benefit from addressing more than the S4 severity might suggest. I'll keep the needinfo and request a perf evaluation, I guess.

Moving this to a reminder.

Flags: needinfo?(gijskruitbosch+bugs)

I think we have a similar issue in Tor Browser: switching from a web page to a content page (our home page) causes the home page content to jump.

As per Gijs' indication about resource use.

The Performance Impact Calculator has determined this bug's performance impact to be medium. If you'd like to request re-triage, you can reset the Performance Impact flag to "?" or needinfo the triage sheriff.

Platforms: [x] Windows [x] macOS [x] Linux
Resource impact: Severe
[x] Able to reproduce locally

Performance Impact: ? → medium

I don't think this is severe nowadays fwiw after bug 1917458, but also bug 1917458 changed how this code works significantly so are we sure this is still an issue? I can't repro comment 0 locally...

See Also: → 1917458
Summary: The content inside the New Tab page is shaking after opening a new tab. → The content inside the New Tab page is shaking after opening a new tab

I can still reproduce something similar in my development build by switching between a new tab and a web page.

It seems to be much rarer when switching between new tabs though.

Blocks: 1920587
Performance Impact: medium → none
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: