Coder Social home page Coder Social logo

There's a retain loop between SubscriptionListener and ListenerToken if listener is added by SubscriptionSession.add(_:ListenerType) about swift HOT 14 CLOSED

pubnub avatar pubnub commented on July 28, 2024
There's a retain loop between SubscriptionListener and ListenerToken if listener is added by SubscriptionSession.add(_:ListenerType)

from swift.

Comments (14)

parfeon avatar parfeon commented on July 28, 2024 1

@luisescamilla13 thank you!
If possible, can you create a new issue, so we won't bother issue author on a non-related topic?

from swift.

dterekhov avatar dterekhov commented on July 28, 2024

It crashed for me at the same line: self?.privateListeners.remove(listener)
Here is a hint of how it was precisely caught: before the app was in the state sceneWillResignActive and on switching to sceneDidBecomeActive it crashed.

Screenshot 2022-12-12 at 12 56 16 AM

from swift.

AirBlack avatar AirBlack commented on July 28, 2024

It didn't crash for me but cos of retain loop and caching the subscription didn't clean itself and was stuck providing the app with duplicate/invalid values. I fixed it by somehow cleaning the subscription manually. I will post a workaround when I'll be next time around my working device.

from swift.

parfeon avatar parfeon commented on July 28, 2024

There will be fix for this, so as soon as subscription listener instance will go out of scope, it will be removed from list of listeners and free-up resources properly.

from swift.

pubnub-release-bot avatar pubnub-release-bot commented on July 28, 2024

@AirBlack this issue is addressed in 6.0.3

from swift.

luisescamilla13 avatar luisescamilla13 commented on July 28, 2024

Still getting the error with 6.0.3 :(
In $specialized Set._Variant.update(with:)

from swift.

parfeon avatar parfeon commented on July 28, 2024

@luisescamilla13 hello. What exactly error do you get?
This issue was about retain cycle.

from swift.

parfeon avatar parfeon commented on July 28, 2024

@luisescamilla13 is it possible to show place. where you experience issue in same way, as shown in first message?

from swift.

luisescamilla13 avatar luisescamilla13 commented on July 28, 2024

@parfeon sure
This is the crash:

SIGSEGV : Crash due to signal: SIGSEGV(SEGV_MAPERR) at 00000010
$specialized Set._Variant.update(with:) (<compiler-generated>:0 )

This is the code where I initialize pubnub:

        // Setup PNConfiguration
        var configuration = PubNubConfiguration(publishKey: keys.publishKey, subscribeKey: keys.subscriptionKey, uuid: email)
        configuration.authKey = keys.token
        pubnub =  PubNub(configuration: configuration)
        listener = SubscriptionListener(queue: .main)
        pubnub.add(listener)

And here is the stack trace:
Screen Shot 2023-02-15 at 11 19 20

from swift.

parfeon avatar parfeon commented on July 28, 2024

@luisescamilla13 do you store somewhere reference on listener? Without reference to it, the object will be deallocated right away.

from swift.

luisescamilla13 avatar luisescamilla13 commented on July 28, 2024

@parfeon yes sir, my class has the following variable
let listener: SubscriptionListener
And the value is initialized in the init of my class

from swift.

parfeon avatar parfeon commented on July 28, 2024

@luisescamilla13 is there any chance to have some minimum app which is able to reproduce this issue? With memory leak, we were able to reproduce it and fix, but I can't reproduce this one.

from swift.

luisescamilla13 avatar luisescamilla13 commented on July 28, 2024

@parfeon to be honest I haven't been able to reproduce it by myself, we just get this random crash every two or three weeks from different users. I'll let you know if I get more details. Thanks for the response.

from swift.

dterekhov avatar dterekhov commented on July 28, 2024

Continue getting crashes with the 6.0.5 latest version.
Please pay attention that the app crashes on com.apple.root.user-initiated-qos.cooperative thread + when going to the background state.

Screenshot 2023-05-30 at 7 07 04 PM Screenshot 2023-05-30 at 7 07 37 PM

cc @parfeon
Can you please re-open this issue?

from swift.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.