Skip to content

SessionManager is "Publishing changes from background thread" #270

@mattcorey

Description

@mattcorey

Hi - with SDK versions 2.10.0 and 2.11.0, I'm getting a bunch of these errors both from Xcode 26.1.1, and from the Console app (when running in TestFlight):

Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates.

These are accompanied by the dreaded 'purple warning' in Xcode.

These warnings seem to occur roughly once/second, and Xcode is pointing me to the following lines:

private var deletedSessionsCount: Int {
        get { TelemetryDeck.customDefaults?.integer(forKey: Self.deletedSessionsCountKey) ?? 0 }
        set {
            self.persistenceQueue.async {
                TelemetryDeck.customDefaults?.set(newValue, forKey: Self.deletedSessionsCountKey).  <-- Here (line 53)
            }
        }
    }
        self.persistenceQueue.async {
            if let updatedSessionData = try? Self.encoder.encode(self.recentSessions) {
                TelemetryDeck.customDefaults?.set(updatedSessionData, forKey: Self.recentSessionsKey) <-- Here (line 197)
            }
        }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions