-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chrome infinite scroll performance #7934
Comments
I'm now wondering if this is a layout bug or if something else is going on. This timeline profile indicates that the page load request took 3.5s from kicking off the request to receiving the data during which time the spinner was showing. However, inspecting the actual network request shows it took only 108ms... |
After some more investigation I think I'm running into this behaviour http://stackoverflow.com/questions/35024301/xhr-settimeout-promise-not-finishing-until-scrolling-stops-in-chrome I am consistently able to increase the loading time by scrolling while the network request is being triggered. If I disable Chrome's "threaded scrolling" so that scroll events happen on the main thread the effect is even more pronounced, to the point where I can almost prevent the next page from loading indefinitely. I backed up my conclusion by modifying |
Confirmed the slow infinite scroll loading in LTS is caused by the same setTimeout/XHR blocking behaviour in Chrome as we're seeing since the switch to ember-infinity. I've tested removal of There's a long discussion on a related chrome bug report that has been going on for >1 year https://bugs.chromium.org/p/chromium/issues/detail?id=570845 Things to look into:
|
I eventually tracked this down to a Chrome "optimisation" behaviour that is enabled when you have touch event handlers registered. Disabling touch events in Ember's EventDispatcher solved the problems I was seeing:
Another confounding factor which may/may not have been an issue I noticed when profiling - Chrome seemed to be flagging long frames (~30ms) when scrolling, as far as I can tell that time was taken up entirely by Chrome's |
Closed via TryGhost/Admin@0affec3 |
Hi @kevinansfield, Thanks for this complete debug. I was wondering if disabling touch events really solved the problem ? I'm facing the same issue on a side project and I make no difference 😞 Thanks ! |
@thomasdurin I just fixed this issue in my Angular application by shamefully modifying the Angular source code to use self.defer = (fn, ms) => {
return (ms || 0) < 16 ? window.requestAnimationFrame(fn) : window.setTimeout(fn, ms)
} |
@m59peacemaker Which file in the Angular source code did you modify? We are running into the same issue and desperately looking for a solution... Thanks! |
Mine was in the ionic bower package, You just need to make it use |
And changing it to this should help: var efficientTimeout = (fn, ms) => (ms || 0) < 16
? window.requestAnimationFrame(fn)
: window.setTimeout(fn, ms)
self.defer = function(fn, delay) {
var timeoutId;
outstandingRequestCount++;
timeoutId = efficientTimeout(function() {
delete pendingDeferIds[timeoutId];
completeOutstandingRequest(fn);
}, delay || 0);
pendingDeferIds[timeoutId] = true;
return timeoutId;
}; |
Thanks for the quick reply! We are actually in Angular 2, but maybe I can find a similar workaround there. Thanks again! |
I experienced a similar problem with my own app in React. I stumbled across this post looking for a solution. My issue was related to "Content Download" and infinite scrolling. Disabling the touch events did not work for me, but Chrome honors the
I am still not 100% sure as to how this directly impacted the scroll event in Chrome. Here is a more in-depth response on stack overflow. |
@m59peacemaker I came across this issue in my AngularJS app with a custom lazy template loader. I really like your solution, but didn't want to modify the Angular.js file directly. So instead, during the config phase of the application, I copy the Hope this help someone. :) let $window = $windowProvider.$get();
let $modifiedWindow = Object.assign({}, $window);
$modifiedWindow.setTimeout = (fn, delay = 0) => delay < 15 ? window.requestAnimationFrame(fn) : window.setTimeout(fn, delay);
let [browserProvider] = $browserProvider.$get.slice(-1);
$browserProvider.$get = /*@ngInject*/ ($log, $sniffer, $document) => browserProvider($modifiedWindow, $log, $sniffer, $document); |
Issue Summary
There appears to be a possible layout bug in Chrome that causes long delays when loading/displaying pages of our content list with infinite scroll. This screen cap demonstrates the issue where I am attempting to scroll as quickly as possible (it was particularly bad when recording, I didn't reach the bottom of the list to keep the gif short):
For comparison, here's exactly the same set of posts in safari and scrolling as quickly as possible (note it reaches the bottom of the list before Chrome even displays 1 extra page):
Performance in Firefox is similar to Safari.
Things I've ruled out:
<h3>{{post.title}}</h3>
inside each list element still displays the same problemScroll behaviour and timeouts stalling network connections
I've observed that when dragging with the scrollbar rather than the trackpad it's not possible to reproduce the slow behaviour.
Looking at the timeline profile I can see quite a few scroll events and timers are created, it now seems possible that those events/timers are somehow causing the stalled network requests that I've shown in my comment below
Possible layout bug?Removing all other layout to leave only the scrollable element with the same styling does not exhibit the dire performance illustrated above. This leads me to think that there may be a bug in Chrome's layout engine that is being triggered by something in our surrounding styles/HTML, perhaps something to do with flexbox and an expanding element? I've not had much luck confirming this via profiling, the profiles appear to show Chrome sitting there doing nothing for quite a while before a very quick paint step.Steps to Reproduce
Technical details:
The text was updated successfully, but these errors were encountered: