You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

首次调用正常,二次打开Vidyo视图触发EXC_BAD_ACCESS错误排查

Fixing EXC_BAD_ACCESS After Re-launching Vidyo Calls on iOS

Hey there, let's break down why you're hitting this EXC_BAD_ACCESS error with the LmiVideoCapturerImplementationAVFoundation zombie instance. The core issue is that your cleanup flow runs synchronously before Vidyo's async operations finish, and you're missing some critical steps to properly release resources.

What's Wrong With Your Current Flow?

Right now, you're calling disconnect, disable, vc = nil, and VCConnectorPkg uninitialize all in sequence in viewDidDisappear. But Vidyo's disconnect is asynchronous—it doesn't immediately tear down the connection or release internal resources like the video capturer. When you jump straight to disabling and releasing the connector, you're yanking the rug out from under the SDK while it's still working with the capturer. Later, when the SDK tries to reference that already-deallocated capturer, you get the zombie error.

Steps You're Missing (And Fixes)

1. Wait for the Disconnect Callback Before Cleaning Up

Vidyo's VCConnector tells you when the disconnect is actually done via the connectorDidDisconnect: delegate method. You need to trigger your cleanup only after this callback fires, not right away in viewDidDisappear.

Here's how to adjust your code:

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    
    // Only kick off the disconnect—don't clean up yet!
    if (self.vc) {
        [self.vc disconnect];
    }
}

// Implement this VCConnectorDelegate method
- (void)connectorDidDisconnect:(VCConnector *)connector reason:(VCConnectorDisconnectReason)reason {
    // Now that the disconnect is fully done, safe to clean up
    [self cleanUpVidyoResources];
}

2. Clean Up Resources in the Right Order

In your cleanup method, follow this sequence to make sure all resources are released properly:

  • First, explicitly stop the local camera capture to cut off the SDK's link to the capturer
  • Then disable the connector to release hardware resources (camera, mic, speaker)
  • Clear the delegate reference to prevent the SDK from holding onto your view controller
  • Finally, nil out the connector instance

Also, stop calling VCConnectorPkg uninitialize after every call! This method should only be called once in your app's lifecycle—usually when the app is exiting, or when you're sure you'll never use Vidyo again. Calling it after every call messes up the SDK's internal state and causes conflicts when you reinitialize later.

Example cleanup method:

- (void)cleanUpVidyoResources {
    if (self.vc) {
        // Stop local camera capture first to release the capturer explicitly
        [self.vc stopLocalCamera];
        // Remove delegate to break SDK's reference to this VC
        [self.vc setDelegate:nil];
        // Disable the connector to release hardware resources
        [self.vc disable];
        // Nil out the connector to release your strong reference
        self.vc = nil;
    }
    
    // REMOVE THIS LINE FROM PER-CALL CLEANUP:
    // [VCConnectorPkg uninitialize];
    // Only call this once, e.g., in applicationWillTerminate:
}

3. Double-Check for Unhandled Delegates/Notifications

Make sure you're not leaving any dangling delegate references or notification observers that could cause the SDK to send messages to your deallocated view controller. You already remove notification observers, but adding the setDelegate:nil step is crucial here.

Quick Recap

  • Let Vidyo finish disconnecting via the delegate callback before cleaning up
  • Explicitly stop the local camera before disabling the connector
  • Don't call VCConnectorPkg uninitialize after every call—save it for app shutdown
  • Always nil out delegates before releasing SDK instances

内容的提问来源于stack exchange,提问作者user2052501

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:29:59