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
Conversation
} | ||
|
||
this.iframe_ = null; | ||
this.intersectionObserver_ = null; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
db41bc0
to
03850ee
Compare
LGTM |
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.