Skip to content
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

Retain cycle when starting streaming #12

Open
a-voronov opened this issue Jul 16, 2018 · 2 comments
Open

Retain cycle when starting streaming #12

a-voronov opened this issue Jul 16, 2018 · 2 comments

Comments

@a-voronov
Copy link

WowzaSDK seems to retain reference to WOWZStatusCallback when calling WowzaGoCoder.startStreaming(_:).

Following tutorials, I can pass self as a callback, but once I do, instance of my class isn't released as I'm keeping reference to WowzaSDK instance..

class Test: NSObject, WOWZStatusCallback {
    let goCoder: WowzaGoCoder.sharedInstance()!

    func stream() {
        goCoder.startStreaming(self) // here self is retained and never released
    }
}

reproduces in v1.5.1

@a-voronov
Copy link
Author

quick fix solution ¯\(ツ)

class Test: NSObject, WOWZStatusCallback {
    let goCoder: WowzaGoCoder.sharedInstance()!

    func stream() {
        goCoder.startStreaming(WOWZStatusCallbackProxy(self)) // now everything's fine
    }
}

class WOWZStatusCallbackProxy: NSObject, WOWZStatusCallback {
    private weak var forwardee: WOWZStatusCallback?

    init(forwardee: WOWZStatusCallback?) {
        self.forwardee = forwardee
        super.init()
    }

    func onWOWZStatus(_ status: WOWZStatus!) {
        forwardee?.onWOWZStatus(status)
    }

    func onWOWZEvent(_ status: WOWZStatus!) {
        forwardee?.onWOWZEvent?(status)
    }

    func onWOWZError(_ status: WOWZStatus!) {
        forwardee?.onWOWZError(status)
    }
}

@ravigangwar1991
Copy link

I'm facing the same problem my app is hanged after calling start streaming.i also tried which code is given.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants