找不到崩溃原因

Can't find cause of crash

本文关键字:崩溃 找不到      更新时间:2023-10-16

我正试图将RedLaser SDK添加到我的项目中,当试图打开PickerController时,我在以下位置遇到错误:

0x39b70538: push {r4, r5, r6, r7, lr}

这是我实例化PickerController:的代码

- (IBAction) redBoxScanButtonPressed
{
    RLSampleViewControllerRequestVideoAuthorization(^void (void) {
        RedBoxPickerController *redBoxPickerController =
        [[RedBoxPickerController alloc] initWithNibName:@"RedBoxPickerController" bundle:nil];
        redBoxPickerController.delegate = self;
        // hide the status bar and show the scanner view
        [[UIApplication sharedApplication] setStatusBarHidden:YES];
        [self presentViewController:redBoxPickerController animated:NO completion:nil];// presentModalViewController:redBoxPickerController animated:FALSE];
        //[redBoxPickerController release];
    });
}

请求授权的方法:

static void RLSampleViewControllerRequestVideoAuthorization(dispatch_block_t completionHandler) {
    RL_RequestVideoAuthorization(^void (RL_VideoAuthorizationStatus status) {
        if (status == RL_VideoAuthorizationStatusAuthorized) {
            dispatch_async(dispatch_get_main_queue(), ^void (void) {
                completionHandler();
            });
        }
    });
}

回溯

(lldb) bt
* thread #11: tid = 0xc81db, 0x39b70538 libc++abi.dylib`__cxa_throw, queue = 'ZXing', stop reason = breakpoint 1.2   * frame #0: 0x39b70538 libc++abi.dylib`__cxa_throw
    frame #1: 0x00187e32 IRON TRAINERS`zxing::GlobalHistogramBinarizer::estimate(std::vector<int, std::allocator<int> >&) + 370
    frame #2: 0x00187f60 IRON TRAINERS`zxing::GlobalHistogramBinarizer::getBlackMatrix() + 268
    frame #3: 0x00186580 IRON TRAINERS`zxing::BinaryBitmap::getBlackMatrix() + 12
    frame #4: 0x001a9b00 IRON TRAINERS`zxing::qrcode::QRCodeReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 44
    frame #5: 0x001b086e IRON TRAINERS`zxing::Reader::decode(zxing::Ref<zxing::BinaryBitmap>) + 278
    frame #6: 0x001b4a86 IRON TRAINERS`-[FormatReader decode:] + 142
    frame #7: 0x00185da8 IRON TRAINERS`-[ZXingDecoder findCodesInBitmap:bytesPerRow:width:height:] + 796
    frame #8: 0x001ba93e IRON TRAINERS`-[BarcodePhotoEngine zxingFindBarcodesInPixmap:] + 226
    frame #9: 0x001b318c IRON TRAINERS`__38-[BarcodeEngine findBarcodesInPixMap:]_block_invoke55 + 76
    frame #10: 0x0081e172 libdispatch.dylib`_dispatch_call_block_and_release + 10
    frame #11: 0x00826d66 libdispatch.dylib`_dispatch_queue_drain + 1718
    frame #12: 0x00820a60 libdispatch.dylib`_dispatch_queue_invoke + 88
    frame #13: 0x00828b08 libdispatch.dylib`_dispatch_root_queue_drain + 1308
    frame #14: 0x00829e18 libdispatch.dylib`_dispatch_worker_thread3 + 100
    frame #15: 0x3a91adc0 libsystem_pthread.dylib`_pthread_wqthread + 668 (lldb)

我不知道该找什么,我试着添加了一些breakpoints,但没有发现问题。

示例项目运行良好,所以我想我缺少了一些代码。

以下是PickerController:的完整代码

/*******************************************************************************
    RedBoxPickerController.m
    Part of RLSample
    This is a scan overlay example that frames discovered barcodes with red boxes.
    Chall Fry
    November 2012
    Copyright (c) 2012 eBay Inc. All rights reserved.   
*/
#import "RedBoxPickerController.h"

