We recently integrated App Startup library into a project with a somewhat complex and time-consuming initialization logic that may take (in the worst case) up to several seconds. So we've got around 15 Initializers, some of them even trigger network / API calls.
It is not covered anywhere in the docs of the library, so I wonder: are there any limitations or time restrictions when it comes to App Startup initializers? Is it okay to do networking stuff with them? And, what's even more important: can long-running initializers actually trigger ANR dialog to appear?
Essentially, my question is not specific to App Startup, it's more like a general question about application initialization that happens before or during Application::onCreate
call:
- are there any time restrictions for this method?
- can long initialization trigger ANR dialogs?
As per the docs, it seems that ANR can be shown mostly when the UI gets irresponsive for 5+ seconds, but does this apply to the initialization step? Given that the users are not expected to interact with anything before the first activity is created, i.e. there's no UI at this stage.
My gut feeling is that it should be fine to do from a technical point of view, putting something like Thead.sleep(10_000L)
into onCreate
also does not seem to trigger any ANRs, but wondering if somebody has made wider research here and maybe can share some feedback from real production projects, although I think that hitting 5 second init time is not very common :)