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

Crash when accessing jump menu #998

Closed
lognaturel opened this issue May 2, 2017 · 2 comments · Fixed by #1015 or #2347
Closed

Crash when accessing jump menu #998

lognaturel opened this issue May 2, 2017 · 2 comments · Fixed by #1015 or #2347

Comments

@lognaturel
Copy link
Member

lognaturel commented May 2, 2017

Stack trace from Firebase Crash. Happens across API levels.

Exception java.lang.RuntimeException: Unable to start activity ComponentInfo{org.odk.collect.android/org.odk.collect.android.activities.FormHierarchyActivity}: java.lang.NullPointerException
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2436)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2498)
android.app.ActivityThread.access$900 (ActivityThread.java:179)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1324)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:146)
android.app.ActivityThread.main (ActivityThread.java:5641)
java.lang.reflect.Method.invokeNative (Method.java)
java.lang.reflect.Method.invoke (Method.java:515)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1288)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1104)
dalvik.system.NativeStart.main (NativeStart.java)

Caused by java.lang.NullPointerException:
org.odk.collect.android.activities.FormHierarchyActivity.onCreate (FormHierarchyActivity.java:74)
android.app.Activity.performCreate (Activity.java:5484)
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1093)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2400)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2498)
android.app.ActivityThread.access$900 (ActivityThread.java:179)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1324)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:146)
android.app.ActivityThread.main (ActivityThread.java:5641)
java.lang.reflect.Method.invokeNative (Method.java)
java.lang.reflect.Method.invoke (Method.java:515)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1288)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1104)
dalvik.system.NativeStart.main (NativeStart.java)
@grzesiek2010
Copy link
Member

@lognaturel
I'm not able to reproduce the issue. Looks like Collect.getInstance().getFormController(); returns null.

Theoretically it would be possible if user clicks on "Go to prompt" icon during form loading but it's not possible as the UI is blocked during form loading.

FormController is set here so as I said above theoretically it would be possible but UI is blocked so we can't do that.

I've also tried some strange scenarios with "Don't keep activities" option without success as well.

The only one explanation is that someone is able to click on "Go to prompt" icon after dismissDialog but before https://github.com/opendatakit/collect/blob/master/collect_app/src/main/java/org/odk/collect/android/activities/FormEntryActivity.java#L2474 :)
Maybe we should dismiss that dialog at the end of the method?

Is someone fast enough? :)

Got it! It takes place when we close the app (when the FormHierarchyActivity is opened) using a physical button and leave the app for a long time (in my case it's at least 30 minutes), then if we open the app again the app crashes.

I've added a small trick to solve that.

@lognaturel lognaturel added this to the May 2017 milestone May 11, 2017
@lognaturel
Copy link
Member Author

Craaaaazy! Good find! I also thought it had to do with going to a prompt quickly and couldn't figure it out. I guess we see it happening frequently because users with less powerful phones may trigger that more quickly.

lognaturel added a commit that referenced this issue Jul 9, 2018
The changes in #998 introduced a null check to make sure the FormHierarchyActivity is closed when FormController is null.

#1038 created a subclass of FormHierarchyActivity -> ViewFormHierarchyActivity. This caused a reintroduction of the bug fixed in #998, as the subclass does not recheck for null in the onCreate() method.

When the same situation that caused crash fixed in #998 occurs in the ViewFormHierarchyActivity following steps will happen:

- ViewFormHierarchyActivity will start with calling super.onCreate()
- A null check in super.onCreate() parent class FormHierarchyActivity::onCreate will call shortcut the onCreate() method by calling return, and call finish() on activity.
- finish() will be scheduled to close the activity asynchronously after the onCreate() is finished
- super.onCreate() is done, the rest of the onCreate() method in ViewFormHierarchyActivity will be called. The shortcut only affected stopping super.onCraete(), the onCreate() is still called.
- Collect.getInstance().getFormController() will still be null. It needs to be to be shortcut again. No need to call finish() this time, as it was already called in the super.onCreate().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants