question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JobManager.create() will take much time

See original GitHub issue

Hi,

If I add below JobManager.create() codes in Application.onCreate(), StrictMode$StrictModeDiskReadViolation warning is showed in log. JobManager.create(this).addJobCreator(MyJobCreator())

06-05 17:27:36.740 25915-25915/? D/StrictMode: StrictMode policy violation; ~duration=106 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=65567 violation=2 at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1293) at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:249) at java.io.File.exists(File.java:780) at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:541) at android.app.ContextImpl.getPreferencesDir(ContextImpl.java:497) at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:656) at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:374) at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:171) at com.evernote.android.job.JobStorage.<init>(JobStorage.java:123) at com.evernote.android.job.JobStorage.<init>(JobStorage.java:119) at com.evernote.android.job.JobManager.<init>(JobManager.java:155) at com.evernote.android.job.JobManager.create(JobManager.java:112)

Calling JobManager.create() in Application.onCreate() may influence app launching time. May I call JobManager.create() in second thread?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12

github_iconTop GitHub Comments

2reactions
Yrleccommented, May 7, 2019

Hi! We’re also seeing a lot of ANRs when creating the JobManager. Like this:

at com.evernote.android.job.JobManager.<init> (JobManager.java:149) at com.evernote.android.job.JobManager.create (JobManager.java:102)

  • locked <@addr=0x133b7418> (a java.lang.Class<com.evernote.android.job.h>) at com.degoo.android.DegooMultiDexApplication.initJobCreator (DegooMultiDexApplication.java:186) at com.degoo.android.DegooMultiDexApplication.onCreate (DegooMultiDexApplication.java:113) at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1035) at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6012) at android.app.ActivityThread.access$1700 (ActivityThread.java:218) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1779) at android.os.Handler.dispatchMessage (Handler.java:102) at android.os.Looper.loop (Looper.java:145) at android.app.ActivityThread.main (ActivityThread.java:6917) at java.lang.reflect.Method.invoke! (Native method) at java.lang.reflect.Method.invoke (Method.java:372)

How come this has to be done on the main thread?

1reaction
zegnuscommented, Apr 2, 2019

@vRallev How do we know, from the public API point of view, which ones involve IO/Network work that must be done in the background thread?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jobs and Scheduling | Apache Flink
Jobs and Scheduling # This document briefly describes how Flink schedules jobs and how it represents and tracks job status on the JobManager....
Read more >
Java: Build your own JobManager – GhostProgrammer
Manage Jobs that need to run as soon as possible. Schedule Jobs to run at a later time. Manage services that should be...
Read more >
Job manager in Android - Stack Overflow
I need this hypothetical JobManager to receive jobs and sort them by ID. If a job with id = 1 is already running,...
Read more >
Performing Recurrent Tasks - Hangfire Documentation
The benefits here are that you never get more than once instance of the job queued up and it doesn't matter how long...
Read more >
Schedule tasks with WorkManager Part of Android Jetpack.
Long Running: Tasks which might run for longer, potentially longer than 10 minutes. Deferrable: Scheduled tasks that start at a later time and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found