Skip to content

🐛 Fixed first contentful paint race condition - #25259

Merged
micajuine-ho merged 13 commits into
ampproject:masterfrom
micajuine-ho:performance_race_condition
Dec 17, 2019
Merged

🐛 Fixed first contentful paint race condition #25259
micajuine-ho merged 13 commits into
ampproject:masterfrom
micajuine-ho:performance_race_condition

Conversation

@micajuine-ho

Copy link
Copy Markdown
Contributor

Fixed a race condition where an analytics request for FIRST_CONTENTFUL_PAINT would sometimes resolve to null because it hadn't be set yet.

Applied this fix to FIRST_VIEWPORT_READY and MAKE_BODY_VISIBLE as well.

cc @zhouyx @jridgewell @keithwrightbos @ampproject/wg-ads

@jridgewell
jridgewell requested a review from zhouyx October 25, 2019 20:01
Comment thread src/service/performance-impl.js Outdated
Comment thread src/service/performance-impl.js Outdated
Comment thread src/service/performance-impl.js Outdated
@zhouyx

zhouyx commented Oct 25, 2019

Copy link
Copy Markdown
Contributor

@keithwrightbos The variable was introduced by #13015. When we tested the behavior we found that there's a race condition between the analytics ping and the first_contentful_paint. if the first_contentful_paint happens after the analytics ping, the value will be resolved to null.

This brings us back to the discussion of async vs sync macro : ) We think that the current behavior is not consistent and want to fix the race condition. Please let us know what do you think about the fix. Thank you.

@zhouyx

zhouyx commented Oct 25, 2019

Copy link
Copy Markdown
Contributor

cc @jonkeller as well to understand the impact to the metrics. (The requests may be delayed to wait for the value) Also I wonder how we handle fcp=null today. Thanks.

@zhouyx zhouyx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please sync with the ads team offline to make sure they're aware of the change. SYNC macro becomes ASYNC, and understand if we want to provide a SYNC version of these variables. Thanks.

Comment thread test/integration/test-amp-analytics.js
Comment thread test/manual/amp-analytics/analytics-fcp.html
Comment thread src/amp.js
@micajuine-ho

Copy link
Copy Markdown
Contributor Author

Could you please sync with the ads team offline to make sure they're aware of the change. SYNC macro becomes ASYNC, and understand if we want to provide a SYNC version of these variables.

Ads team signed off on the changes.

@zhouyx

zhouyx commented Nov 14, 2019

Copy link
Copy Markdown
Contributor

LGTM. to @jridgewell for owner's approval. Thank you

Comment thread src/amp.js
@micajuine-ho micajuine-ho reopened this Dec 13, 2019
@micajuine-ho
micajuine-ho merged commit 22c1399 into ampproject:master Dec 17, 2019
@micajuine-ho
micajuine-ho deleted the performance_race_condition branch December 17, 2019 19:47
micajuine-ho pushed a commit to micajuine-ho/amphtml that referenced this pull request Dec 27, 2019
* edge case handling and testing

* type fixing

* cleaning up

* changing to only serve chrome

* install platform service for fcp

* Clean up integration test

* viewport

* remove platform test
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.

4 participants