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

Video Outstream: prebid,js Error in Example #10944

Open
richmadriz opened this issue Jan 15, 2024 · 4 comments
Open

Video Outstream: prebid,js Error in Example #10944

richmadriz opened this issue Jan 15, 2024 · 4 comments

Comments

@richmadriz
Copy link

Error in Example outstream no server, https://docs.prebid.org/examples/video/outstream/pb-ve-outstream-no-server.html
We are working trying to separate this example but it has an error which happens to us in the same way in our demo.
ms: Error rendering ad (id: 31f3cda2d27635): renderAd was prevented from writing to the main document.

Imagen de WhatsApp 2024-01-15 a las 09 00 07_2a076f96

@patmmccann patmmccann changed the title prebid,js Error in Example Video Outstream: prebid,js Error in Example Jan 16, 2024
@patmmccann patmmccann added the bug label Jan 16, 2024
@jarrettabello
Copy link

jarrettabello commented Jan 18, 2024

I took at look at this test page and found a few issues. I believe our test code example needs to be reworked here. We are using document in the renderAd function and we need to specify an element as an ad container.

By updating the test page with an ad container to inject the ad into the error resolves.
image

Also worth noting that the script tag that contains the prebid configuration on the page is a script tag with text/plain <script type="text/plain" class="optanon-category-C0003"> -- that should be updated to text/javascript

<script type="text/javascript" class="optanon-category-C0003">
	    var pbjs = pbjs || {};
	    pbjs.que = pbjs.que || [];
	    var adUnits = [{
	        code: 'video1',
	        mediaTypes: {
	            video: {
	                context: 'outstream',
			playerSize: [640, 480],
			mimes: ['video/mp4'],
			protocols: [1, 2, 3, 4, 5, 6, 7, 8],
			playbackmethod: [2],
			skip: 1
	            }
	        },
	        bids: [{
	            bidder: 'appnexus',
	            params: {
	                placementId: 13232385
	            }
	        }]
        }];

        pbjs.que.push(function() {
            pbjs.addAdUnits(adUnits);
            pbjs.requestBids({
                timeout: 1000,
                bidsBackHandler: function(bids) {
                    var highestCpmBids = pbjs.getHighestCpmBids('video1');
                    pbjs.renderAd(document.getElementById('myad'), highestCpmBids[0].adId);
                }
            });
        });
    </script>

@richmadriz
Copy link
Author

I tried this already by obtaining a div apart from video1 and obtaining the video1 Id tag itself but it does not work with any div that is in the document either,

<script> var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; function callANRenderer(bid, ad) { const adResponse = { ad: { video: { content: ad, player_width: 640, player_height: 480, } } } bid.renderer.push(() => { window.ANOutstreamVideo.renderAd({ targetId: bid.adUnitCode, adResponse, }); }); } function render(bid) { let ad = bid.ad || bid.vastXml; if (ad) { callANRenderer(bid, ad) } else { if (bid.vastUrl) { (async() => { ad = await fetch(resp).then(resp => resp.text()); if (typeof ad === 'string') { callANRenderer(bid, ad); } else { console.log('Invalid VAST'); } })(); } else { console.log('Invalid ad'); } } } const adUnits = [{ code: 'video1', mediaTypes: { video: { context: 'outstream', playerSize: [ [640, 480] ], mimes: ['video/mp4'], protocols: [1, 2, 3, 4, 5, 6, 7, 8], api: [2], linearity: 1, playbackmethod: [2], skip: 1, renderer: { render, url: "https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js" }, maxduration: 30 } }, bids: [{ bidder: 'appnexus', params: { placementId: 31776638 } }] }]; pbjs.que.push(function() { pbjs.addAdUnits(adUnits); pbjs.setConfig({ debug: true, cache: { url: 'https://prebid.adnxs.com/pbc/v1/cache' } }); pbjs.requestBids({ timeout: 1000, bidsBackHandler: function(bids) { const highestCpmBids = pbjs.getHighestCpmBids('video1'); pbjs.renderAd(document.getElementById('myad'), highestCpmBids[0].adId); } }); }); </script>

and this in the BODY

<div id="video1"></div>
<div id="myad"></div>

@patmmccann patmmccann assigned ChrisHuie and unassigned fowler446 Jul 2, 2024
@dgirardi
Copy link
Collaborator

Related to prebid/prebid.github.io#5400

@dgirardi
Copy link
Collaborator

Also related: prebid/prebid.github.io#5248

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Tracking
Development

No branches or pull requests

7 participants