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

Remove ad during unlayout #2697

Merged
merged 1 commit into from Mar 29, 2016

Conversation

jridgewell
Copy link
Contributor

Should improve the swiping performance. Right now, I've set amp-ad to unlayout on pause, meaning we will remove the ad at the beginning of the swipe. If this hurts performance, we can remove that and have it only remove on unlayout (when the swipe completes).

Fixes #2563.

}

this.iframe_ = null;
this.intersectionObserver_ = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

To double-check - intersection observer is likely to listen on viewport or such. Is there some sort of unlisten for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The unlistener doesn't get returned during construction, so no way to call it. Apparently it only listens to the iframe though, so it should be cleaned up by virtue of the the iframe's contentWindow being destroyed.

Copy link
Contributor

Choose a reason for hiding this comment

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

It does also listen on viewport. But it looks like all listeners are freed via onViewportCallback(false) which is called from the element's onViewportCallback. Could you confirm if you always call onViewportCallback(false) on the element before unlayout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, I see that now. Both #pause and #unlayout call setInViewport(false).

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool. Then no worries. But I'd still add a comment - "The listeners have already been freed via setInViewport(false) before unlayout" - or something like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Commented.

Should improve the swiping performance.
@dvoytenko
Copy link
Contributor

LGTM

@jridgewell jridgewell merged commit 8cacbdf into ampproject:master Mar 29, 2016
@jridgewell jridgewell deleted the remove-ad-on-pause branch March 29, 2016 19:43
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.

None yet

2 participants