【发布时间】:2018-07-26 11:53:30
【问题描述】:
在我的音乐应用程序中当我尝试显示广告时(我正在使用 Triton SDK),有时应用程序会崩溃并给我这个错误:
CoreAnimation:[EAGLContext renderbufferStorage:fromDrawable:] 在隐式事务中从非主线程调用!请注意,如果没有明确的 CATransaction 或调用 [CATransaction flush],这可能是不安全的。
我的广告包含横幅和音频 MP3,请任何人帮助我。
这里是流歌代码,连续调用:-
- (void) configureAudioStremaing {
if ([Singletone sharedSingletone].playMusic == NO) {
NSError *setCategoryError = nil;
NSError *activationError = nil;
[[AVAudioSession sharedInstance] setActive:YES withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&activationError];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:&setCategoryError];
[app beginReceivingRemoteControlEvents];
}
else {
NSError *setCategoryError = nil;
NSError *activationError = nil;
[[AVAudioSession sharedInstance] setActive:NO withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&activationError];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:&setCategoryError];
[app beginReceivingRemoteControlEvents];
}
当广告显示所有在主线程中调用的函数时,已经调用了以下函数,但有时我仍然遇到崩溃问题:-
//for banner view
- (void) showAdbanner {
[Singletone sharedSingletone].impressionUrlCalled = NO;
[[Singletone sharedSingletone].bannerView removeFromSuperview];
BOOL adFrameFound = NO;
for (int i = 0; i < [[Singletone sharedSingletone].ad.companionBanners count]; i++) {
TDCompanionBanner *banner = [[Singletone sharedSingletone].ad.companionBanners objectAtIndex:i];
if (banner.width == 300 && 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];
}
}
我从 crashlytics 得到这份报告:
【问题讨论】:
-
请添加代码
标签: ios objective-c uiwebview