Skip to content

[BUG] Switching camera (video stream source) crashes on devices without notch #2357

@Svantulden

Description

@Svantulden

Describe the bug
When using videoStream.switchSource(camera:) on a device without a notch, like an iPhone SE 1st Gen or an older iPad, this crashes the app. We think this is related to that kind of devices, as we cannot reproduce it on newer iPhone devices with notch.

Exception or Stack Trace
BAD_ACCESS:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00001f9e31279178
Exception Codes: 0x0000000000000001, 0x00001f9e31279178
VM Region Info: 0x1f9e31279178 is not in any region.  Bytes after previous region: 34283253633401  
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      commpage (reserved)     1000000000-7000000000 [384.0G] ---/--- SM=NUL  ...(unallocated)
--->  
      UNUSED SPACE AT END
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [1600]

The thread that crashed in the symbolicated crash

Thread 22 name:   Dispatch queue: com.apple.root.default-qos
Thread 22 Crashed:
0   AzureCommunicationCalling     	       0x105ccd0e8 calling::ng::NGMyself::fireMediaOperationStatusChanged(rt::IntrusivePtr<calling::ng::NGCall> const&, SkyLib::CallHandler::MODALITY_TYPE, csa::ISelfParticipantCallView::LocalMediaOperationState, csa::ISelfParticipantCallView::MediaNegotiationStatusCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 688
1   AzureCommunicationCalling     	       0x105cd6584 auf::VarF<calling::ng::NGMyself::fireMediaOperationStatusChanged(rt::IntrusivePtr<calling::ng::NGCall> const&, SkyLib::CallHandler::MODALITY_TYPE, csa::ISelfParticipantCallView::LocalMediaOperationState, csa::ISelfParticipantCallView::MediaNegotiationStatusCode, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&)::$_1, rt::WeakIntrusivePtr<calling::ng::NGMyself>, rt::IntrusivePtr<calling::ng::NGCall> const&, SkyLib::CallHandler::MODALITY_TYPE&, csa::ISelfParticipantCallView::LocalMediaOperationState&, csa::ISelfParticipantCallView::MediaNegotiationStatusCode&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&>::dispatch() + 272
2   AzureCommunicationCalling     	       0x106331844 auf::priv::MRMWTransport::tryDispatch(auf::IDispatcher*) + 156
3   AzureCommunicationCalling     	       0x10632b470 auf::StrandExecutorImp::tryDispatch(auf::IDispatcher*) + 24
4   AzureCommunicationCalling     	       0x10632b2f4 auf::StrandExecutorImp::depleteStrand(rt::IntrusivePtr<auf::StrandExecutorImp>) + 100
5   AzureCommunicationCalling     	       0x10632b630 auf::Var<void (auf::StrandExecutorImp::*)(rt::IntrusivePtr<auf::StrandExecutorImp>), auf::StrandExecutorImp&, rt::IntrusivePtr<auf::StrandExecutorImp>&>::dispatch() + 80
6   AzureCommunicationCalling     	       0x10632a440 auf::NativeThreadPoolExecutor::callFromNativeWorker(spl::VarBase*, void*) + 56
7   AzureCommunicationCalling     	       0x10632a5fc invocation function for block in spl::priv::NativeThreadPoolManager::dispatch(std::nullptr_t const&, dispatch_queue_s*, void (*)(spl::VarBase*, void*), spl::VarBase*, void*) + 64
8   libdispatch.dylib             	       0x1d36ef7a8 _dispatch_call_block_and_release + 24
9   libdispatch.dylib             	       0x1d36f0780 _dispatch_client_callout + 16
10  libdispatch.dylib             	       0x1d369fbdc _dispatch_root_queue_drain + 640
11  libdispatch.dylib             	       0x1d36a02ac _dispatch_worker_thread2 + 172
12  libsystem_pthread.dylib       	       0x216d76b94 _pthread_wqthread + 224
13  libsystem_pthread.dylib       	       0x216d76720 start_wqthread + 8

To Reproduce
Steps to reproduce the behavior:

  1. Start the call like normal, having an outgoing video stream and a local video stream active
  2. Get the other camera, like the .cameraFacing == .back when the front is the active source
  3. Switch source to that camera via localVideoStream.switchSource(camera: camera)
  4. The app mostly always crashes. Sometimes it doesn't, so maybe it's threading related

Code Snippet

let camera = localVideoStream.source.cameraFacing == .back ? deviceManager.cameras.first(where: { $0.cameraFacing == .front }) : deviceManager.cameras.first(where: { $0.cameraFacing == .back })
if let camera {
    localVideoStream.switchSource(camera: camera, completionHandler: { error in
        if let error = error {
            self.logger.print("Not possible to switch camera: \(error)", "ACS")
        } else {
            self.logger.print("Switch Camera \(camera.cameraFacing == .back ? "back": "front") - success", "ACS")
        }
    })
}

Additional information
When using version 2.15.1 we see the following in the Xcode console during debugging at time of crash:

*** Assertion failure in -[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:forWindowScene:], UIApplication.m:5785

Expected behavior
The camera switching happens normally without a crash

Setup (please complete the following information):

  • OS: Tested on iPadOS 16.7.14, iPadOS 17.5.1, iOS 15.8
  • IDE : Xcode
  • Version of the Library used: Multiple exhibiting this issue, like 2.15.1 and the latest via SPM 2.18.1 as well

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Metadata

Metadata

Labels

Communicationcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions