BuglyConfig 中的 buildConfig),配置开发任务、灰度任务、以及正式任务。开发任务打开所有的监控项,灰度阶段按需采样,正式发布根据需要降低采样。// 模拟 OC 异常id data = [NSArray arrayWithObject:@"Hello World"];[(NSDictionary *)data objectForKey:@""];// 模拟信号异常abort();// 模拟 C++异常throw "Something went wrong";
// 模拟ANRwhile(YES){;}
- (void)foomButtonClicked {self.timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(timerFired) userInfo:nil repeats:YES];}- (void)timerFired {CGSize size = CGSizeMake(1024 , 1024);const size_t bitsPerComponent = 8;const size_t bytesPerRow = size.width * 4;CGContextRef ctx = CGBitmapContextCreate(calloc(sizeof(unsigned char), bytesPerRow * size.height), size.width, size.height,bitsPerComponent, bytesPerRow,CGColorSpaceCreateDeviceRGB(),kCGImageAlphaPremultipliedLast);CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0);CGContextFillRect(ctx, CGRectMake(0, 0, size.width, size.height));}
BuglyCrashMonitorPlugin.h 中的 reportException:、reportError:或 reportExceptionWithCategory:name:reason:callStack:extraInfo:terminateApp:来上报(详细参考其他接口/上报自定义异常部分)。- (void)userDefinedCrash {NSError *error = [NSError errorWithDomain:@"Error Test" code:-2 userInfo:nil];[BuglyCrashMonitorPlugin reportError:error];}
- (void)userDefinedCrash {@try {NSString *value = @"This is a string";[NSException raise:@"TurboEncabulatorException"format:@"Spurving bearing failure: Barescent skor motion non-sinusoidal for %p", value];} @catch (NSException *exception) {[BuglyCrashMonitorPlugin reportException:exception];}}
NSArray * arr = [NSThread callStackSymbols];[BuglyCrashMonitorPlugin reportExceptionWithCategory:3 name:@"reportTest" reason:@"test" callStack:arr extraInfo:[NSDictionary dictionary] terminateApp:false];
reportExceptionWithCategory:name:reason:callStack:extraInfo:terminateApp:的参数中,callStack 设置的出错堆栈,extraInfo 展示在附件中。[BuglyLaunchMonitorPlugin endColdLaunch]接口自定义启动结束点,也支持自定义标签以及通过打点接口,监控启动过程中的耗时任务。如需了解更多关于启动接口的使用,请参见 API 说明-启动监控 部分。[BuglyLaunchMonitorPlugin startSpan:@"parentSpan" parentSpanName:nil];[BuglyLaunchMonitorPlugin startSpan:@"spanTest" parentSpanName:@"parentSpan"];dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{[BuglyLaunchMonitorPlugin endSpan:@"spanTest"];[BuglyLaunchMonitorPlugin endSpanFromLaunch:@"spanFromLaunch"];});dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{[BuglyLaunchMonitorPlugin endSpan:@"parentSpan"];});[BuglyLaunchMonitorPlugin addTag:@"tagTest1"];[BuglyLaunchMonitorPlugin addTag:@"tagTest2"];
"looper.fluency")的情况下,SDK 会在初始化完成后,监控应用的流畅度情况。在应用运行一次的期间,会先收集数据,保存至本地,下次启动时再聚合上报。为了避免影响应用的启动,SDK 会在初始化5分钟后,再将缓存的数据聚合上报后台。"looper.hitches")后,在 UI 线程执行耗时逻辑,耗时超过500ms的情况下,会触发卡顿上报。卡顿监控通过监控 UI 线程的消息执行来判断当前 UI 线程是否发生卡顿。"event_sample_ratio"(消息采样率)以及"sample_ratio"(设备采样率)都设置为1。这样只要满足卡顿的耗时阈值,即可触发卡顿上报。- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"defaultcell"];cell.textLabel.text = [self.dataList objectAtIndex:indexPath.row];cell.textLabel.font = [UIFont systemFontOfSize:80];BOOL hitch = arc4random() % 5;if (hitch) {[NSThread sleepForTimeInterval:0.02];}return cell;}
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"RMVCLeakExample"bundle:[NSBundle mainBundle]];UIViewController * subVC = [storyboard instantiateViewControllerWithIdentifier:@"rm.vcleak.subvc"];[self.navigationController pushViewController:subVC animated:YES];self.holdVC = subVC;
文档反馈