-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix service manager crash #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay! I'm unsure if we should just silently ignore this, because it could mean that the audio won't play but we won't know about it. I.e. should we at least log an event?
ActivityManager activityManager = (ActivityManager) mActivity.getSystemService(Context.ACTIVITY_SERVICE); | ||
List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = activityManager.getRunningAppProcesses(); | ||
if (runningAppProcesses != null) { | ||
int importance = runningAppProcesses.get(0).importance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we find our process or are we certain it's always the first one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be the first one as that's the foreground one. I've added that in the failure callback though so we can log it, just in case there's something else amiss.
Unfortunately we don't have Datadog or Logger in AudioPlayerRecorder. I've update the callbacks so that we can log from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Let's try it out!
b984ac1
to
a717977
Compare
Potentially fixes crash: https://console.firebase.google.com/u/0/project/td-project-01/crashlytics/app/android:com.todoist/issues/5c94bfaef8b88c29631d145f?time=last-ninety-days&sessionEventKey=661EFB9F0356000131FD3657D1CE98D6_1937057838887752195
Not reproducible, but I suspect the flow is something like this:
According to this issue, the activity might not be "fully awake" so they'll be paused immediately and then resumed.
I've added logs to debug this and I can see that when you go through this flow, the service is started, paused, and started again, although in my testing the app does reach the correct foreground state (
importance = 100
) so this PR is still a guess about a fix.