Open abdd14 opened 1 month ago
The thread should stop when the FrameCryptorTransformer is destroyed
https://github.com/webrtc-sdk/webrtc/blob/m125_release/api/crypto/frame_crypto_transformer.cc#L335
@cloudwebrtc Hi, How to stop it? I'm using webrtc from flutter SDK
you can use await frameCryptor.dispose();
to release instance.
https://github.com/flutter-webrtc/flutter-webrtc/blob/main/lib/src/native/frame_cryptor_impl.dart#L325
I'm calling that, and It's being removed from the frameCryptors dictionary. But even with that I was looking at the memory graph and The FrameCrypto was still there
I discovered that I should set stream handler to nil and after that RTCFrameCrypto was getting removed but not FrameCryptorTransformer.
FlutterEventChannel* eventChannel = self.frameCryptorsChannels[frameCryptorId];
[eventChannel setStreamHandler:nil];
frameCryptor.eventSink = nil;
frameCryptor.delegate = nil;
I found out that I have older version which dealloc is like that:
- (void)dealloc {
frame_crypto_transformer_->UnRegisterFrameCryptorTransformerObserver();
}
while in the current branch I can see
- (void)dealloc {
os_unfair_lock_lock(&_lock);
if (_frame_crypto_transformer != nullptr) {
_frame_crypto_transformer->UnRegisterFrameCryptorTransformerObserver();
_frame_crypto_transformer = nullptr;
}
_observer = nullptr;
os_unfair_lock_unlock(&_lock);
}
Maybe this is the issue.
The FrameCryptorTransformer instance keep increasing every time someone create a track.
This will keep the CPU threads busy.