covidsafe / App-Android

Doctors and researchers at the University of Washington with Microsoft volunteers have built a tool to alert you about highly relevant public health announcements, potential exposure to COVID-19, and to assist public health officials and contact tracing teams without compromising your personal privacy.
http://covidsafe.cs.washington.edu/
MIT License
65 stars 20 forks source link

App Crash on LoggingService class while initiating the Service (Exception trace attached) #20

Closed aakash1313 closed 4 years ago

aakash1313 commented 4 years ago

--------- beginning of crash 2020-04-18 01:22:08.927 12195-12195/edu.uw.covidsafe E/AndroidRuntime: FATAL EXCEPTION: main Process: edu.uw.covidsafe, PID: 12195 android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{17f93e5 u0 edu.uw.covidsafe/.LoggingService} at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1918) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:216) at android.app.ActivityThread.main(ActivityThread.java:7263) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

justinklchan commented 4 years ago

https://stackoverflow.com/questions/44425584/context-startforegroundservice-did-not-then-call-service-startforeground

Please log and see time diff between the two method calls to see if that's an issue.

justinklchan commented 4 years ago

On my own device I can get this exception if I try to use startForegroundService with the PullService. I don't get this with the LoggingService. But with the PullService I notice that the time between startForegroundService() and startForeground() is less than 5 seconds. And still this exception occurs. So requires more investigation...

aakash1313 commented 4 years ago

@justinklchan , i tried this but didn't work . investigating it further

aakash1313 commented 4 years ago

@justinklchan : By mistake it got closed , opening it again

aakash1313 commented 4 years ago

@justinklchan : found the root cause for the issues. It seems we were logging the state of service incorrectly. Linked PR will resolve the issue completely. That part can be cleaned and refactored a bit. But that PR will resolve the issue for now