twostraws / CodeScanner

A SwiftUI view that is able to scan barcodes, QR codes, and more, and send back what was found.
MIT License
1.02k stars 293 forks source link

iOS 14 crash #23

Closed arthur-ver closed 3 years ago

arthur-ver commented 3 years ago

CodeScanner sometimes crashes with the error "Thread 1: "*** -[__NSSingleObjectArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]"

arthur-ver commented 3 years ago

Nevermind. It was an issue with self.presentationMode.wrappedValue.dismiss() when using multiple Views inside .sheet

arthur-ver commented 3 years ago

Ok, it has still not fixed the issue...

Spezializten commented 3 years ago

I have experienced the same issue!

CodeScanner sometimes crashes with the error "Thread 1: "*** -[__NSSingleObjectArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]"

EstebanC02 commented 3 years ago

Hello, to complement the error I see that it occurs when the user rejects the camera permission. This is what generates the error log:

,w_642/v1598564806/entity/category/5f36eee59496f93eba00018d.jpg)
2020-10-10 11:34:31.572427-0500 APP[56230:3102612] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 1 beyond bounds for empty NSArray'
*** First throw call stack:
(0x1a4080114 0x1b78a6cb4 0x1a3f8c6f0 0x1a7a45bc0 0x1a7a4a474 0x104f4a078 0x104f4a764 0x104f4a8e0 0x1a6207858 0x1a6207d5c 0x1a4003820 0x1a3f67e68 0x1a6207a08 0x1a62081b8 0x1a6140da0 0x1a6207858 0x1a6207d5c 0x1a4003820 0x1a3f67e68 0x1a6207a08 0x1a62081b8 0x1a62084b8 0x1a60f4138 0x1a60f3f1c 0x1a60f8618 0x1a622a4d8 0x1a6d83c70 0x1a6d83924 0x1a6db8ec0 0x1a6d8d578 0x1a6d8da80 0x1a6d8dbd0 0x1a72d75a8 0x106f555fc 0x106f63a6c 0x1a3fffc30 0x1a3ffa0e8 0x1a3ff9200 0x1ba0f4598 0x1a68bf004 0x1a68c45d8 0x1aa9fe694 0x1aa9fe624 0x1aa5e73c8 0x104f13970 0x104f13a7c 0x1a3cd8598)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 1 beyond bounds for empty NSArray'
terminating with uncaught exception of type NSException
(lldb) 
libsystem_kernel.dylib`__pthread_kill:
    0x1ce8e6954 <+0>:  mov    x16, #0x148
    0x1ce8e6958 <+4>:  svc    #0x80
->  0x1ce8e695c <+8>:  b.lo   0x1ce8e6978               ; <+36>
    0x1ce8e6960 <+12>: stp    x29, x30, [sp, #-0x10]!
    0x1ce8e6964 <+16>: mov    x29, sp
    0x1ce8e6968 <+20>: bl     0x1ce8c41dc               ; cerror_nocancel
    0x1ce8e696c <+24>: mov    sp, x29
    0x1ce8e6970 <+28>: ldp    x29, x30, [sp], #0x10
    0x1ce8e6974 <+32>: ret    
    0x1ce8e6978 <+36>: ret    
Error screenshot
dscoppelletti commented 3 years ago

It seems to be very similar to #18.

TusharSharma651 commented 3 years ago

Happening on this line of code. let previewConnection = captureSession.connections[1]

jzeisweiss commented 3 years ago

I found the same issue as @TusharSharma651 where it can crash if you quickly launch the view controller for line 180 of ScannerViewController.

image

jzeisweiss commented 3 years ago

@twostraws - This issue has been fixed by https://github.com/twostraws/CodeScanner/pull/10. Can you tag a new release?

twostraws commented 3 years ago

@jzeisweiss Done!