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

Impossibility to close a vast without end card (under certain conditions) #808

Closed
jovencinho opened this issue Mar 15, 2023 · 0 comments · Fixed by #810
Closed

Impossibility to close a vast without end card (under certain conditions) #808

jovencinho opened this issue Mar 15, 2023 · 0 comments · Fixed by #810

Comments

@jovencinho
Copy link
Contributor

Describe the bug
There are some Vast creatives that when they finish playing, a black screen is shown and they cannot be closed (because the close button does not appear).
The problem is that in this method when creating the companion, it could become nil and later, the creative model asks for hasCompanionAd, but it does not have more creatives to show.

if (companionItems.count > 0) {
// There is at least 1 companion. Set the flag so that when the initial video creative has completed
// display, the appropriate view controllers will prevent the "close" button and the learn more after the video has
// finished, it will instead display the endcard.
creativeModel.hasCompanionAd = YES;
// Now try to create the companion items creatives.
// Create a model of the best fitting companion ad.
PBMCreativeModel *creativeModelCompanion = [self createCompanionCreativeModelWithAd:vastAd
companionAds:companionItems
creative:creative];
if (creativeModelCompanion) {
[creatives addObject:creativeModelCompanion];
}
}

To Reproduce
You can use any VAST creative that does not have an end card (e.g. https://prebid-mobile-ad-assets.s3.amazonaws.com/scripts/vasts/vast.xml) and add an empty ad companion creative to it.

<Creative>
    <CompanionAds>
    </CompanionAds>
</Creative>

This is not the only way, any VAST configuration that causes it to return nil in this method would also pass

- (PBMCreativeModel *)createCompanionCreativeModelWithAd:(PBMVastInlineAd *)vastAd
companionAds:(NSArray<PBMVastCreativeCompanionAds *>*)companionAds
creative:(PBMVastCreativeLinear *)creative {
if ((companionAds == nil) || (creative == nil)) {
return nil;
}
if (companionAds.count == 0) {
return nil;
}
PBMCreativeModel *creativeModel = [[PBMCreativeModel alloc] initWithAdConfiguration:self.adConfiguration];
creativeModel.eventTracker = [[PBMAdModelEventTracker alloc] initWithCreativeModel:creativeModel serverConnection:self.serverConnection];
creativeModel.verificationParameters = vastAd.verificationParameters;
PBMVastCreativeCompanionAds* companionAd = [companionAds firstObject];
if (companionAd.companions.count == 0) {
return nil;
}
// get the most appropriate companion from the list.
PBMVastCreativeCompanionAdsCompanion* companion = [self getMostAppropriateCompanion: companionAd];
if (companion == nil) {
return nil;
}
NSString* resource;
switch (companion.resourceType) {
case PBMVastResourceTypeStaticResource:
// image. build html around resource
resource = [self buildStaticResource:companion];
break;
case PBMVastResourceTypeIFrameResource:
resource = companion.resource;
break;
case PBMVastResourceTypeHtmlResource:
resource = companion.resource;
break;
default:
// unrecognized companion type.
return nil;
}
if (!resource) {
return nil;
}
creativeModel.html = resource;
creativeModel.width = companion.width;
creativeModel.height = companion.height;
creativeModel.clickThroughURL = companion.clickThroughURI;
// Store the impression URIs so that can be fired at the appropriate time.
NSMutableDictionary *trackingURLs = [companion.trackingEvents.trackingEvents mutableCopy];
NSString *companionClickKey = [PBMTrackingEventDescription getDescription:PBMTrackingEventCompanionClick];
NSMutableArray *trackingArray = trackingURLs[companionClickKey];
// Create a companion array if it doesn't already exist.
if (trackingURLs[companionClickKey] == nil) {
trackingArray = [NSMutableArray new];
}
// Save the the tracking urls in the array.
trackingURLs[companionClickKey] = [trackingArray arrayByAddingObjectsFromArray:companion.clickTrackingURIs];
NSString *clickKey = [PBMTrackingEventDescription getDescription:PBMTrackingEventClick];
trackingURLs[clickKey] = companion.clickTrackingURIs;
creativeModel.trackingURLs = trackingURLs;
// tag this creative model as an end card.
creativeModel.isCompanionAd = YES;
return creativeModel;
}

Solution
Change to true hasCompanionAd only if a not nil companion was obtained.

    if (companionItems.count > 0) {
        // Now try to create the companion items creatives.
        // Create a model of the best fitting companion ad.
        PBMCreativeModel *creativeModelCompanion = [self createCompanionCreativeModelWithAd:vastAd
                                                                               companionAds:companionItems
                                                                                   creative:creative];
        if (creativeModelCompanion) {
            // There is at least 1 companion.  Set the flag so that when the initial video creative has completed
            // display, the appropriate view controllers will prevent the "close" button and the learn more after the video has
            // finished, it will instead display the endcard.
            creativeModel.hasCompanionAd = YES;
            [creatives addObject:creativeModelCompanion];
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant