ShopifyCheckoutKit.Configuration: NSLock guaranteed#85
Merged
kieran-osgood-shopify merged 1 commit intoJun 15, 2026
Merged
Conversation
Contributor
Author
This was referenced May 13, 2026
Merged
f957cbd to
82606f0
Compare
0453ef5 to
3aaa3db
Compare
82606f0 to
cd2ef3a
Compare
0955280 to
c7e8091
Compare
cd2ef3a to
e5d6371
Compare
945d4b6 to
fe87622
Compare
1d19f91 to
87179cb
Compare
2fccbc2 to
63e7604
Compare
11 tasks
b28434d to
1d9c9a8
Compare
1d9c9a8 to
bf73472
Compare
87179cb to
9870cf8
Compare
bf73472 to
1b9f6d6
Compare
0d6d8de to
0e4fa9c
Compare
9870cf8 to
014b0e5
Compare
markmur
approved these changes
Jun 15, 2026
0e4fa9c to
ec5db8e
Compare
014b0e5 to
5a6e752
Compare
ec5db8e to
d9d261f
Compare
Contributor
Author
Merge activity
|
kieran-osgood-shopify
added a commit
that referenced
this pull request
Jun 15, 2026
### What changes are you making? See #85 for explanation on the new LockedValue container Aside from that not much to say about this PR, it uses LockedValue to make concurrent access to the shared logger safe ### How to test <!-- Please outline the steps to test your changes --> --- ### Before you merge > [!IMPORTANT] > > - [ ] I've added tests to support my implementation > - [ ] I have read and agree with the [Contribution Guidelines](./CONTRIBUTING.md) > - [ ] I have read and agree with the [Code of Conduct](./CODE_OF_CONDUCT.md) > - [ ] I've updated the relevant platform README (`platforms/swift/README.md` and/or `platforms/android/README.md`) --- <details> <summary>Releasing a new Swift version?</summary> - [ ] I have bumped the version in `platforms/swift/ShopifyCheckoutKit.podspec` - [ ] I have bumped the version in `platforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swift` - [ ] I have updated `platforms/swift/CHANGELOG.md` - [ ] I have updated the SwiftPM/CocoaPods version snippets in `platforms/swift/README.md` (major version only) </details> <details> <summary>Releasing a new Android version?</summary> - [ ] I have bumped the `versionName` in `platforms/android/lib/build.gradle` - [ ] I have updated `platforms/android/CHANGELOG.md` - [ ] I have updated the Gradle/Maven version snippets in `platforms/android/README.md` </details> > [!TIP] > See the [Contributing documentation](./CONTRIBUTING.md) for the full release process per platform.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
Swift 6 is stricter about global/shared mutable state. In Swift 6 language mode, a mutable global like this becomes a concurrency-safety problem:
The compiler treats this as non-isolated shared mutable state: any caller in the process can read or write it, and Swift has no guarantee that those accesses are serialized.
The kind of error we are working toward eliminating is:
This matters for ShopifyCheckoutKit.configuration because it is public process-wide configuration, and it currently also drives side effects like updating OSLogger.shared.logLevel.
Options considered
I considered both making configuration
@MainActoror wrapping the configuration inside anactorBoth of these result in suboptimal results,
actorwould make all reads async/await,@MainActorwould result in all reads needing to be MainActor isolated event for background tasks.This is not ideal for our library code, because reading log levels or constructing user agents, which should be sync and should not cross to the main actor, all then rely on tasks and async/await, it would complicate library code significantly with workarounds for sync to async
What
The "synchronous synchronization" option is an NSLock or Semaphore
Its a bit manual and can result in deadlocks, but essentially we wrap up reading/writing to this value behind an explicit lock.
For this binary single access mutual exclusion
NSLock/DispatchSemaphoreperform the same, butNSLockships with a helperwithLockto guarantee release around a closure (easy enough to add to semaphore, but no actual benefit).Before you merge
Important
platforms/swift/README.mdand/orplatforms/android/README.md)Releasing a new Swift version?
platforms/swift/ShopifyCheckoutKit.podspecplatforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swiftplatforms/swift/CHANGELOG.mdplatforms/swift/README.md(major version only)Releasing a new Android version?
versionNameinplatforms/android/lib/build.gradleplatforms/android/CHANGELOG.mdplatforms/android/README.mdTip
See the Contributing documentation for the full release process per platform.