-
-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix retain on pluginMediaStreamTrack will not allow camera/mic to be freed #126
Bugfix retain on pluginMediaStreamTrack will not allow camera/mic to be freed #126
Conversation
I noticed CPU was spinning at 20% after i getUserMedia and stop the stream. This fixes the issue, as the lambda was retaining the pluginMediaStreamTrack |
@oNaiPs so no more PacerThread thread running after deallocating iosrtc/Cordova? |
I'm not sure if that's the thread, but yeah it stops at least one thread
|
Thank you for your response. So basically now you saw that from 20% to ~0% cpu usage? |
Yes indeed. The bug is reproducible with:
When stream stops, the retention would keep the camera running indefinitely |
Amazing! May you please explain why the track was not freed before and why it is freed using May be more places in which |
Bugfix retain on pluginMediaStreamTrack will not allow camera/mic to be freed
Yes there will be more places for that to be used. It looks like swift would benefit from other syntax though. Take a look at https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AutomaticReferenceCounting.html, mainly on "Resolving Strong Reference Cycles for Closures" |
Is Swift a joke? The problem of "Strong Reference Cycles" is resolved in so many languages with GC... |
@oNaiPs should then things like this also be fixed?: func MediaStreamTrack_setEnabled(command: CDVInvokedUrlCommand) {
NSLog("iosrtcPlugin#MediaStreamTrack_setEnabled()")
let id = command.argumentAtIndex(0) as! String
let value = command.argumentAtIndex(1) as! Bool
let pluginMediaStreamTrack = self.pluginMediaStreamTracks[id]
if pluginMediaStreamTrack == nil {
NSLog("iosrtcPlugin#MediaStreamTrack_setEnabled() | ERROR: pluginMediaStreamTrack with id=\(id) does not exist")
return;
}
dispatch_async(self.queue) {
pluginMediaStreamTrack!.setEnabled(value)
}
} to: func MediaStreamTrack_setEnabled(command: CDVInvokedUrlCommand) {
NSLog("iosrtcPlugin#MediaStreamTrack_setEnabled()")
let id = command.argumentAtIndex(0) as! String
let value = command.argumentAtIndex(1) as! Bool
weak var pluginMediaStreamTrack = self.pluginMediaStreamTracks[id]
if pluginMediaStreamTrack == nil {
NSLog("iosrtcPlugin#MediaStreamTrack_setEnabled() | ERROR: pluginMediaStreamTrack with id=\(id) does not exist")
return;
}
dispatch_async(self.queue) {
pluginMediaStreamTrack!.setEnabled(value)
}
} |
I'm preparing a commit that replaces all the |
@ibc yes, it'll apply to those variables that are used inside the lambda block afterwards. |
Thanks. I've set |
No description provided.