I'm working on an application with large codebase. The problem is that when I launch the app from cold start state, It takes a lot of time to show the first screen of the app.
Based on here I checked the TTID for the app and it was terrifying:
Displayed com.example.myapp/.ui.MainActivity: +6s501ms
So I put some logs to check where is the problem:
class MyApp : Application() {
override fun onCreate() {
Log.d("Performance", "MyApp::onCreate::start")
super.onCreate()
// App initializations
Log.d("Performance", "MyApp::onCreate::end")
}
}
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Log.d("Performance", "MainActivity::onCreate::start")
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Ui initializations
Log.d("Performance", "MainActivity::onCreate::end")
}
}
After this I realized something strange:
---------------------------- PROCESS STARTED (4572) for package com.example.myapp ----------------------------
13:58:06.819 Performance D MyApp::onCreate::start
13:58:07.066 Performance D MyApp::onCreate::end
13:58:07.132 Performance D MainActivity::onCreate::start
13:58:07.566 Performance D MainActivity::onCreate::end
I noticed a strange thing. That there is a lot of delay (about 5 seconds) between PROCESS_START
and App:onCreate
(there isn't any timestamp for PROCESS_START
but I calculated manually). Also app creation and activity creation does not take more than 1 second.
So how can I solve this problem? What can be the cause of this issue?
from Delay between app process start and Application onCreate
No comments:
Post a Comment