Heart of bugs

We use third-party tools to analyze and capture Mach signals or Unix signals to get crash information, but sometimes when we look at the exact crash location, the line of code doesn’t seem to be able to find the problem.

Such as:

The crash cannot be repeated, so we have to try to solve the problem and explore possible steps;

The problem could go away and crash rates stay high.

Is there a way to record what the user did for reproduction? Can you record the scene? The answer is yes.

So I spent a day writing this tool: KillBug Welcome star✨

Bugtags also has KillBug functionality. We’ve used it before and managed to reduce the crash rate to one in 100,000. User interaction logs help.

This tool is used to collect user steps:

  • 1, can be used for bug recurrence, problem investigation, monitoring :iOS to reduce the crash rate to less than 1/10,000 secret
  • 2. Analyze user operation logs

Runtime Method Swizzle is adopted. In order not to affect the startup speed of app, Method Swizzle needs to be manually started.

Support Swift, OC and mixed programming projects.

The following information can be collected:

/// UIControl - (void)trackEventView:(UIView *)view; /// tableview&collectionview - (void)trackEventView:(UIView *)view withIndexPath:(nullable NSIndexPath *)indexPath; /// viewWillAppear - (void)trackViewWillAppear:(UIViewController *)controller; // uiapplication active state - (void)trackApplication:(NSString *)state; / / / uiapplication death information - (void) trackApplicationDeadReason (nsstrings *) "reason; - (void)trackTouch:(NSString *)info; /// log callback - (void)debugInfoHandler:(debugInfoHandler)handler;Copy the code

use

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    KBAutoTrackManager *manager = [KBAutoTrackManager shared];
    [manager debugInfoHandler:^(NSString * _Nonnull info) {
        NSLog(@"%@", info);
        /// Custom 
    }];
    return YES;
}

Copy the code

kill bug

Work with Firebase

/ / / asynchronous deferred processing, to avoid affect the first screen loading speed DispatchQueue. Main. AsyncAfter (deadline: . Now () + 3) {KBAutoTrackManager. Shared () debugInfoHandler {(info) in / / / to Crashlytics debug (info) Crashlytics.crashlytics().log(info) } }Copy the code

This allows Firebase to collect user interaction logs while catching crashes:

Firebase looks like this:

With stack information, I ask what bugs can’t be fixed?

If it is sent to your own server, you have to deal with the collected crash logs yourself.

The log log

2021-03-30 11:20:53.215736+0800 KillBug_Example[962:142129] will appear: KBViewController 2021-03-30 11:20:53.265620+0800 KillBug_Example[962:142129] app State: 2021-03-30 11:20:54.720428+0800 KillBug_Example[962:142129] touch: KillBug_Example Click position x:245.333328 Y :629.333328 2021-03-30 11:20:54.761609+0800 KillBug_Example[962:142129] will appear: KBViewControllerA 2021-03-30 11:20:59.767387+0800 KillBug_Example[962:142129] touch: Click position x:138.333328 Y :35.333328 2021-03-30 11:20:59.767880+0800 KillBug_Example[962:142129] touch Click position x:138.333328 Y :35.333328 2021-03-30 11:20:59.776511+0800 KillBug_Example[962:142129] click: UITableView row 4 Section :0 2021-03-30 11:21:06.493889+0800 KillBug_Example[962:142129] touch: Click position x:261.000000 Y :645.333328 2021-03-30 11:21:09.982150+0800 KillBug_Example[962:142129] click: UIButton TXT :ButtonA 2021-03-30 11:21:14.463084+0800 KillBug_Example[962:142129] click: UIButton TXT: KillBug_Example[962:142129] app State: KillBug_Example[962:142129] 2021-03-30 11:21:18.677035+0800 KillBug_Example[962:142129] app state: KillBug_Example[962:142129] 2021-03-30 11:21:23.629401+0800 KillBug_Example[962:142129] app state: KillBug_Example[962:142129] 2021-03-30 11:21:23.954509+0800 KillBug_Example[962:142129] app state: 2021-03-30 11:21:25.641821+0800 KillBug_Example[962:142129] click: KillBug_Example 2021-03-30 11:21:25.643086+0800 KillBug_Example[962:142129] app Crash: {"appException" : { "exceptionreason" : "*** -[__NSSingleObjectArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]", "exceptionname" : "NSRangeException" } }Copy the code

You can also upload it to your own server.

Support pod

pod 'KillBug'
Copy the code

The Runtime section has a detailed comment, welcome to submit an issue!

KillBug Welcome to star✨ oh