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

StrictMode DiskReadViolation during initialization #276

Closed
HGaurav328 opened this issue Sep 4, 2024 · 6 comments
Closed

StrictMode DiskReadViolation during initialization #276

HGaurav328 opened this issue Sep 4, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@HGaurav328
Copy link

Hey all.

We are using below version of the SDK inside our app.
com.newrelic.agent.android:agent-gradle-plugin:7.5.1,
com.newrelic.agent.android:android-agent:7.5.1

During the initialization of the SDK with StrictMode enabled like so:

StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build())

StrictMode policy violation; ~duration=88 ms: android.os.strictmode.DiskReadViolation (Ask Gemini)
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1666)
at libcore.io.BlockGuardOs.access(BlockGuardOs.java:74)
at libcore.io.ForwardingOs.access(ForwardingOs.java:128)
at android.app.ActivityThread$AndroidOs.access(ActivityThread.java:8054)
at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:313)
at java.io.File.exists(File.java:813)
at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:790)
at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:781)
at android.app.ContextImpl.getFilesDir(ContextImpl.java:826)
at android.content.ContextWrapper.getFilesDir(ContextWrapper.java:286)
at com.newrelic.agent.android.util.OfflineStorage.(OfflineStorage.java:26)
at com.newrelic.agent.android.AndroidAgentImpl.(AndroidAgentImpl.java:119)
at com.newrelic.agent.android.AndroidAgentImpl.init(AndroidAgentImpl.java:636)
at com.newrelic.agent.android.NewRelic.start(NewRelic.java:301)
at com.viewlift.hoichoi.datasource.startup.NewRelicInitializer.initializeNewRelic(NewRelicInitializer.kt:27)
at com.viewlift.hoichoi.datasource.startup.NewRelicInitializer.create(NewRelicInitializer.kt:12)
at com.viewlift.hoichoi.datasource.startup.NewRelicInitializer.create(NewRelicInitializer.kt:9)
at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:180)
at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:138)
at androidx.startup.AppInitializer.initializeComponent(AppInitializer.java:117)
at com.viewlift.hoichoi.App.onAppInitializer(App.kt:61)
at com.viewlift.hoichoi.App.onCreate(App.kt:53)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1316)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6998)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2236)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8177)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

@HGaurav328 HGaurav328 added the bug Something isn't working label Sep 4, 2024
@ndesai-newrelic
Copy link
Contributor

@HGaurav328 we created internal bug ticket for this.

@HGaurav328
Copy link
Author

HGaurav328 commented Sep 18, 2024

Hi Any update on it or can we initialization NewRelic in background thread.

@ndesai-newrelic
Copy link
Contributor

@HGaurav328 we are working on it, we will fix it for next release.

@ywang-nr
Copy link
Contributor

@HGaurav328 Thank you for raising this issue, upon investigating, could you help me with few questions?

I noticed with your implementation

  • StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build())

All the violations happen within NR library shouldn't be affecting your functionality of the application, since they are just logs(noise) that indicate places are running in the main thread within the NR library. Is this true?

  • Unless you plan to use penaltyDeath() to kill the process?
  • Do you plan to release your app with StrictMode on?

@ywang-nr ywang-nr added the question Further information is requested label Sep 19, 2024
@HGaurav328
Copy link
Author

No We just enable StrictMode on debug build. because we got lots of ANR from crashlytics dashboard which related to NewRelic sdk. we attached crashlytics logs file.
com.viewlift.hoichoi_issue_e8d399d5266c540a0a018ea50c98cf90_ANR_session_66ED6B0303A300013E8C01C42BB09350_DNE_0_v2_stacktrace.txt

@ndesai-newrelic
Copy link
Contributor

@HGaurav328 this anr issue is already fixed in 7.4.0 and higher agent version.

@ywang-nr ywang-nr removed the question Further information is requested label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants