at-internet / atinternet-apple-sdk

AT Internet mobile analytics solution for Apple devices
http://www.atinternet.com
MIT License
25 stars 47 forks source link

Crash on tracker.configuration.parameters #136

Open peseriusz opened 2 years ago

peseriusz commented 2 years ago

I found issue with access to

tracker.configuration.parameters

in (main thread):

class func sendOfflineHits(_ tracker: Tracker, forceSendOfflineHits: Bool, async: Bool = true)

in first line:

if((tracker.configuration.parameters["storage"] != "always" || forceSendOfflineHits)

image

It looks like there is parallel access to

tracker.configuration.parameters

second call comes from Tracker.swift

@objc public func setConfig(_ configuration: [String: String], override: Bool = false, sync: Bool = false, completionHandler: ((_ isSet: Bool) -> Void)?) {

saving value:

self.configuration.parameters[key] = value

from this code:

  let configurationOperation = BlockOperation(block: {
                        self.configuration.parameters[key] = value
                        if let identifier = self.configuration.parameters["identifier"], identifier != "" {
                            self.buffer.recomputeUserId()
                        }
                    })

(...)

TrackerQueue.sharedInstance.queue.addOperation(configurationOperation)

(background thread).

Access to dictionary is not threads safe in Swift.