mixpanel / mixpanel-swift

Official iOS (Swift) Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
433 stars 234 forks source link

Crash in Persistence.swift #152

Closed DarkoDamjanovic closed 6 years ago

DarkoDamjanovic commented 7 years ago

http://crashes.to/s/6de7dc0ea4a

I'm not sure which version this was, I am quite sure it was 2.2.2, but today I updated the pod and saw some strange result:

Installing Mixpanel-swift 2.2.1 (was 2.2.2)

It seems that the pod was re-set to another version...? (maybe I miss something here...)

yarneo commented 7 years ago

Hey @DarkoDamjanovic , it looks like based on your crash line that you have the older version of our library. That result definitely is weird that it downgraded your version. Could you try doing pod update Mixpanel-swift and see if it upgrades you to 2.2.2? Thanks!

DarkoDamjanovic commented 7 years ago

@yarneo pod update Mixpanel-swift leads now to:

Installing Mixpanel-swift 2.2.1 (was 2.2.1)

But maybe my pod file entry is not correct?

pod 'Mixpanel-swift', :git => 'https://github.com/mixpanel/mixpanel-swift.git', :branch => 'swift4'

Thanks for the help.

jeffaburt commented 7 years ago

FWIW it looks like the version was goofed when heartbeating master into swift4 in https://github.com/mixpanel/mixpanel-swift/commit/09abe18914dcd479aaeb0ade97e145d8807679b9#diff-f2dbbce823cb5a139355e0ac891e2e53R1.

yarneo commented 7 years ago

seems that way. Thanks for the heads up, I'll investigate today

DarkoDamjanovic commented 6 years ago

Any updates? I still get this line on pod update:

Installing Mixpanel-swift 2.2.1 (was 2.2.1)

yusuftor commented 6 years ago

I also get this crash (I wasn't using the swift4 version). I have switched to the Swift 4 branch now and it does downgrade to 2.2.1.

pchien commented 6 years ago

I just updated the podspec on swift4 to 2.2.2 to match master. Sorry about the regression. Hopefully that helps.

yusuftor commented 6 years ago

Thanks! Does this fix the Persistence crash though? I was using the Swift 3 version of 2.2.2 before and still had the crash.

Sent with GitHawk

pchien commented 6 years ago

Hey @DarkoDamjanovic @yusuftor I haven't been able to reproduce or figure out this crash. Do you guys have any more info? Is it always coming from Mixpanel.track?

RamblinWreck77 commented 6 years ago

Have about 30 crashes in production with this. Fabric shows

"Persistence.swift line 129 specialized static Persistence.archiveToFile(Persistence.ArchiveType, object : Any, token : String) -> ()"

Crashed: globalLock EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000000000007d8 "

My app launches a lot in the background, and this crash has exclusively happened for my users when the app launches in the background.

I'm on the latest version

zihejia commented 6 years ago

hi @RamblinWreck77, Thanks for the information, we will have a look on this.

mgfeldman commented 6 years ago

@zihejia Any updates on this? We're having a lot of instances of a seemingly related crash to this. Our app also launches in the background often.

Fabric shows this as the crash source:

static Persistence.unarchiveWithFilePath(String) -> Any?

"Fatal Exception: NSArchiverArchiveInconsistency *** -[NSKeyedUnarchiver decodeObjectForKey:]: missing class information for object"

We are on 2.3.3 and our project is in Swift 3.

Thanks

phoney commented 6 years ago

Just a note if this isn't obvious: This is an objective-C assertion failure/exception inside NSKeyedUnarchiver. Maybe the file is corrupt or there's a problem reading it in the background (is file encryption set that prevents reading it in the background?) It's not possible to catch objective-c exceptions in swift code. When I ran into a similar case I had to write some objective-c code that was called from swift that caught the exception. Not sure if you need to do that though.

keithZumper commented 6 years ago

The same crash is still occurring for me.

Crashed: globalLock
0  CoreFoundation                 0x1835ddf48 _CFArrayReplaceValues + 836
1  CoreFoundation                 0x1835ddbf4 CFArrayAppendValue + 236
2  CoreFoundation                 0x1835f976c _flattenPlist + 292
3  CoreFoundation                 0x1835f9908 _flattenPlist + 704
4  CoreFoundation                 0x1835f9898 _flattenPlist + 592
5  CoreFoundation                 0x18367f0c0 __CFBinaryPlistWriteOrPresize + 196
6  Foundation                     0x184075180 -[NSKeyedArchiver finishEncoding] + 588
7  Foundation                     0x184130ae8 +[NSKeyedArchiver archiveRootObject:toFile:] + 228
8  Mixpanel                       0x1040fc90c specialized static Persistence.archiveToFile(Persistence.ArchiveType, object : Any, token : String) -> () (Persistence.swift:136)
9  Mixpanel                       0x1040f46cc People.(addPeopleRecordToQueueWithAction(String, properties : [String : Any]) -> ()).(closure #1).(closure #4) (People.swift)
10 Mixpanel                       0x1040fdf68 ReadWriteLock.(read(closure : () -> ()) -> ()).(closure #1) (ReadWriteLock.swift:20)
11 Mixpanel                       0x1040b62f4 _T0Ieg_IeyB_TR (MixpanelInstance.swift)
12 libdispatch.dylib              0x18300ca60 _dispatch_client_callout + 16
13 libdispatch.dylib              0x1830156e4 _dispatch_sync_invoke_and_complete + 56
14 Mixpanel                       0x1040f4344 People.(addPeopleRecordToQueueWithAction(String, properties : [String : Any]) -> ()).(closure #1) (People.swift)
15 Mixpanel                       0x1040b62f4 _T0Ieg_IeyB_TR (MixpanelInstance.swift)
16 libdispatch.dylib              0x18300caa0 _dispatch_call_block_and_release + 24
17 libdispatch.dylib              0x18300ca60 _dispatch_client_callout + 16
18 libdispatch.dylib              0x1830169b4 _dispatch_queue_serial_drain$VARIANT$mp + 608
19 libdispatch.dylib              0x1830172fc _dispatch_queue_invoke$VARIANT$mp + 336
20 libdispatch.dylib              0x183017cc8 _dispatch_root_queue_drain_deferred_wlh$VARIANT$mp + 340
21 libdispatch.dylib              0x183020098 _dispatch_workloop_worker_thread$VARIANT$mp + 668
22 libsystem_pthread.dylib        0x18333fe70 _pthread_wqthread + 860
23 libsystem_pthread.dylib        0x18333fb08 start_wqthread + 4
zihejia commented 6 years ago

v2.4.5 has a fix to Persistence crash, so close this one now.