【发布时间】:2026-02-20 01:05:02
【问题描述】:
我不清楚如何正确停止和解除分配 MPPGraph。我创建了一个与this 非常相似的框架。每次以某种方式调用 dealloc 时都会引发此异常。 Thread 1: Exception: "waitUntilDoneWithError: should not be called on the main thread".
我不知道如何不在主线程中调用它,并希望有人对此有所了解。
【问题讨论】:
标签: mediapipe
我不清楚如何正确停止和解除分配 MPPGraph。我创建了一个与this 非常相似的框架。每次以某种方式调用 dealloc 时都会引发此异常。 Thread 1: Exception: "waitUntilDoneWithError: should not be called on the main thread".
我不知道如何不在主线程中调用它,并希望有人对此有所了解。
【问题讨论】:
标签: mediapipe
对于遇到相同问题的任何人。此问题已在here 得到解决,并已提出解决方案。
编辑: 最后一点可能是错误的,但我以这种方式使用了 dealloc:
- (void)dealloc {
self.mediapipeGraph.delegate = nil;
[self.mediapipeGraph cancel];
// Ignore errors since we're cleaning up.
[self.mediapipeGraph closeAllInputStreamsWithError:nil];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self.mediapipeGraph waitUntilDoneWithError:nil];
});
}
【讨论】: