You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that the proxy is de-initialized immediately after initialization.
To make it last I have to store it somewhere else, so it will work as expected.
In my opinion a bug, since an object which is set as an observer should not be deallocated.
The text was updated successfully, but these errors were encountered:
This isn't anything to do with Swift, just Cocoa, but it's also correct behavior there. If the SKPaymentQueue kept the observer alive, it would never know when to deallocate it. (This pattern is extremely common throughout Cocoa, though in most cases it's because the observer owns the observed object, and you'd get a strong reference cycle and therefore a leak if the observed kept the observer alive.)
Thank you very much for the clarification @belkadan .
Also sorry if I came to the wrong place.
Anyhow - and maybe I am spoiled by the Java Garbage Collector and Swift can't do this - IMHO the right time to deallocate the observer would be when I remove it from the SKPaymentQueue via "func remove(_ observer: SKPaymentTransactionObserver)" and there are no more other references to the object.
Until then I find it spooky an observer I added just doesn't work without any evidence what happened.
These are the things one spends hours finding out about 🙁
Ah, but you can't do that removal if you don't have a reference to it from elsewhere!
You're right that garbage collection would handle this case; cycle collection is the main thing garbage collection can do that plain reference counting cannot. It's a tradeoff for sure.
Environment
macOS: 10.14.4
Xcode: Version 10.2.1 (10E1001)
Swift 5
Additional Detail from JIRA
md5: fa76162c2848920848aec995aa6bf1c2
Issue Description:
I created a proxy class for my SKPaymentTransactionObserver. It takes the real SKPaymentTransactionObserver with its initializer.
Now within the AppDelegate I added a new instance of my proxy to the SKPaymentQueue:
SKPaymentQueue.default().add(LoggingSKPaymentTransactionObserver(aSKPaymentTransactionObserver: CsConstants.STORE_KIT_AGENT))
I found that the proxy is de-initialized immediately after initialization.
To make it last I have to store it somewhere else, so it will work as expected.
In my opinion a bug, since an object which is set as an observer should not be deallocated.
The text was updated successfully, but these errors were encountered: