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
Modify amp sticky ad to only wait on render-start if render-start implemented. #21157
Conversation
]).then(() => { | ||
return this.ad_.getImpl().then(impl => { | ||
const promises = [signals.whenSignal(CommonSignals.RENDER_START)]; | ||
if (!(impl.config || {}).renderStartImplemented) { |
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.
Seems odd that this ever used load end as a signal. I would instead of expected render start signal to be sufficient and that the AMP runtime just controls when the signal fires based on the impl config. In other words, for DF config w/o renderStartImplemented, render start is fired when the iframe is attached. While for configs w/ renderStartImplemented, it would be fired based on received postMessage triggered by context.renderStarted(). Are we positive that's no the case?
Was a goal here that the sticky shouldn't be made visible until the creative had completely loaded in order to reduce blank rectangle time?
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.
Please get review/approval from Yuxuan (she can merge) and ensure related changes with adsbygoogle are in production.
(!config && ( | ||
!impl.ignoreLoadEndForAmpStickyAd || | ||
!impl.ignoreLoadEndForAmpStickyAd()))) { | ||
promises.push(signals.whenSignal(CommonSignals.LOAD_END)); |
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.
Supposedly LOAD_END
event should come after RENDER_START
. Is it not the case?
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.
load end was firing from the remote.html frame even though the ad inside wasn't actually there yet, so we need to block on render start instead, to verify the ad actually exists before we show the sticky container.
extensions/amp-a4a/0.1/amp-a4a.js
Outdated
* to trigger showing the sticky-ad container. | ||
* @return {boolean} | ||
*/ | ||
ignoreLoadEndSignalForAmpStickyAd() { |
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.
I didn't see the function being used? Am I missing anything?
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.
whoops sorry removed.
I felt sending 'no-content' signal is the right answer here. Are we having a race condition where iframe onload event fired before 'no-content'. In any case, I think we should fix the issue on the ad level, not at the sticky-ad level. |
My description wasn't thorough enough. We are not just concerned with a no-fill case, but also the fact that the sticky ad container shows before the ad is rendered when there is a filled ad. So the only way to handle this is to modify amp sticky ad to wait to show until it's received a message that the ad is rendered. If we instead wait for a no-content message, then we will show an empty sticky ad container which will then suddenly disappear. |
@bradfrizzell Thank you for the explanation. I found this line of code to be related
I think the race condition here is really the I still don't like the idea of having amp-sticky-ad change its behavior based on its child. What about we have ads send a |
I am fine with getting rid of blocking on the load-end message entirely, but just want to raise the following concern. If an ad network wants to work with amp sticky ad, is it ok to require that implement the render-start message? Because as it is right now, my understanding is that the sticky ad will work with any ad tag loaded inside it, as the sticky container shows based on the browser load event firing on the ad frame, whereas render-start is a new api the network would have to add. What do you think? |
Ping :) |
Looking at the code again, here's one thing that I think it's unclear to me. amphtml/extensions/amp-ad/0.1/amp-ad-xorigin-iframe-handler.js Lines 260 to 268 in 9b8a19b
@dvoytenko Do you recall that why we want to toggle visibility at iframe onload? I vaguely remember that you ran some experiment and iframe onload always arrives after render-start? |
That's a good point. We definitely want to support all ad networks, even if they don't implement renderStart API. Currently we have a few signals. 1. render-start 2. iframe on load 3. visibility timeout 4.no-content (mutual exclusive of render-start) At this change we want to display sticky-ad at 1 (if render-start is supported), 2 (if render-start not supported). I think that makes perfect sense. But it leads to different behavior between sticky-ad and regular ad. I am leaning towards changing the behavior or regular ad. Can we apply the same behavior to regular ad as well? |
is that change something that we'd need to block this PR on? It seems like that would be a larger scope than what I'm doing here. The change I made to the promise race is contained within amp-sticky-ad at this time. |
@zhouyx ping on above |
Synced with the team on this. + @lannka
Today the @bradfrizzell In this way, we don't need to call TODO to @zhouyx: Add more detailed comments to common signals, so that we don't need to review them from start again next time. |
@zhouyx done, please take another look |
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.
Because we remove LOAD_END
here, we want to make sure that all visible ad has signaled RENDER_START
. Can we ensure that renderViaNameAttrOfXOriginIframe_
, renderViaIframeGet_
and renderAmpCreative_
, the three rendering methods have all signaled RENDER_START
?
I took a quick look at the amp-a4a.js
code. Here's what I found, please confirm
#
renderAmpCreative_calls
installFriendlyIframeEmbedwhere FIE always signals
RENDER_START
renderViaNameAttrOfXOriginIframe_and
renderViaIframeGet_both use the
AmpAdXOriginIframeHandlerwhich always signals
RENDER_START` after changes from #22305
Agree that renderViaNameAttr calls renderStart, as it uses iframeRenderHelper which then uses XOriginIframeHandler So yes I agree your assessment looks correct to me, render-start will be called in all cases. |
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.
One more request. Please help me understand why we need both the config change for delayed fetch and also adding support to fast fetch.
I think the PR is good to go after #22305 is merged.
FYI: #22305 is merged. Please let me know when the PR is ready. Thank you |
@bradfrizzell Any update on the PR. Thanks |
@zhouyx hey sorry this fell off my plate with some higher priority stuff. going to try to finish this up today / tomorrow |
examples/adsense_sticky.amp.html
Outdated
</amp-sticky-ad> | ||
|
||
|
||
<!-- |
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.
nit: Please remove.
examples/adsense_sticky.amp.html
Outdated
<h2>AdSense</h2> | ||
|
||
|
||
<!-- <amp-sticky-ad layout="nodisplay"> |
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.
nit: remove
examples/adsense_sticky.amp.html
Outdated
</head> | ||
<body> | ||
|
||
<amp-user-notification |
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.
nit: no need
examples/adsense_sticky.amp.html
Outdated
@@ -0,0 +1,118 @@ | |||
<!doctype html> |
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.
Do we need this new example file. Is it possible to move it to adsense.amp.html instead? Thank you
event['source'] == this.iframe.contentWindow | ||
) { | ||
this.renderStarted(); | ||
this.element.parentElement.setAttribute('visible', ''); |
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.
I don't think you need to toggle visibility here. AMP sticky ad when it received render-start signal will toggle visibility. this.renderStarted()
should have done the work.
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.
done
extensions/amp-a4a/0.1/amp-a4a.js
Outdated
* @return {!Promise} awaiting load event for ad frame | ||
* @private | ||
*/ | ||
iframeRenderHelper_(attributes) { | ||
iframeRenderHelper_(attributes, letCreativeTriggerRenderStart) { |
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.
Do we need to pass in letCreativeTriggerRenderStart
? I think we can call this.letCreativeTriggerRenderStart()
instead.
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.
good call, fixed
extensions/amp-a4a/0.1/amp-a4a.js
Outdated
return this.iframeRenderHelper_(dict({'src': srcPath, 'name': name})); | ||
return this.iframeRenderHelper_( | ||
dict({'src': srcPath, 'name': name}), | ||
false |
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.
I'm a bit confused why we need to set the letCreativeTriggerRenderStart
value specifically to false
here?
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.
fixed
event['source'] == this.iframe.contentWindow | ||
) { | ||
this.renderStarted(); | ||
this.element.setAttribute('visible', ''); |
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.
One last request: we set iframe visibility to hidden here
https://github.com/ampproject/amphtml/blob/master/extensions/amp-ad/0.1/amp-ad-xorigin-iframe-handler.js#L278
Should also set iframe visibility instead of element visibility.
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.
done
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.
LGTM
…lemented. (ampproject#21157) * Modify amp sticky ad to only wait on render-start if render-start implemented. * Remove console log * Cleanup * Make it work for iframe get rendering canonical amp adsense * Respond to feedback * Remove all reliance on LOAD_END event * Update test * Fix syntax * Respond to feedback * respond to feedback * Fix getData * Add tests, respond to comment
If render start is supported for a given network, then amp sticky ad should wait only on render-start, not render-start OR load_end.
Also, enable render-start for adsense.
This fixes a bug where Adsense sticky ads on canonical amp running delayed fetch could show a sticky ad for a no-fill.