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

SafeFrames don't resize #66

Closed
benjaminclot opened this issue Jul 2, 2019 · 4 comments
Closed

SafeFrames don't resize #66

benjaminclot opened this issue Jul 2, 2019 · 4 comments

Comments

@benjaminclot
Copy link

benjaminclot commented Jul 2, 2019

Describe the bug
When using SafeFrames, the GPT iFrame doesn't resize correctly and stays at 1x1.

To Reproduce
Steps to reproduce the behavior:

  1. Take this example: http://prebid.org/dev-docs/examples/adunit-refresh.html (which, by the way, needs some updating to work)
  2. Enable SafeFrames
  3. Refresh the ad (I also enabled a first call and debug mode)
    Demo: https://adverline-gam.glitch.me/tests/safeframe.html

Expected behavior
The GPT SafeFrame should resize to match its content ad. Obviously, this problem doesn't occur with AdSense/AdX ads, which are also enabled. Some refreshes may be needed to have header bidding winning the auction.

Desktop/Smartphone

  • OS: any
  • Browser: any
  • Version: any

Strangely
Some header bidding ads seem to work (very rare).

Temporary fix
Will cause bugs eventually.

pbjs.onEvent('bidWon', (bid) => {
  if (bid.mediaType === 'banner') {
    const slot = window.googletag.pubads().getSlots()
      .find(s => s.getSlotElementId() == bid.adUnitCode);
    const safeFrame = document.querySelector(`#google_ads_iframe_${slot.getSlotId().getId().replace(/(\.|\/)/g, '\\$1')}[data-is-safeframe="true"]`);

    if (safeFrame) {
      safeFrame.style.height = `${bid.height}px`;
      safeFrame.style.width = `${bid.width}px`;
    }
  }
});
@benjaminclot
Copy link
Author

ping @jaiminpanchal27 @jsnellbaker @idettman @mkendall07

Can anybody comment on this? This is a critical bug at it effectively blocks the usage of SafeFrames (at least with GAM).

@benjaminclot
Copy link
Author

Any input on this issue would be most welcome.

@jaiminpanchal27
Copy link
Collaborator

@benjaminclot Thanks for submitting the issue. I was able to reproduce the issue with the steps you shared. Basically Prebid's resize function isn't working as it should. I will put up a PR today.

@benjaminclot
Copy link
Author

Fixed by this PR: prebid/Prebid.js#3988

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

No branches or pull requests

2 participants