Closed ncreated closed 2 months ago
Branch report: ncreated/RUM-1053/make-logs-api-concurrency-safe
Commit report: a3d8423
Test service: dd-sdk-ios
:white_check_mark: 0 Failed, 1880 Passed, 0 Skipped, 1m 16.57s Total Time :small_red_triangle_down: Test Sessions change in coverage: 2 decreased, 5 increased, 1 no change
What and why?
📦 This PR prepares DatadogLogs for compatibility with apps that enable "complete" concurrency checking in Swift 6.
I identified a potential data-race safety issue when passing instances of LoggerProtocol across isolation boundaries, such as to different threads:
How?
This issue is resolved by declaring Sendable conformance for
LoggerProtocol
:Since Xcode 15 uses
SWIFT_STRICT_CONCURRENCY: minimal
, which checks only explicitSendable
conformances, this:resulted in concurrency warnings elsewhere.
Instead of using
@unchecked Sendable
forRemoteLogger
,ConsoleLogger
, and some test types, I chose to address concurrency warnings properly, makingRemoteLogger
andConsoleLogger
fully checked Sendable types 👌.This required several major changes:
core
reference inRemoteLogger
with an immutable reference toFeatureScope
.FeatureScope
sendable, to facilitate similar work in other modules.RemoteLogger
after removing thecore
reference.SynchronizedAttributes
andSynchronizedTags
to ensureRemoteLogger
has onlySendable
members.Smaller adjustments were made as a consequence of spreading
Sendable
conformance. For example, markingBacktraceReporter
asSendable
required resolving issues in Crash Reporting tests, as this type is shared throughDatadogInternal
.Review checklist