Skip to content

[amp-inabox] Only request position when visibility-v2 is disabled or …#6787

Merged
lannka merged 2 commits intoampproject:masterfrom
lannka:dont-request-position
Dec 22, 2016
Merged

[amp-inabox] Only request position when visibility-v2 is disabled or …#6787
lannka merged 2 commits intoampproject:masterfrom
lannka:dont-request-position

Conversation

@lannka
Copy link
Copy Markdown
Contributor

@lannka lannka commented Dec 21, 2016

…native IntersectionObserver is not available.

for #5700

…native IntersectionObserver is not available.
@bradfrizzell
Copy link
Copy Markdown
Contributor

lgtm

@lannka
Copy link
Copy Markdown
Contributor Author

lannka commented Dec 22, 2016

@bradfrizzell @keithwrightbos just FYI, this means ads tag will not receive a request from inabox (hence no host script needs to be loaded) if we're in a browser that supports IntersectionObserver.

/** @override */
connect() {
if (this.visibilityV2Enabled_) {
// Visibility V2 uses native IntersectionObserver, no position data needed
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.

I wonder does the native IntersectionObserver callback function handle remeasure correctly? Could you link me the code where the callback function is?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The intersection is not calculated by AMP runtime, so no re-measure needs to happen:
https://github.com/ampproject/amphtml/blob/master/extensions/amp-analytics/0.1/visibility-impl.js#L353

Copy link
Copy Markdown
Contributor

@zhouyx zhouyx Dec 22, 2016

Choose a reason for hiding this comment

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

But we will update this.viewportRect in the polyfill case, and then runtime will take care of the scheduling layout of the element. I can't find where we update this in our native IO callback function. Without it how would runtime know when to layout the element of inabox? This also happen to the viewport onScroll and viewport onResize event. Am I missing something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you're right. but inabox V1 does not take care of resource scheduling. we will only make the amp-analytics visibility tracking useful at the moment.

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.

Then I think we can't just return when this.visiblityV2Enabled_ is true, connect() function is not only about amp-analytics visibility tracking, it will also take care of remeasuring viewportBox for runtime use. We can't simply skip that part of logic with visiblityV2Enabled_ is true?

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.

As talked offline. This is good with inabox V1. LGTM

@zhouyx
Copy link
Copy Markdown
Contributor

zhouyx commented Dec 22, 2016

LGTM

@lannka lannka merged commit b22fb75 into ampproject:master Dec 22, 2016
@lannka lannka deleted the dont-request-position branch December 22, 2016 20:44
torch2424 pushed a commit to torch2424/amphtml that referenced this pull request Jan 3, 2017
ampproject#6787)

* [amp-inabox] Only request position when visibility-v2 is disabled or native IntersectionObserver is not available.

* Fix lint
jridgewell pushed a commit to jridgewell/amphtml that referenced this pull request Jan 31, 2017
ampproject#6787)

* [amp-inabox] Only request position when visibility-v2 is disabled or native IntersectionObserver is not available.

* Fix lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants