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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Block initial amp-story render on amp-story layout #21382

Merged
merged 7 commits into from Mar 30, 2019

Conversation

newmuis
Copy link
Contributor

@newmuis newmuis commented Mar 12, 2019

Followup to #21193. This fixes the previously-broken definition for amp-story, so that it may block on it's layoutCallback before rendering.

Fixes #21349

Copy link
Contributor

@gmajoulet gmajoulet left a comment

Choose a reason for hiding this comment

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

Implementation LGTM

@@ -2360,6 +2360,32 @@ export class AmpStory extends AMP.BaseElement {
}
}

/** @implements {../../../src/render-delaying-services.RenderDelayingService} */
class AmpStoryRender {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have a separate amp-story-render.js file?

return Promise.resolve();
}

return this.storyEl_.signals().whenSignal(CommonSignals.LOAD_END);
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to wait for storyEL_ to upgrade to an AMP element before calling signals()

Copy link
Contributor

Choose a reason for hiding this comment

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

This hasn't been addressed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be addressed now 馃槂

extensions/amp-story/1.0/amp-story.js Outdated Show resolved Hide resolved
Copy link
Contributor

@torch2424 torch2424 left a comment

Choose a reason for hiding this comment

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

LGTM 馃槃 Merge once @jridgewell 's comments are addressed.

Also, thanks for taking this on! 馃挴

@newmuis
Copy link
Contributor Author

newmuis commented Mar 27, 2019

PTAL @jridgewell for changes to amp-story-render-service.js.

@gmajoulet
Copy link
Contributor

Could you please host a demo for this? I'd like to test it over different internet connections. If I understand correctly, it will show nothing (completely blank document), until the first page and its media are fully loaded?

Some people actually like the fact that we try to show the text content + CSS before the media is loaded, cf: https://twitter.com/TappableHQ/status/1107950229335277568, they even made a video.
In the case of this video, if I understand correctly, this PR would delay the FMP by 5 or 6 seconds. :(

@newmuis
Copy link
Contributor Author

newmuis commented Mar 27, 2019

Sure, I've hosted this here.

I don't think we actually block on the media of the first page. We create a separate promise for what we return in layoutCallback vs. our own internal representation of the story being "loaded".

// Do not block the layout callback on the completion of these promises, as
// that prevents descendents from being laid out (and therefore loaded).
storyLayoutPromise.then(() => this.whenPagesLoaded_(PAGE_LOAD_TIMEOUT_MS))
.then(() => this.markStoryAsLoaded_());
return storyLayoutPromise;

Co-Authored-By: newmuis <newmuis@users.noreply.github.com>
@googlebot
Copy link

So there's good news and bad news.

馃憤 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

馃槙 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

鈩癸笍 Googlers: Go here for more info.

@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

鈩癸笍 Googlers: Go here for more info.

@googlebot
Copy link

So there's good news and bad news.

馃憤 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

馃槙 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

鈩癸笍 Googlers: Go here for more info.

return whenUpgradedToCustomElement(storyEl).signals()
return whenUpgradedToCustomElement(storyEl).then(() => {
return storyEl.signals().whenSignal(CommonSignals.LOAD_END);
})
.whenSignal(CommonSignals.LOAD_END);
Copy link
Contributor

Choose a reason for hiding this comment

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

Auto suggest bug. 馃槵

@@ -39,6 +39,7 @@ import {getServicePromise} from './service';
const SERVICES = {
'amp-dynamic-css-classes': '[custom-element=amp-dynamic-css-classes]',
'variant': 'amp-experiment',
'amp-story-render': 'amp-story[standalone]',
Copy link
Contributor

Choose a reason for hiding this comment

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

The validator team will need to update our list of render-blocking extensions so that this one is injected with a link-preload when necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/cc @Gregable is that something you can do? I'm not sure if it's already there; amp-story previously had a definition that was just broken.

Copy link
Contributor

Choose a reason for hiding this comment

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

Internally we have b/77581738 filed which is about being able to remove the boilerplate for amp-story and not including a preload link. @newmuis Would the preload link be for all of amp-story (I don't see an amp-story-render-0.1.js being served from the cdn)?

Copy link
Contributor Author

@newmuis newmuis Apr 3, 2019

Choose a reason for hiding this comment

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

Right now, yes: all of amp-story. We could take it as a separate project to divide amp-story into what's render-blocking vs. what's not, but we're a while away from that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Filed b/129863998

Copy link
Contributor

Choose a reason for hiding this comment

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

Annnnd, this is already being done. Apologies for the noise. If you're not seeing a preload please let me know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@newmuis newmuis added cla: yes and removed cla: no labels Mar 30, 2019
@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

鈩癸笍 Googlers: Go here for more info.

@newmuis newmuis merged commit a6fdcad into ampproject:master Mar 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix amp-story render-delaying usage
6 participants