onnela-lab / beiwe-android

Beiwe is a smartphone-based digital phenotyping research platform. This is the Beiwe Android app code. The Beiwe2 app is also available on the Google Play store to use with open source builds of the Beiwe backend.
https://www.beiwe.org/
BSD 3-Clause "New" or "Revised" License
26 stars 17 forks source link

Crash when tapping audio recording notification #24

Closed antong closed 6 years ago

antong commented 6 years ago

Repeating crash when touching the audio recording notification occurred about two hours after installation and initial logon. The notification did not go away, but the app crashed every time when tapping the notification. When I opened the app from the launcher, the logon screen appeared. After logon, tapping the notification worked as expected and the audio recording interface opened.

A log excerpt follows.

03-01 10:55:00.924 I/PowerStateListener( 5394): Screen turned on
03-01 10:55:00.926 I/PowerStateListener( 5394): Screen turned on
...
03-01 10:55:04.587 I/ActivityManager( 4948): Process org.beiwe.app (pid 5394) has died
03-01 10:55:04.587 D/ActivityManager( 4948): cleanUpApplicationRecord -- 5394
03-01 10:55:04.594 W/ActivityManager( 4948): Scheduling restart of crashed service org.beiwe.app/.BackgroundService in 11765274ms
...
03-01 10:55:06.144 D/StatusBar( 7438): Clicked on content of 0|org.beiwe.app|-2116657889|null|10155
03-01 10:55:06.169 W/InputMethodManagerService( 4948): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@bb1bf81
 attribute=null, token = android.os.BinderProxy@1173d21
03-01 10:55:06.217 I/ActivityManager( 4948): START u0 {act=org.beiwe.app.start_audio_survey flg=0x4000000 cmp=org.beiwe.app/.survey.AudioRecorderActivity (has extras)
} from uid 10155 on display 0
03-01 10:55:06.217 W/ActivityManager( 4948): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=org.beiwe.app.sta
rt_audio_survey flg=0x4000000 cmp=org.beiwe.app/.survey.AudioRecorderActivity (has extras) }
03-01 10:55:06.249 V/BoostFramework( 4948): BoostFramework() : mPerf = com.qualcomm.qti.Performance@af1f380
03-01 10:55:06.249 I/ActivityManager( 4948): Start proc 19318:org.beiwe.app/u0a155 for activity org.beiwe.app/.survey.AudioRecorderActivity
03-01 10:55:06.267 D/com.facebook.appevents.AppEventsLogger(11504): Got unexpected exception: java.io.WriteAbortedException: Read an exception; java.io.NotSerializableException: org.json.JSONObject
03-01 10:55:06.454 D/AndroidRuntime(19318): Shutting down VM
--------- beginning of crash
03-01 10:55:06.461 E/AndroidRuntime(19318): FATAL EXCEPTION: main
03-01 10:55:06.461 E/AndroidRuntime(19318): Process: org.beiwe.app, PID: 19318
03-01 10:55:06.461 E/AndroidRuntime(19318): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.beiwe.app/org.beiwe.app.survey.AudioRecorderActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getString(int)' on a null object reference
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.app.ActivityThread.access$900(ActivityThread.java:150)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.os.Handler.dispatchMessage(Handler.java:102)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.os.Looper.loop(Looper.java:148)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.app.ActivityThread.main(ActivityThread.java:5417)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at java.lang.reflect.Method.invoke(Native Method)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
03-01 10:55:06.461 E/AndroidRuntime(19318): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getString(int)' on a null object reference
03-01 10:55:06.461 E/AndroidRuntime(19318):     at org.beiwe.app.storage.PersistentData.getSurveySubmitSuccessToastText(PersistentData.java:283)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at org.beiwe.app.survey.AudioRecorderCommon.<init>(AudioRecorderCommon.java:47)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at org.beiwe.app.survey.AudioRecorderActivity.<init>(AudioRecorderActivity.java:14)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at java.lang.Class.newInstance(Native Method)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
03-01 10:55:06.461 E/AndroidRuntime(19318):     ... 9 more
03-01 10:55:06.505 W/ActivityManager( 4948):   Force finishing activity org.beiwe.app/.survey.AudioRecorderActivity

...

03-01 10:55:06.144 D/StatusBar( 7438): Clicked on content of 0|org.beiwe.app|-2116657889|null|10155
03-01 10:55:06.169 W/InputMethodManagerService( 4948): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@bb1bf81
 attribute=null, token = android.os.BinderProxy@1173d21
03-01 10:55:06.217 I/ActivityManager( 4948): START u0 {act=org.beiwe.app.start_audio_survey flg=0x4000000 cmp=org.beiwe.app/.survey.AudioRecorderActivity (has extras)
} from uid 10155 on display 0
03-01 10:55:06.217 W/ActivityManager( 4948): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=org.beiwe.app.sta
rt_audio_survey flg=0x4000000 cmp=org.beiwe.app/.survey.AudioRecorderActivity (has extras) }
03-01 10:55:06.249 V/BoostFramework( 4948): BoostFramework() : mPerf = com.qualcomm.qti.Performance@af1f380
03-01 10:55:06.249 I/ActivityManager( 4948): Start proc 19318:org.beiwe.app/u0a155 for activity org.beiwe.app/.survey.AudioRecorderActivity
03-01 10:55:06.267 D/com.facebook.appevents.AppEventsLogger(11504): Got unexpected exception: java.io.WriteAbortedException: Read an exception; java.io.NotSerializableException: org.json.JSONObject
03-01 10:55:06.454 D/AndroidRuntime(19318): Shutting down VM
--------- beginning of crash
03-01 10:55:06.461 E/AndroidRuntime(19318): FATAL EXCEPTION: main
03-01 10:55:06.461 E/AndroidRuntime(19318): Process: org.beiwe.app, PID: 19318
03-01 10:55:06.461 E/AndroidRuntime(19318): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.beiwe.app/org.beiwe.app.survey.AudioRecorderActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getString(int)' on a null object reference
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.app.ActivityThread.access$900(ActivityThread.java:150)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.os.Handler.dispatchMessage(Handler.java:102)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.os.Looper.loop(Looper.java:148)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.app.ActivityThread.main(ActivityThread.java:5417)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at java.lang.reflect.Method.invoke(Native Method)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
03-01 10:55:06.461 E/AndroidRuntime(19318): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getString(int)' on a null object reference
03-01 10:55:06.461 E/AndroidRuntime(19318):     at org.beiwe.app.storage.PersistentData.getSurveySubmitSuccessToastText(PersistentData.java:283)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at org.beiwe.app.survey.AudioRecorderCommon.<init>(AudioRecorderCommon.java:47)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at org.beiwe.app.survey.AudioRecorderActivity.<init>(AudioRecorderActivity.java:14)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at java.lang.Class.newInstance(Native Method)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
03-01 10:55:06.461 E/AndroidRuntime(19318):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
03-01 10:55:06.461 E/AndroidRuntime(19318):     ... 9 more
03-01 10:55:06.505 W/ActivityManager( 4948):   Force finishing activity org.beiwe.app/.survey.AudioRecorderActivity

Android version 6.0.1

biblicabeebli commented 6 years ago

Awesome, thanks for sending this. Can't promise a timeline immediately, but this will be helpful!

zagorsky commented 6 years ago

@antong we'll try to fix this soon. For our own notes:

I've seen two ways to trigger this crash:

  1. (Reliably) Open the audio recording screen, start an audio recording, and kill the app from the task switcher (without stopping the recording first). Then tap the notification again.

  2. (Occasionally) Don't open the app for a few hours, and then tap the audio recording notification.

Here's the most relevant part of the stack trace:

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getString(int)' on a null object reference
at org.beiwe.app.storage.PersistentData.getSurveySubmitSuccessToastText(PersistentData.java:283)
at org.beiwe.app.survey.AudioRecorderCommon.<init>(AudioRecorderCommon.java:47)
at org.beiwe.app.survey.AudioRecorderActivity.<init>(AudioRecorderActivity.java:14)
antong commented 6 years ago

@zagorsky, yes your number 2 is what I'm experiencing regularly. With our setup, I get daily survey and audio recording requests. So, I usually get two notifications, one for the survey and one for the audio recording. When I first tap the audio recording notification I get this crash but when I tap the survey notification I get the password prompt and then get the survey. If I first do the survey, then the audio recording doesn't crash.

zagorsky commented 6 years ago

@antong, this should be fixed in commit 9278f16. I'll push a new version of the app soon so you can test it.

zagorsky commented 6 years ago

@antong, this should be fixed in Beiwe version 2.2.6 and higher. If you're compiling the app yourself, it should be fixed in commit 9278f16, which is on master. For anyone who's installing the app from Google Play, you can install Beiwe (currently 2.2.7) by opening the Google Play app on an Android phone, finding the Beiwe2 app, scrolling down to "Become a beta tester", and enrolling in the beta test.