Crash during setup

Open
#114 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
swift
Domain
mobile

Research direction

Start in ScannerViewController.swift at setupCaptureDevice() around line 314, following the stack trace through camera permission handling and session setup. Reproduce startup on iOS 15 and iOS 16 devices, then verify that capture sessions no longer raise the reported active-color-space exception during configuration.

Written by the indexing model from the issue text.

Description

Hi!

I'm seeing some crashes when starting a capture session - on various devices using iOS 15 and iOS 16.

NavigationView {
    VStack {
        CodeScannerView(
            codeTypes: [.qr],
            scanMode: .oncePerCode
        ) { response in
            if case let .success(result) = response {
                onFindQRCode(result.string)
            }
        }
        .padding(.horizontal, 16)
        .padding(.bottom, 24)
        .aspectRatio(1, contentMode: .fit)

        // More view elements
    }
}
NSInvalidArgumentException - *** -[AVCaptureDevice setActiveColorSpace:] Not supported - use activeFormat.supportedColorSpaces
Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x9e88 __exceptionPreprocess
1  libobjc.A.dylib                0x178d8 objc_exception_throw
2  AVFCapture                     0x1c7e0 __102-[AVCaptureFigVideoDevice _setActiveFormat:resetVideoZoomFactorAndMinMaxFrameDurations:sessionPreset:]_block_invoke
3  libdispatch.dylib              0x3fdc _dispatch_client_callout
4  libdispatch.dylib              0x13574 _dispatch_lane_barrier_sync_invoke_and_complete
5  AVFCapture                     0x3a144 -[AVCaptureFigVideoDevice setActiveColorSpace:]
6  Foundation                     0x3f814 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:]
7  Foundation                     0x3f590 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:]
8  Foundation                     0x3e518 _NSSetLongLongValueAndNotify
9  AVFCapture                     0xc6d8 -[AVCaptureSession _updateDeviceActiveFormatsAndActiveConnections]
10 AVFCapture                     0xa0d70 -[AVCaptureSession _buildAndRunGraph:]
11 AVFCapture                     0x6710 -[AVCaptureSession _commitConfiguration]
12 AVFCapture                     0x18b1c -[AVCaptureSession addOutput:]
13 <redacted>                     0x506574 CodeScannerView.ScannerViewController.setupCaptureDevice() + 314 (ScannerViewController.swift:314)
14 <redacted>                     0x506134 closure #1 in CodeScannerView.ScannerViewController.handleCameraPermission() + 251 (ScannerViewController.swift:251)
15 <redacted>                     0x5062d0 closure #1 in CodeScannerView.ScannerViewController.requestCameraAccess(completion:) + 270 (ScannerViewController.swift:270)
16 <redacted>                     0x506390 thunk for @escaping @callee_guaranteed (@unowned Bool) -> () (<compiler-generated>)
17 TCC                            0xd06c ___tcc_server_send_request_authorization_block_invoke.62
18 libdispatch.dylib              0x24b4 _dispatch_call_block_and_release
19 libdispatch.dylib              0x3fdc _dispatch_client_callout
20 libdispatch.dylib              0xb694 _dispatch_lane_serial_drain
21 libdispatch.dylib              0xc1e0 _dispatch_lane_invoke
22 libdispatch.dylib              0x16e10 _dispatch_workloop_worker_thread
23 libsystem_pthread.dylib        0xdf8 _pthread_wqthread
24 libsystem_pthread.dylib        0xb98 start_wqthread
Dominant language
Swift
Stars
1.2k
Forks
328
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from twostraws/CodeScanner

All issues in twostraws/CodeScanner

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.