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

Add full data-race safety and enable strict concurrency checking for Swift 6 compatibility #174

Merged
merged 11 commits into from
Aug 12, 2024

Conversation

Jeehut
Copy link
Contributor

@Jeehut Jeehut commented Jul 31, 2024

Implements #165.

Note that this is based off of the branch of #173 and therefore supersedes it. If this is merged first, #173 can be closed.

You might want to also check out my article in TelemetryDeck/docs#98 to understand the changes better.

Also, it's probably a good idea if a few real-world customers give these changes a spin, either by including the feature/data-race-safety branch or on the main branch once this is merged. We should have some real-world testing before making a regular release.

@Jeehut Jeehut force-pushed the feature/data-race-safety branch from 9e410a3 to 67d831b Compare July 31, 2024 14:42
@Jeehut Jeehut requested a review from winsmith July 31, 2024 15:02
@Jeehut Jeehut force-pushed the feature/data-race-safety branch from dc702ae to 66fe52e Compare August 1, 2024 13:33
@Jeehut
Copy link
Contributor Author

Jeehut commented Aug 1, 2024

@winsmith I just rebased after merging #178 and fixed some leftover issues I found with UI-based parameters.

@winsmith
Copy link
Contributor

winsmith commented Aug 1, 2024

Looks good but the "Text Xcode 15" step seems to fail on watchOS. Can we do something about that?

@Jeehut
Copy link
Contributor Author

Jeehut commented Aug 1, 2024

@winsmith I fixed the CI immediately after receiving the notification that CI failed. 😊 All passing now.

@Jeehut
Copy link
Contributor Author

Jeehut commented Aug 1, 2024

@winsmith Please don't merge just yet, I just tested this branch in a real-world project and ran into this issue:

Bildschirmfoto 2024-08-01 um 16 01 50

Let me take another look, it seems marking TelemetryManager as @unchecked Sendable wasn't quite right…

I'll let you know when it's ready, marked as a draft PR for now.

@Jeehut Jeehut marked this pull request as draft August 1, 2024 14:03
@Jeehut Jeehut marked this pull request as ready for review August 5, 2024 14:32
@Jeehut
Copy link
Contributor Author

Jeehut commented Aug 5, 2024

@winsmith I played around a lot to fix this issue, the only thing that worked were the changes I committed in 483b686. In my testing with iOS & macOS targets, it worked as expected. So I'm marking this PR as ready again.

Note that extracting the computed properties into a property wrapper like this did NOT work (it still crashed):

@propertyWrapper
struct ThreadSafe<Value> {
    private let queue = DispatchQueue(label: "com.telemetrydeck.ThreadSafe", attributes: .concurrent)
    private var value: Value

    init(wrappedValue: Value) {
        self.value = wrappedValue
    }

    var wrappedValue: Value {
        get { return queue.sync { value } }
        set { queue.async(flags: .barrier) { self.value = newValue } }
    }
}

I do not really understand why this doesn't work, it should be equivalent to what I committed, but apparently it's not. 🤷‍♂️

I also want to reiterate that it's probably a good idea if customers first try this out before we make an official release. For me, it worked, but maybe you wanna ask one or two customers if they wanna give it a try with the main branch after this is merged. Or with the current feature/data-race-safety branch. Alternatively, we could also make a 2.4.0-beta.1 release. Maybe you wanna ask the customer who reported #172?

I could also ask on Mastodon for volunteers if you don't already know customers to contact.

@winsmith
Copy link
Contributor

Fantastic work. I'll find a few customers to test this with!

@winsmith
Copy link
Contributor

Let's merge this into main, but let's not add a release just yet. Then we can publish the blog post and we can hit up a few select customers. Would that work for you?

@Jeehut
Copy link
Contributor Author

Jeehut commented Aug 12, 2024

@winsmith Yeah, sounds good. Let's go, I'm merging. 🎉

@Jeehut Jeehut merged commit bfbc475 into main Aug 12, 2024
6 checks passed
@Jeehut Jeehut deleted the feature/data-race-safety branch August 12, 2024 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants