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

Make <amp-install-service-worker> a low priority element, and remove timer-based delay to installation #13409

Conversation

danielrozenberg
Copy link
Member

Fixed #12473

@danielrozenberg danielrozenberg force-pushed the remove-amp-install-service-worker-delay branch 2 times, most recently from ce34d8c to c8dfd93 Compare February 15, 2018 16:41
@zackargyle
Copy link
Contributor

This is awesome. Thank you @danielrozenberg!

@jridgewell
Copy link
Contributor

/to @cramforce, to confirm this is what he meant.

@@ -92,27 +92,20 @@ export class AmpInstallServiceWorker extends AMP.BaseElement {
}
}

/** @override */
getPriority() {
return 2;
Copy link
Member

Choose a reason for hiding this comment

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

We should have constants for this. At least give it a comment.

Copy link
Member

Choose a reason for hiding this comment

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

Also, I think 3 (even lower than ads) may be more appropriate.

Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced with 3. Created a new issue #13555 to replace them with constants later

/** @override */
getPriority() {
return 3;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems priority only affect #layoutCallback, but we're installing the iframe/SW in #buildCallback.

Choose a reason for hiding this comment

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

Nice catch. Perhaps we should rename getPriority to getLayoutPriority.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure 👍.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jridgewell PTAL, moved insertion of the iframe into layout phase. I also changed the description of #13555 to mention renaming the getPriority method as @choumx suggsted

@cramforce
Copy link
Member

cramforce commented Feb 21, 2018 via email

@@ -49,6 +49,9 @@ export class AmpInstallServiceWorker extends AMP.BaseElement {

/** @private {?UrlRewriter_} */
this.urlRewriter_ = null;

/** @private {boolean} */
this.shouldInsertframeOnFirstLayout_ = false;

Choose a reason for hiding this comment

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

Nit: insertIframeOnFirstLayout

/** @private */
insertIframe_() {
// Mutate block is not required when calling this method, since the inserted
// iframe has `display: none` and does not modify the document's layout.
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately not, any insertion can cause CSS style recalc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it enough to call it from inside layoutCallback() or does it need more explicit protection?

}

/** @override */
firstLayoutCompleted() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use layoutCallback. We'll need to guard against layout happening, regardless.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@danielrozenberg
Copy link
Member Author

/to @jridgewell better?

@danielrozenberg
Copy link
Member Author

Ping @jridgewell

@danielrozenberg danielrozenberg force-pushed the remove-amp-install-service-worker-delay branch from 0e91ef6 to ef121b9 Compare March 7, 2018 18:00
@dreamofabear dreamofabear merged commit 7a8be5f into ampproject:master Mar 7, 2018
@danielrozenberg danielrozenberg deleted the remove-amp-install-service-worker-delay branch March 8, 2018 19:13
RanAbram pushed a commit to RanAbram/amphtml that referenced this pull request Mar 12, 2018
…timer-based delay to installation (ampproject#13409)

* Make <amp-install-service-worker> a low priority element, and remove timer-based delay to installation

* Set priority to 3

* Move insertion of the iframe into layout phase

* Address @choumx's comment

* Address @jridgewell's comments

* Fix missing resolved promise in layoutCallback()
dreamofabear pushed a commit to dreamofabear/amphtml that referenced this pull request Mar 28, 2018
… remove timer-based delay to installation (ampproject#13409)"

This reverts commit 7a8be5f.
dreamofabear pushed a commit that referenced this pull request Mar 28, 2018
#14293)

* Revert "Make <amp-install-service-worker> a low priority element, and remove timer-based delay to installation (#13409)"

This reverts commit 7a8be5f.

* s/deferMutate/mutateElement

* remove import
dreamofabear pushed a commit that referenced this pull request Mar 28, 2018
#14293)

* Revert "Make <amp-install-service-worker> a low priority element, and remove timer-based delay to installation (#13409)"

This reverts commit 7a8be5f.

* s/deferMutate/mutateElement

* remove import
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.

None yet

6 participants