google / iosched

The Google I/O Android App
Apache License 2.0
21.77k stars 6.2k forks source link

Add reporting when the app is fully drawn to the framework #351

Closed benbaxter closed 4 years ago

benbaxter commented 4 years ago

Invoking Activity#reportFullyDrawn() once the data has been loaded and the screen has been rendered to the user.

The entry points into the app are the OnboardingActivity, MainActivity, and SessionDetailsActvitiy. Each of these report when they have been fully drawn independently to the framework. The Android framework prints a log statement as follows:

I/ActivityTaskManager: Fully drawn com.google.samples.apps.iosched/.ui.MainActivity: +3s493ms

This is used for measuring startup time and is a helpful signal when diagnosing startup performance issues. Check out the vitals documentation for more about the usage of reportFullyDrawn().

benbaxter commented 4 years ago

Part of me wonders if we need to go through ViewModels to report this since it's specific to the UI/platform and doesn't really impact any business logic. Would it be enough to just rely on doOnLayout in our activities?

Good point! I removed the view model middle layer. Originally I thought multiple views would report when they had finished drawing but since doOnLayout also handles when the subviews have completed layout, the complexity was greatly reduced.