amplitude / Amplitude-Swift

Native iOS/tvOS/macOS/watchOS SDK
MIT License
26 stars 20 forks source link

File opening errors in logger #175

Closed slava-semeniuk-ek closed 3 months ago

slava-semeniuk-ek commented 3 months ago

I'm currently tracking errors from Amplitude to our error analytics, and I've encountered a significant number of errors in our production app. All the errors are similar in nature, and here are a couple of examples:

I'm concerned about whether these errors could potentially cause any data issues?

SDK Version: 1.6.0 OS Info: iOS 17.*

crleona commented 3 months ago

Hi @slava-semeniuk-ek - Could you please double check the version of Amplitude-Swift you are using? 1.6.0 was just released two days ago. Any stack traces you can provide would also be very helpful.

slava-semeniuk-ek commented 3 months ago

For the latest version which uses 1.6.0, I could find the following errors:

NSLocalizedDescription: “v2-8” couldn’t be removed.

Logs AmplitudeErrorLogger.swift - Line 41 specialized AmplitudeMessageLogger.record(issue:message:) + 41 AmplitudeErrorLogger.swift - Line 24 protocol witness for Logger.error(message:) in conformance AmplitudeMessageLogger + 24 PersistentStorage.swift - Line 104 closure #1 in PersistentStorage.remove(eventBlock:) + 104 partial apply for thunk for @callee_guaranteed () -> () libdispatch.dylib _dispatch_sync_f_slow PersistentStorage.swift - Line 100 PersistentStorage.remove(eventBlock:) + 100 protocol witness for Storage.remove(eventBlock:) in conformance PersistentStorage IdentifyInterceptor.swift - Line 124 IdentifyInterceptor.getCombinedInterceptedIdentify() + 124 IdentifyInterceptor.swift - Line 157 implicit closure #2 in implicit closure #1 in closure #1 in IdentifyInterceptor.scheduleTransferInterceptedIdentifyEvent() + 157 IdentifyInterceptor.swift - Line 182 closure #1 in IdentifyInterceptor.scheduleTransferInterceptedIdentifyEvent() + 182 QueueTimer.swift - Line 38 closure #1 in QueueTimer.init(interval:once:queue:handler:) + 38

The file “v2-243” couldn’t be opened using text encoding Unicode (UTF-8).

Logs AmplitudeErrorLogger.swift - Line 24 protocol witness for Logger.error(message:) in conformance AmplitudeMessageLogger + 24 PersistentStorage.swift - Line 94 PersistentStorage.getEventsString(eventBlock:) + 94 protocol witness for Storage.getEventsString(eventBlock:) in conformance PersistentStorage EventPipeline.swift - Line 70 closure #1 in EventPipeline.flush(completion:) + 70 thunk for @callee_guaranteed () -> () _dispatch_lane_barrier_sync_invoke_and_complete EventPipeline.swift - Line 65 EventPipeline.flush(completion:) + 65 EventPipeline.swift - Line 34 closure #1 in EventPipeline.init(amplitude:) + 34 QueueTimer.swift - Line 38 closure #1 in QueueTimer.init(interval:once:queue:handler:) + 38
crleona commented 3 months ago

Thanks @slava-semeniuk-ek! This was caused by some concurrency issues that were largely resolved in 1.5.0+, but we missed one callback in IdentifyInterceptor, which I've fixed in https://github.com/amplitude/Amplitude-Swift/pull/176. I've also added some additional diagnostic logging which will help us catch similar issues in the future. Our write patterns are such that events in one of the removed files should have been either uploaded or re-written to another file, so we don't believe this has caused any data issues.

crleona commented 3 months ago

This should be released in 1.6.1

slava-semeniuk-ek commented 2 months ago

@crleona hey, hey, have you had a chance to check the additional diagnostic logging? It looks like these errors are still appearing in Amplitude 1.6.2

slava-semeniuk-ek commented 1 month ago

@crleona It seems it's still not fixed for 1.7.0. Could you please check the additional diagnostic logging? Let me know If you need any details from my side