twilio / conversations-ios

SPM releases

Home Page:https://www.twilio.com/docs/conversations/ios/changelog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

App Hanging +[TCHHelpers dateFromTimestampString:]

anish190 opened this issue · comments

SDK version

4.0.3

Device model

iPhone 13 Pro Max

OS version

17.1.2

Issue description

I utilize Sentry for monitoring the performance of the application. I recently came across an app hang issue within the dateFromTimestampString method.

Thread 0
0   libicucore.A.dylib              0x343cfb508         icu::Transliterator::_getAvailableVariant
1   libicucore.A.dylib              0x343cfd05c         icu::TimeZoneFormat::parseOffsetPattern
2   libicucore.A.dylib              0x343cfc1a8         icu::TimeZoneFormat::initGMTOffsetPatterns
3   libicucore.A.dylib              0x343cfbaf8         icu::TimeZoneFormat::TimeZoneFormat
4   libicucore.A.dylib              0x343cfc99c         icu::TimeZoneFormat::createInstance
5   libicucore.A.dylib              0x343ce2330         icu::SimpleDateFormat::tzFormat
6   libicucore.A.dylib              0x343ce4028         icu::SimpleDateFormat::subParse
7   libicucore.A.dylib              0x343ce2ddc         icu::SimpleDateFormat::parse
8   libicucore.A.dylib              0x343d1633c         udat_parseCalendar
9   CoreFoundation                  0x330a533f8         CFDateFormatterGetAbsoluteTimeFromString
10  CoreFoundation                  0x330a53198         CFDateFormatterCreateDateFromString
11  Foundation                      0x32e9702bc         getObjectValue
12  Foundation                      0x32e97c04c         -[NSDateFormatter getObjectValue:forString:errorDescription:]
13  Foundation                      0x32e97bf4c         -[NSDateFormatter dateFromString:]
14  TwilioConversationsClient       0x103f5b69c         +[TCHHelpers dateFromTimestampString:] (TCHHelpers.mm:187)
15  TwilioConversationsClient       0x103f203e0         -[TCHMessage dateCreatedAsDate] (TCHMessage.mm:109)**
16  MyApp                 0x202f692ec         MutableCollection<T>._insertionSort
17  MyApp                 0x202f67aec         UnsafeMutableBufferPointer._stableSortImpl
18  MyApp                 0x202f64b94         MutableCollection<T>.sort
19  MyApp                 0x202f63b9c         GroupChannelsViewModel.groupConversationsByDate
20  MyApp                 0x202f63204         GroupChannelsViewModel.sortAndLoad
21  MyApp                 0x202f629d0         GroupChannelsViewModel.loadConversations
22  MyApp                 0x202f6557c         GroupChannelsViewModel.addObserver
23  MyApp                 0x2028ab4c0         ObservableType.subscribe
24  MyApp                 0x20285f5a8         AnonymousObserver.onCore
25  MyApp                 0x2028adf4c         ObserverBase.on
26  MyApp                 0x2028ae090         ObserverBase<T>
27  MyApp                 0x202866fe8         BehaviorSubject.synchronized_subscribe<T>
28  MyApp                 0x202866d04         BehaviorSubject.subscribe<T>
29  MyApp                 0x2028aad44         ObservableType.subscribe
30  MyApp                 0x202f65460         GroupChannelsViewModel.addObserver
31  MyApp                 0x202f622a8         GroupChannelsViewModel.viewDidLoad
32  MyApp                 0x202f5e4b4         GroupChannelsScene.viewDidLoad
33  MyApp                 0x202f5e5d8         GroupChannelsScene.viewDidLoad
34  UIKitCore                       0x3350206c4         -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled]
35  UIKitCore                       0x334dd55e0         -[UIViewController loadViewIfRequired]
36  UIKitCore                       0x334dd3dd4         -[UIViewController view]
37  UIKitCore                       0x3354b28f0         -[UINavigationController _startCustomTransition:]
38  UIKitCore                       0x334ed7f74         -[UINavigationController _startDeferredTransitionIfNeeded:]
39  UIKitCore                       0x334ed766c         -[UINavigationController __viewWillLayoutSubviews]
40  UIKitCore                       0x334ed75d0         -[UILayoutContainerView layoutSubviews]
41  UIKitCore                       0x334df2690         -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
42  QuartzCore                      0x3335e91bc         CA::Layer::layout_if_needed
43  QuartzCore                      0x3335e8d44         CA::Layer::layout_and_display_if_needed
44  QuartzCore                      0x3335ef274         CA::Context::commit_transaction
45  QuartzCore                      0x3335e8570         CA::Transaction::commit
46  QuartzCore                      0x3335e8218         CA::Transaction::flush_as_runloop_observer
47  UIKitCore                       0x334e6a970         _UIApplicationFlushCATransaction
48  UIKitCore                       0x334e6a488         _UIUpdateSequenceRun
49  UIKitCore                       0x334e69b78         schedulerStepScheduledMainSection
50  UIKitCore                       0x334e69c34         runloopSourceCallback
51  CoreFoundation                  0x3309af318         __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
52  CoreFoundation                  0x3309ae594         __CFRunLoopDoSource0
53  CoreFoundation                  0x3309acd48         __CFRunLoopDoSources0
54  CoreFoundation                  0x3309aba84         __CFRunLoopRun
55  CoreFoundation                  0x3309ab664         CFRunLoopRunSpecific
56  GraphicsServices                0x3b71715e8         GSEventRunModal
57  UIKitCore                       0x334fec2b0         -[UIApplication _run]
58  UIKitCore                       0x334feb8ec         UIApplicationMain
59  MyApp                 0x202491ca4         main

That's quite unusual, ICU core is an Apple system library on iPhone.

As far as I can see, icu::Transliterator::_getAvailableVariant should not be able to hang, it's a loop but with clear termination condition and maximum of 32 iterations.

@berkus Do you have any recommendations on where to investigate?

@anish190 Yes, one way would be to figure out which message SID it hangs on, and then fetch that message using REST api and inspect its date fields to see if something is amiss there.

It seems like problematic is dateCreated (dateCreatedAsDate), and it should always be set by the service.

For a quick workaround, in your GroupChannelsViewModel.groupConversationsByDate use dateCreated (which is a String) instead of dateCreatedAsDate and then parse it yourself, logging it to sentry along the way.

Thanks for the direction. Will look into it.

@anish190 do tell what you find out!

@berkus Sorry. I was super busy due to the release. I'll spend some time this week and update you,

@berkus After switching from dateCreatedAsDate to dateCreated, I haven't encountered the previously mentioned issue in Sentry. I plan to keep an eye on this over the next few builds and will verify if this adjustment resolves the problem.