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

馃悰 Layers: Bust Resource's measurements when dirtying #21748

Merged

Conversation

jridgewell
Copy link
Contributor

When the Layers experiment was enabled, dirtying the element would invalidate Layer's cached measurements. But I forgot to invalidate Resource's measurement state, which controls signals to the AMP elements (like, onLayoutMeasure and onMeasureChanged).

This has a particularly bad affect on A4A ads, since they initiate ads requests during onLayoutMeasure!

When the Layers experiment was enabled, dirtying the element would
invalidate Layer's cached measurements. But I forgot to invalidate
Resource's measurement state, which controls signals to the AMP elements
(like, `onLayoutMeasure` and `onMeasureChanged`).

This has a particularly bad affect on A4A ads, since they initiate ads
requests during `onLayoutMeasure`!
@jridgewell jridgewell added this to TODO in Layers via automation Apr 5, 2019
r.requestMeasure();
}
const ampElements = element.getElementsByClassName('i-amphtml-element');
for (let i = 0; i < ampElements.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not:

for (const ampElement of element.getElementsByClassName('i-amphtml-element') {
   ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't use for-of loops because it requires a Symbol.iterator (and Symbol) polyfill.

@jridgewell jridgewell merged commit f6c3f7d into ampproject:master Apr 8, 2019
Layers automation moved this from TODO to Done Apr 8, 2019
@jridgewell jridgewell deleted the layers-bust-resources-measurement branch April 8, 2019 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Layers
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants