diff --git a/CHANGES.rst b/CHANGES.rst index 126d457e7..45f6de952 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,7 @@ Changes to be released in next version * Xcode 12: Make Xcode 12 and fastlane(xcodebuild) happy while some pods are not updated. * Update Gemfile.lock. * MXAnalyticsDelegate: Make it fully agnostic on tracked data. + * MXProfiler: Use this new module to track launch animation time reliably. * KeyValueStore improvements. 🐛 Bugfix diff --git a/Riot/Modules/Application/LegacyAppDelegate.m b/Riot/Modules/Application/LegacyAppDelegate.m index bf303c6ef..c08206a8d 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.m +++ b/Riot/Modules/Application/LegacyAppDelegate.m @@ -204,7 +204,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni The launch animation container view */ UIView *launchAnimationContainerView; - NSDate *launchAnimationStart; } @property (strong, nonatomic) UIAlertController *mxInAppNotification; @@ -454,9 +453,15 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni _handleSelfVerificationRequest = YES; // Configure our analytics. It will indeed start if the option is enabled - [MXSDKOptions sharedInstance].analyticsDelegate = [Analytics sharedInstance]; + Analytics *analytics = [Analytics sharedInstance]; + [MXSDKOptions sharedInstance].analyticsDelegate = analytics; [DecryptionFailureTracker sharedInstance].delegate = [Analytics sharedInstance]; - [[Analytics sharedInstance] start]; + + MXBaseProfiler *profiler = [MXBaseProfiler new]; + profiler.analytics = analytics; + [MXSDKOptions sharedInstance].profiler = profiler; + + [analytics start]; self.localAuthenticationService = [[LocalAuthenticationService alloc] initWithPinCodePreferences:[PinCodePreferences shared]]; @@ -588,6 +593,9 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni [self.pushNotificationService applicationDidEnterBackground]; + // Pause profiling + [MXSDKOptions.sharedInstance.profiler pause]; + // Analytics: Force to send the pending actions [[DecryptionFailureTracker sharedInstance] dispatch]; [[Analytics sharedInstance] dispatch]; @@ -599,6 +607,8 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. + [MXSDKOptions.sharedInstance.profiler resume]; + // Force each session to refresh here their publicised groups by user dictionary. // When these publicised groups are retrieved for a user, they are cached and reused until the app is backgrounded and enters in the foreground again for (MXSession *session in mxSessionArray) @@ -2407,7 +2417,9 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni [window addSubview:launchLoadingView]; launchAnimationContainerView = launchLoadingView; - launchAnimationStart = [NSDate date]; + + [MXSDKOptions.sharedInstance.profiler startMeasuringTaskWithName:kMXAnalyticsStartupLaunchScreen + category:kMXAnalyticsStartupCategory]; } } @@ -2415,16 +2427,14 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni { if (launchAnimationContainerView) { - NSTimeInterval duration = [[NSDate date] timeIntervalSinceDate:launchAnimationStart]; - NSLog(@"[AppDelegate] hideLaunchAnimation: LaunchAnimation was shown for %.3fms", duration * 1000); - - // Track it on our analytics - [[MXSDKOptions sharedInstance].analyticsDelegate trackDuration:duration - category:kMXAnalyticsStartupCategory - name:kMXAnalyticsStartupLaunchScreen]; - - // TODO: Send durationMs to Piwik - // Such information should be the same on all platforms + id profiler = MXSDKOptions.sharedInstance.profiler; + MXTaskProfile *launchTaskProfile = [profiler taskProfileWithName:kMXAnalyticsStartupLaunchScreen category:kMXAnalyticsStartupCategory]; + if (launchTaskProfile) + { + [profiler stopMeasuringTaskWithProfile:launchTaskProfile]; + + NSLog(@"[AppDelegate] hideLaunchAnimation: LaunchAnimation was shown for %.3fms", launchTaskProfile.duration * 1000); + } [self->launchAnimationContainerView removeFromSuperview]; self->launchAnimationContainerView = nil;