@implementation RedBoxPickerController
/*******************************************************************************
    didReceiveMemoryWarning
*/
- (void) didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
/*******************************************************************************
    viewWillAppear:
    Sets up the initial state of UI elements in the overlay.
*/
- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    inRangeLabel.hidden = true;
    numBarcodesFoundLabel.text = @"";
    torchButton.enabled = self.hasTorch;
    torchButton.style = self.isTorchOn ?  UIBarButtonItemStyleDone :
            UIBarButtonItemStyleBordered;
}
#pragma mark Button Handlers
/*******************************************************************************
    cancelScan
    Action proc for the 'Done' button.
*/
- (IBAction) cancelScan
{
    [self doneScanning];
}
/*******************************************************************************
    captureImage
    Action proc for the 'Cap' button.
    Need to have reportCameraImage enabled for this.
*/
- (IBAction) captureImage
{
    if (!imageSaveInProgress) 
    {
        [self requestCameraSnapshot:true];
        savingImageLabel.hidden = false;
        captureButton.enabled = false;
    }
}
/*******************************************************************************
    toggleFrontBackCamera
    Action proc for the 'Front/Back' button.
*/
- (IBAction) toggleFrontBackCamera 
{
    self.useFrontCamera = !self.useFrontCamera;
}
/*******************************************************************************
    toggleTorch
    Action proc for the 'Light' button.
*/
- (IBAction) toggleTorch
{
    [self turnTorch:!self.isTorchOn];
    torchButton.style = self.isTorchOn ?  UIBarButtonItemStyleDone :
            UIBarButtonItemStyleBordered;
}
#pragma mark Status Updates
/*******************************************************************************
    statusUpdated:
    The RedLaser SDK will call this method repeatedly while scanning for barcodes.
*/
- (void) statusUpdated:(NSDictionary*) status
{
    NSSet *foundBarcodes = [status objectForKey:@"FoundBarcodes"];
    // Report how many barcodes we've found so far
    numBarcodesFoundLabel.text = [NSString stringWithFormat:@"%d Barcodes found", 
            [foundBarcodes count]];
    // Show the right guidance string for the guidance level
    // Guidance is used for detecting long Code 39 codes in parts.
    // See the documentation for more info.
    int guidanceLevel = [[status objectForKey:@"Guidance"] intValue];
    if (guidanceLevel == 1)
    {
        guidanceLabel.text = @"Try moving the camera close to each part of the barcode";
    } else if (guidanceLevel == 2)
    {
        guidanceLabel.text = [NSString stringWithFormat:@"%@…", 
                [status objectForKey:@"PartialBarcode"]];
    } else {
        guidanceLabel.text = @"";
    }
    // Show the in range label if we're in range of an EAN barcode
    inRangeLabel.hidden = ![[status objectForKey:@"InRange"] boolValue];
    // Tell the Red Box View to update its display
    redBoxView.barcodes = foundBarcodes;
    [redBoxView setNeedsDisplay];
    // If the user clicked the "Capture" button, this key will have a UIImage in it
    // on a subsequent statusUpdated call. Otherwise, the key won't be present.
    // If we have a camera image, save it to the device's photo album.
    UIImage *cameraImage = [status objectForKey:@"CameraSnapshot"];
    if (cameraImage && cameraImage != (id) [NSNull null])
    {
        imageSaveInProgress = true;
        UIImageWriteToSavedPhotosAlbum(cameraImage, self, 
                @selector(image:didFinishSavingWithError:contextInfo:), nil);
    }
}
/*******************************************************************************
    image:didFinishSavingWithError:contextInfo:
    Called when UIImageWriteToSavedPhotosAlbum() has finished saving an image to
    the camera roll.
    Reenables the Capture button and hides the "Saving Image..." label.
*/
- (void) image: (UIImage *) image didFinishSavingWithError: (NSError *) error
        contextInfo: (void *) contextInfo
{
    imageSaveInProgress = false;
    savingImageLabel.hidden = true;
    captureButton.enabled = true;
}
@end
@implementation RedBoxView
@synthesize barcodes;
/*******************************************************************************
    drawRect:
    RedBoxView is a UIView subclass that exists to override this method. 
    When it redraws itself, it looks for any barcodes in the found barcode set that 
    have been 'seen' in the last second, makes a UIBezierPath from the corner
    locations of the barcode, and then fills and strokes the path.
*/
- (void) drawRect:(CGRect)rect
{
    for (BarcodeResult *val in self.barcodes)
    {
        // Has this barcode been seen on-screen recently, or is it stale?
        if ([val.mostRecentScanTime timeIntervalSinceNow] < -1.0)
        {
            continue;
        }
        // Don't bother displaying a path that only has 2 points--this is rare but can happen
        if ([val.barcodeLocation count] < 2)
            continue;
        // Generate a UIBezierPath of the points, close it, and fill it
        UIBezierPath *path = [UIBezierPath bezierPath];
        [path moveToPoint:[[val.barcodeLocation objectAtIndex:0] CGPointValue]];
        for (int index = 1; index < [val.barcodeLocation count]; ++index)
        {
            [path addLineToPoint:[[val.barcodeLocation objectAtIndex:index] CGPointValue]];
        }
        [path closePath];
        [[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.2] set];
        [path fill];
        [[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.3] set];
        [path stroke];
    }
    // Be sure to clear out the barcodes once we've drawn them
    self.barcodes = nil;
}
- (void) didMoveToSuperview
{
    CGRect superviewFrame = [[self superview] frame];
    superviewFrame.origin.x = superviewFrame.origin.y = 0;
    self.frame = superviewFrame;
    [super didMoveToSuperview];
}

@end

您可以在应用程序方案中"启用僵尸对象"。这将为您提供正确的错误消息。

只需点击你的应用程序名称(xCode上停止按钮的右侧),然后点击编辑方案,然后点击左侧面板中的运行,现在转到"诊断"选项卡,你会看到内存管理标题,在该标题下你可以启用"启用僵尸对象"。

希望这对你有帮助。