TelemetryDeck / SwiftSDK

Swift SDK for TelemetryDeck, a privacy-conscious analytics service for apps and websites.
https://telemetrydeck.com/
Other
149 stars 30 forks source link

Avoid runtime exception due to deallocated `unowned self` #84

Closed andreyz closed 1 year ago

andreyz commented 1 year ago

Fixes #83

My assumption the crash is due to self ie SignalManager being deallocated before completion handler for URLDataTask completes.

andreyz commented 1 year ago

Ideally DispatchQueue and/or URLDataTask could be controlled in tests, as to verify various race conditions introduced by the GC async blocks.

winsmith commented 1 year ago

Fantastic! You marked this PR as draft, can you ping me when you'd like a review?

andreyz commented 1 year ago

@winsmith I wanted to test this patch in beta release of my app first.

Could you tweak your tests to fix missing Xcode 12 meanwhile?

winsmith commented 1 year ago

For sure!

winsmith commented 1 year ago

@andreyz It is done!

andreyz commented 1 year ago

This PR seems to address the issue in my TestFlight build. I've also ran a leaks check in Instruments, just in case.

andreyz commented 1 year ago

@winsmith please have a look. Not sure if use of unowned self was justified there, if it was — you'd know.

winsmith commented 1 year ago

It was you know. One of those times when you just write the line without thinking about it. Thanks for the PR, it works on my test devices as well.