Skip to content
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

🚀Only resize viewport during constructor when embedded #27416

Merged
merged 5 commits into from Mar 27, 2020

Conversation

kristoferbaxter
Copy link
Contributor

@kristoferbaxter kristoferbaxter commented Mar 25, 2020

When initializing AMP content on origins or via signed-exchanges, the viewport sets a padding-top and css variable for padding-top to 0.

This change can be expensive on complex and large DOM structures during boot. See attached image of a trace from a complex AMP Document on a Nokia 3.2.

Screen Shot 2020-03-25 at 2 28 14 PM

This PR only sets the styles when an AMP document is embedded inside a viewer.

Copy link
Contributor

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the right approach, but I'm curious if viewer pages also have this large performance penalty. Maybe we can solve both cases by adding something like will-change: padding-top?

test/unit/test-viewport.js Show resolved Hide resolved
@@ -155,7 +155,9 @@ export class ViewportImpl {
'disableScroll',
this.disableScrollEventHandler_.bind(this)
);
this.binding_.updatePaddingTop(this.paddingTop_);
if (this.viewer_.isEmbedded()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kristoferbaxter kristoferbaxter merged commit 9b444cd into ampproject:master Mar 27, 2020
Performance Improvements automation moved this from In progress to Done Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants