title: CoreAnimation:[EAGLContext renderbufferStorage:fromDrawable:] was called from a non-main thread
body: <p>In my Music Application When I am trying to show Ad (I'm using Triton SDK), Sometimes App is crashing and giving me this error:</p>
  
  <p><strong>CoreAnimation: [EAGLContext renderbufferStorage:fromDrawable:] was called from a non-main thread in an implicit transaction! Note that this may be unsafe without an explicit CATransaction or a call to [CATransaction flush].</strong></p>
  
  <p>My Ads contain both Banner and Audio MP3, Please anyone help me out.</p>
  
  <p>Here is the streaming song code, Which is called continuously:-</p>
  
  <pre><code>- (void) configureAudioStremaing {
  
  if ([Singletone sharedSingletone].playMusic == NO) {
  
  
  
      NSError *setCategoryError = nil;
  
      NSError *activationError = nil;
  
      [[AVAudioSession sharedInstance] setActive:YES withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&amp;activationError];
  
  
  
      [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:&amp;setCategoryError];
  
      [app beginReceivingRemoteControlEvents];
  
  
  
  }
  
  
  
  else {
  
  
  
      NSError *setCategoryError = nil;
  
      NSError *activationError = nil;
  
  
      [[AVAudioSession sharedInstance] setActive:NO withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&amp;activationError];
  
      [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:&amp;setCategoryError];
  
          [app beginReceivingRemoteControlEvents];
  
  
  }
  </code></pre>
  
  <p>And this following function has been called when Ad is showing All function called in main thread only still I am getting crash issue sometimes:-</p>
  
  <pre><code>//for banner view
  
  
  
  - (void) showAdbanner {
  
  
  
  [Singletone sharedSingletone].impressionUrlCalled = NO;
  
  [[Singletone sharedSingletone].bannerView removeFromSuperview];
  
  
  
  BOOL adFrameFound = NO;
  
  
  
  for (int i = 0; i &lt; [[Singletone sharedSingletone].ad.companionBanners count]; i++) {
  
  
  
      TDCompanionBanner *banner = [[Singletone sharedSingletone].ad.companionBanners objectAtIndex:i];
  
  
  
      if (banner.width == 300 &amp;&amp; banner.height == 250) {
  
          [Singletone sharedSingletone].bannerView = [[TDBannerView alloc] initWithWidth:banner.width andHeight:banner.height];
  
          adFrameFound = YES;
  
          break;
  
      }
  
  }
  
  
  
  if (adFrameFound == NO) {
  
      [Singletone sharedSingletone].bannerView = [[TDBannerView alloc] initWithWidth:300 andHeight:250];
  
  }
  
  
  
  if (songProgressView!=nil) {
  
      [Singletone sharedSingletone].bannerView.translatesAutoresizingMaskIntoConstraints = NO;
  
      [Singletone sharedSingletone].bannerView.backgroundColor = [blackColor colorWithAlphaComponent:0.5];
  
      [self.view addSubview:[Singletone sharedSingletone].bannerView];
  
  
  
      [self.view addConstraint:[NSLayoutConstraint constraintWithItem:[Singletone sharedSingletone].bannerView
  
                                                            attribute:NSLayoutAttributeTop
  
                                                            relatedBy:NSLayoutRelationEqual
  
                                                            toItem:songProgressView
  
                                                            attribute:NSLayoutAttributeBottom
  
                                                           multiplier:1.0 constant:0.0]];
  
  
  
      [self.view addConstraint:[NSLayoutConstraint constraintWithItem:[Singletone sharedSingletone].bannerView
  
                                                            attribute:NSLayoutAttributeCenterX
  
                                                            relatedBy:NSLayoutRelationEqual
  
                                                               toItem:self.view
  
                                                            attribute:NSLayoutAttributeCenterX
  
                                                           multiplier:1.0 constant:0.0]];
  
      [[Singletone sharedSingletone].bannerView presentAd:[Singletone sharedSingletone].ad];
  
      }
  </code></pre>
  
  <p>}</p>
  
  <p>I am getting this report from crashlystics:</p>
  
  <p><a href="http://prntscr.com/kbl58s" rel="nofollow noreferrer">http://prntscr.com/kbl58s</a></p>