Skip to content

Commit

Permalink
Merge pull request #696 in MOBILE-SDK/app_mobile-sdk-ios from github_…
Browse files Browse the repository at this point in the history
…sync_blank_ads to master

* commit '9343f6fb457ccd8e54f4d3a7c872565463dfe3af':
  Fix data race where ads load blank occasionally (#61)
  • Loading branch information
Kowshickkarthick Subramanian committed Mar 24, 2021
2 parents 3f436e8 + 9343f6f commit f14ccbd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sdk/sourcefiles/internal/ANAdWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ @interface ANAdWebViewController () <WKNavigationDelegate, WKUIDelegate, WKScrip
@property (nonatomic, readwrite, strong) ANWebView *webView;
@property (nonatomic, readwrite, assign) BOOL isMRAID;
@property (nonatomic, readwrite, assign) BOOL completedFirstLoad;
@property (nonatomic, readwrite, strong) WKNavigation *firstNavigation;

@property (nonatomic, readwrite, strong) NSTimer *viewabilityTimer;
@property (nonatomic, readwrite, assign, getter=isViewable) BOOL viewable;
Expand Down Expand Up @@ -170,7 +171,7 @@ - (instancetype)initWithSize:(CGSize)size
if (!strongSelf) {
return;
}
[strongSelf.webView loadHTMLString:htmlToLoad baseURL:base];
strongSelf.firstNavigation = [strongSelf.webView loadHTMLString:htmlToLoad baseURL:base];
});
});

Expand Down Expand Up @@ -314,7 +315,9 @@ -(void) webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation

- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
{
[self processWebViewDidFinishLoad];
if (navigation == self.firstNavigation) {
[self processWebViewDidFinishLoad];
}
}

- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error {
Expand Down Expand Up @@ -526,6 +529,7 @@ - (void)processWebViewDidFinishLoad
if (!self.completedFirstLoad)
{
self.completedFirstLoad = YES;
self.firstNavigation = nil;
// If it is VAST ad then donot call didCompleteFirstLoadFromWebViewController videoAdReady will call it later.
if ([self.videoXML length] > 0)
{
Expand Down

0 comments on commit f14ccbd

Please sign in to comment.