Skip to content
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

Main Thread IO done on SDK initialization #320

Closed
MihaiHoinarescu opened this issue Feb 25, 2020 · 2 comments
Closed

Main Thread IO done on SDK initialization #320

MihaiHoinarescu opened this issue Feb 25, 2020 · 2 comments

Comments

@MihaiHoinarescu
Copy link

Everytime the SDK initializes we get a bunch of strict mode violations.

It seems like the SDK is doing some IO in onPostExecute of an AsyncTask. It would be great if this IO could be done on a different thread so it doesn't slow down the user experience.

I've added the stack trace below.

01-21 19:15:06.023 18420 18420 D StrictMode: at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1556)
01-21 19:15:06.023 18420 18420 D StrictMode: at libcore.io.BlockGuardOs.access(BlockGuardOs.java:69)
01-21 19:15:06.023 18420 18420 D StrictMode: at libcore.io.ForwardingOs.access(ForwardingOs.java:73)
01-21 19:15:06.023 18420 18420 D StrictMode: at android.app.ActivityThread$AndroidOs.access(ActivityThread.java:7246)
01-21 19:15:06.023 18420 18420 D StrictMode: at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:281)
01-21 19:15:06.023 18420 18420 D StrictMode: at java.io.File.exists(File.java:815)
01-21 19:15:06.023 18420 18420 D StrictMode: at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:645)
01-21 19:15:06.023 18420 18420 D StrictMode: at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:636)
01-21 19:15:06.023 18420 18420 D StrictMode: at android.app.ContextImpl.getFilesDir(ContextImpl.java:681)
01-21 19:15:06.023 18420 18420 D StrictMode: at android.app.ContextImpl.fileList(ContextImpl.java:792)
01-21 19:15:06.023 18420 18420 D StrictMode: at android.content.ContextWrapper.fileList(ContextWrapper.java:233)
01-21 19:15:06.023 18420 18420 D StrictMode: at com.optimizely.ab.android.shared.Cache.exists(Cache.java:69)
01-21 19:15:06.023 18420 18420 D StrictMode: at com.optimizely.ab.android.datafile_handler.DatafileCache.exists(DatafileCache.java:65)
01-21 19:15:06.023 18420 18420 D StrictMode: at com.optimizely.ab.android.datafile_handler.DefaultDatafileHandler.isDatafileSaved(DefaultDatafileHandler.java:225)
01-21 19:15:06.023 18420 18420 D StrictMode: at com.optimizely.ab.android.sdk.OptimizelyManager.isDatafileCached(OptimizelyManager.java:412)
01-21 19:15:06.023 18420 18420 D StrictMode: at com.optimizely.ab.android.sdk.OptimizelyManager.getDatafile(OptimizelyManager.java:281)
01-21 19:15:06.023 18420 18420 D StrictMode: at com.optimizely.ab.android.sdk.OptimizelyManager$2.onDatafileLoaded(OptimizelyManager.java:343)
01-21 19:15:06.023 18420 18420 D StrictMode: at com.optimizely.ab.android.datafile_handler.DefaultDatafileHandler$1.onDatafileLoaded(DefaultDatafileHandler.java:78)
01-21 19:15:06.023 18420 18420 D StrictMode: at com.optimizely.ab.android.datafile_handler.DatafileLoader.notify(DatafileLoader.java:81)
01-21 19:15:06.023 18420 18420 D StrictMode: at com.optimizely.ab.android.datafile_handler.DatafileLoader.access$000(DatafileLoader.java:35)
01-21 19:15:06.023 18420 18420 D StrictMode: at com.optimizely.ab.android.datafile_handler.DatafileLoader$RequestDatafileFromClientTask.onPostExecute(DatafileLoader.java:134)
01-21 19:15:06.023 18420 18420 D StrictMode: at com.optimizely.ab.android.datafile_handler.DatafileLoader$RequestDatafileFromClientTask.onPostExecute(DatafileLoader.java:85)
01-21 19:15:06.023 18420 18420 D StrictMode: at android.os.AsyncTask.finish(AsyncTask.java:755)
01-21 19:15:06.023 18420 18420 D StrictMode: at android.os.AsyncTask.access$900(AsyncTask.java:192)
01-21 19:15:06.023 18420 18420 D StrictMode: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:772)
01-21 19:15:06.023 18420 18420 D StrictMode: at android.os.Handler.dispatchMessage(Handler.java:107)
01-21 19:15:06.023 18420 18420 D StrictMode: at android.os.Looper.loop(Looper.java:214)
01-21 19:15:06.023 18420 18420 D StrictMode: at android.app.ActivityThread.main(ActivityThread.java:7356)
01-21 19:15:06.023 18420 18420 D StrictMode: at java.lang.reflect.Method.invoke(Native Method)
01-21 19:15:06.023 18420 18420 D StrictMode: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
01-21 19:15:06.023 18420 18420 D StrictMode: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
01-21 19:15:06.024 18420 18420 D StrictMode: StrictMode policy violation; ~duration=106 ms: android.os.strictmode.DiskReadViolation
01-21 19:15:06.024 18420 18420 D StrictMode: at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1556)
01-21 19:15:06.024 18420 18420 D StrictMode: at java.io.UnixFileSystem.list(UnixFileSystem.java:344)
01-21 19:15:06.024 18420 18420 D StrictMode: at java.io.File.list(File.java:1131)
01-21 19:15:06.024 18420 18420 D StrictMode: at android.os.FileUtils.listOrEmpty(FileUtils.java:1212)
01-21 19:15:06.024 18420 18420 D StrictMode: at android.app.ContextImpl.fileList(ContextImpl.java:792)
01-21 19:15:06.024 18420 18420 D StrictMode: at android.content.ContextWrapper.fileList(ContextWrapper.java:233)
01-21 19:15:06.024 18420 18420 D StrictMode: at com.optimizely.ab.android.shared.Cache.exists(Cache.java:69)
01-21 19:15:06.024 18420 18420 D StrictMode: at com.optimizely.ab.android.datafile_handler.DatafileCache.exists(DatafileCache.java:65)
01-21 19:15:06.024 18420 18420 D StrictMode: at com.optimizely.ab.android.datafile_handler.DefaultDatafileHandler.isDatafileSaved(DefaultDatafileHandler.java:225)
01-21 19:15:06.024 18420 18420 D StrictMode: at com.optimizely.ab.android.sdk.OptimizelyManager.isDatafileCached(OptimizelyManager.java:412)
01-21 19:15:06.024 18420 18420 D StrictMode: at com.optimizely.ab.android.sdk.OptimizelyManager.getDatafile(OptimizelyManager.java:281)
01-21 19:15:06.024 18420 18420 D StrictMode: at com.optimizely.ab.android.sdk.OptimizelyManager$2.onDatafileLoaded(OptimizelyManager.java:343)
01-21 19:15:06.024 18420 18420 D StrictMode: at com.optimizely.ab.android.datafile_handler.DefaultDatafileHandler$1.onDatafileLoaded(DefaultDatafileHandler.java:78)
01-21 19:15:06.024 18420 18420 D StrictMode: at com.optimizely.ab.android.datafile_handler.DatafileLoader.notify(DatafileLoader.java:81)
01-21 19:15:06.024 18420 18420 D StrictMode: at com.optimizely.ab.android.datafile_handler.DatafileLoader.access$000(DatafileLoader.java:35)
01-21 19:15:06.024 18420 18420 D StrictMode: at com.optimizely.ab.android.datafile_handler.DatafileLoader$RequestDatafileFromClientTask.onPostExecute(DatafileLoader.java:134)
01-21 19:15:06.024 18420 18420 D StrictMode: at com.optimizely.ab.android.datafile_handler.DatafileLoader$RequestDatafileFromClientTask.onPostExecute(DatafileLoader.java:85)
01-21 19:15:06.024 18420 18420 D StrictMode: at android.os.AsyncTask.finish(AsyncTask.java:755)
01-21 19:15:06.024 18420 18420 D StrictMode: at android.os.AsyncTask.access$900(AsyncTask.java:192)
01-21 19:15:06.024 18420 18420 D StrictMode: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:772)
01-21 19:15:06.024 18420 18420 D StrictMode: at android.os.Handler.dispatchMessage(Handler.java:107)
01-21 19:15:06.024 18420 18420 D StrictMode: at android.os.Looper.loop(Looper.java:214)
01-21 19:15:06.024 18420 18420 D StrictMode: at android.app.ActivityThread.main(ActivityThread.java:7356)
01-21 19:15:06.024 18420 18420 D StrictMode: at java.lang.reflect.Method.invoke(Native Method)
01-21 19:15:06.024 18420 18420 D StrictMode: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
01-21 19:15:06.024 18420 18420 D StrictMode: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
01-21 19:15:06.024 18420 18690 I UserProfileCache: Loaded user profile cache from disk.```
@quibi-jlk
Copy link

Thanks for looking into this @thomaszurkan-optimizely! FWIW, this is causing some noticeable jank during our app startup. Is there an ETA for the fix?

@thomaszurkan-optimizely
Copy link
Contributor

@quibi-jlk we should be doing a patch release soon.

quibi-jlk added a commit to quibi-jlk/mparticle-android-integration-optimizely that referenced this issue Mar 13, 2020
This version fixes a bad strictmode violation with many disk reads on the main thread. optimizely/android-sdk#320.

See full diff here: optimizely/android-sdk@3.2.1...3.5.0
@jaeopt jaeopt closed this as completed Mar 13, 2020
willpassidomo pushed a commit to mparticle-integrations/mparticle-android-integration-optimizely that referenced this issue Mar 14, 2020
This version fixes a bad strictmode violation with many disk reads on the main thread. optimizely/android-sdk#320.

See full diff here: optimizely/android-sdk@3.2.1...3.5.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants