diff --git a/mediapipe/tasks/ios/vision/image_segmenter/sources/MPPImageSegmenter.mm b/mediapipe/tasks/ios/vision/image_segmenter/sources/MPPImageSegmenter.mm index dfa8845f2..8fad36671 100644 --- a/mediapipe/tasks/ios/vision/image_segmenter/sources/MPPImageSegmenter.mm +++ b/mediapipe/tasks/ios/vision/image_segmenter/sources/MPPImageSegmenter.mm @@ -243,17 +243,18 @@ using ::mediapipe::tasks::core::PacketsCallback; return; } - // Output packet map is moved to a block variable that will not be deallocated for the lifetime of the `dispatch_async` call. Eventhough masks are not copied, we have to ensure that they are not de allocated before the delegate call completes. + // Output packet map is moved to a block variable that will not be deallocated for the lifetime of + // the `dispatch_async` call. Since masks are not copied, this ensures that they are only + // deallocated after the delegate call completes. __block PacketMap outputPacketMap = std::move(liveStreamResult.value()); if (outputPacketMap[kImageOutStreamName.cppString].IsEmpty()) { return; } - + dispatch_async(_callbackQueue, ^{ - - MPPImageSegmenterResult *result = - [MPPImageSegmenter imageSegmenterResultWithOutputPacketMap:outputPacketMap - shouldCopyMaskPacketData:NO]; + MPPImageSegmenterResult *result = + [MPPImageSegmenter imageSegmenterResultWithOutputPacketMap:outputPacketMap + shouldCopyMaskPacketData:NO]; [self.imageSegmenterLiveStreamDelegate imageSegmenter:self didFinishSegmentationWithResult:result