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

Orbot 17: startup on boot crash #812

Closed
syphyr opened this issue Feb 13, 2023 · 10 comments
Closed

Orbot 17: startup on boot crash #812

syphyr opened this issue Feb 13, 2023 · 10 comments
Assignees
Labels

Comments

@syphyr
Copy link
Contributor

syphyr commented Feb 13, 2023

When "Start Orbot on Boot" is enabled on 17.0.0-ALPHA-4-tor.0.4.7.10, a fatal exception occurs when Orbot attempts to automatically start on boot. Manually starting Orbot after the system boots works fine.

02-13 09:31:31.175  1422  1422 E AndroidRuntime: FATAL EXCEPTION: main
02-13 09:31:31.175  1422  1422 E AndroidRuntime: Process: org.torproject.android, PID: 1422
02-13 09:31:31.175  1422  1422 E AndroidRuntime: java.lang.RuntimeException: Unable to create application org.torproject.android.OrbotApp: java.lang.IllegalStateException: WorkManager is not initialized properly.  The most likely cause is that you disabled WorkManagerInitializer in your manifest but forgot to call WorkManager#initialize in your Application#onCreate or a ContentProvider.
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5451)
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	at android.app.ActivityThread.-wrap2(ActivityThread.java)
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1564)
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:102)
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:154)
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6186)
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
02-13 09:31:31.175  1422  1422 E AndroidRuntime: Caused by: java.lang.IllegalStateException: WorkManager is not initialized properly.  The most likely cause is that you disabled WorkManagerInitializer in your manifest but forgot to call WorkManager#initialize in your Application#onCreate or a ContentProvider.
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	at androidx.work.WorkManager.getInstance(WorkManager.java:165)
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	at org.torproject.android.service.util.Prefs.initWeeklyWorker(Prefs.java:64)
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	at org.torproject.android.OrbotApp.onCreate(OrbotApp.java:29)
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1025)
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5448)
02-13 09:31:31.175  1422  1422 E AndroidRuntime: 	... 8 more
@syphyr
Copy link
Contributor Author

syphyr commented Feb 16, 2023

When looking at the official doc for WorkManager here: https://developer.android.com/guide/background/persistent/configuration/custom-configuration#custom-config

This seems to be the problem:

Note: If you call the deprecated no-parameter WorkManager.getInstance() method before WorkManager has been initialized, the method throws an exception. You should always use the WorkManager.getInstance(Context) method, even if you're not customizing WorkManager.

@syphyr
Copy link
Contributor Author

syphyr commented Feb 16, 2023

I am trying to add WorkManager.initialize(Context, new Configuration.Builder().build()); before WorkManager.getInstance() but I cant figure out how to get the right Context

https://github.com/guardianproject/orbot/blob/83f245c77b417066bc7ca40f910bed29bce5851e/orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java#L64

@syphyr
Copy link
Contributor Author

syphyr commented Mar 11, 2023

@n8fr8 this crash on startup started to occur with 1fcceeb. Do you have any suggestions on how to initialize the correct "Context" with WorkManager? I am having some problems trying to figure out the correct way of initializing WorkManager before calling it.

@n8fr8
Copy link
Member

n8fr8 commented Mar 13, 2023

I'm back in the code and will see where I can get. This sounds like a familiar issue I've solved somewhere else...

@bitmold bitmold self-assigned this Mar 30, 2023
n8fr8 added a commit that referenced this issue Apr 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
and hopefully fix onboot
@n8fr8 n8fr8 added the bug label Apr 7, 2023
@n8fr8 n8fr8 self-assigned this Apr 7, 2023
@xyz-nobody
Copy link

xyz-nobody commented Apr 10, 2023

Same with version 17.0.0 BETA 5, Orbot does not start by default at boot.
but I don't see anything in the logs :(

@n8fr8
Copy link
Member

n8fr8 commented Apr 10, 2023

I've made the fix last week, but haven't put a release out.

@xyz-nobody
Copy link

In any case thank you for this great work.
Orbot is really great.

Do you know when you will push a next beta or rc?

@n8fr8
Copy link
Member

n8fr8 commented Apr 11, 2023

today!

@syphyr
Copy link
Contributor Author

syphyr commented Apr 11, 2023

I've made the fix last week, but haven't put a release out.

I can confirm that 3dd0fdb fixes the startup crash. Thank you!

@syphyr
Copy link
Contributor Author

syphyr commented Jan 22, 2024

Fixed

@syphyr syphyr closed this as completed Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants