New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initialize
performs blocking disk operations on the calling thread.
#101
Comments
We are having the same problem, due to the SDK, our Android app is launched with a long delay (from +3 s to + 12 s). We hope that this issue will be resolved as soon as possible. |
@ajalt @botmane I think the issue is caused by the initial creation of the sqlite database. We timed the init call ourselves, the first time the app opened it was longer than the other times, but no where near 12 s (it was still under 1 s). Subsequent app opening, it only took on avg 50-100ms. I am exploring putting the logic on a background thread. There is 1 issue, which is the database is required in order to resolve the device Id. Having the initialization logic run asynchronously on a background thread creates cases where |
My benchmarks show that the Amplitude initialization takes 200ms-500ms on normal app start (after initial creation). That's not 12 seconds, but it is still longer than any other component in our startup procedure. |
Thank you for the reply, @djih Please find attached 2 videos of our app, one without Amplitude SDK and one with it. videos_amplitude.zip. The phone used is an Asus Zenphone 2 551ML. This is a very serious matter for us. I hope you can do something about it soon. Otmane |
@botmane I am working on a fix now, expect to get it out by end of week |
@ajalt @botmane apologies for the delay. We have a test branch out with a fix: #109. You can download the compiled jars here:
Please install from the jar file and let us know if that resolves the issue. Thanks! |
I tested with the fix. I can't speak about any side effects of moving the initialization to the background thread, but it did fix the main thread stall and the associated StrictMode violations. |
@ajalt thanks for the update! I'm going to merge it in today and release a new version |
The docs recommend calling
Amplitude.getInstance().initialize(...)
in anonCreate
method. However, there are a number or database queries that take place in that call which block the thread they're called on. This has a noticeable impact on application start time.Here are a couple of the StrictMode reports:
Is it possible for the SDK to perform these calls on a background thread?
The text was updated successfully, but these errors were encountered: