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 editable field with calculate is used in relevance expression #4170

Closed
grzesiek2010 opened this issue Oct 15, 2020 · 2 comments
Closed
Labels

Comments

@grzesiek2010
Copy link
Member

Problem description

https://console.firebase.google.com/u/0/project/api-project-322300403941/crashlytics/app/android:org.odk.collect.android/issues/85177cf7b388af8b6ec086cd77c7cc05?time=last-seven-days&versions=v1.28.2%20(3943)&sessionEventKey=5F88045E02020001727F5A1D764EC4D0_1462203208677627982

Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
       at org.odk.collect.android.activities.FormEntryActivity.saveAnswersForCurrentScreen(FormEntryActivity.java:1129)
       at org.odk.collect.android.activities.FormEntryActivity.updateFieldListQuestions(FormEntryActivity.java:2714)
       at org.odk.collect.android.activities.FormEntryActivity.access$1900(FormEntryActivity.java:200)
       at org.odk.collect.android.activities.FormEntryActivity$10.run(FormEntryActivity.java:2681)
       at android.app.Activity.runOnUiThread(Activity.java:6972)
       at org.odk.collect.android.activities.FormEntryActivity.widgetValueChanged(FormEntryActivity.java:2678)
       at org.odk.collect.android.formentry.ODKView.widgetValueChanged(ODKView.java:621)
       at org.odk.collect.android.widgets.QuestionWidget.widgetValueChanged(QuestionWidget.java:499)
       at org.odk.collect.android.widgets.items.SelectOneWidget.onItemClicked(SelectOneWidget.java:103)
       at org.odk.collect.android.formentry.questions.AudioVideoImageTextLabel.lambda$setTextView$0(AudioVideoImageTextLabel.java:118)
       at org.odk.collect.android.formentry.questions.-$$Lambda$AudioVideoImageTextLabel$MqCYJ2yJoQ6DnhH04sxqp-kc3wc.onClick(-.java:2)

Steps to reproduce the problem

crashOnFieldList.xlsx
ezgif com-video-to-gif (7)

@lognaturel
Copy link
Member

lognaturel commented Oct 26, 2020

In this case, the value of ${name} used to compute relevance is briefly the user-provided value but as soon as there's a recalculation round, it goes back to the computed value. But recalculation gets triggered by the user typing into middleName which by that point is no longer relevant.

This is really a form design issue -- calculate should not be used on an editable field. https://xlsform.org/en/#trigger would be the right thing to use in this case to set the value of fullName only when name is edited. We should make sure that works.

Good find, @grzesiek2010. I'm not yet sure what the action to take is. We should make it clearer in the docs that calculate is not appropriate on an editable field. Ideally, this wouldn't crash, but I'm not sure what it should do. Probably throw an error dialog that says it's a form design issue?

The problem occurs on v1.27.3 as well but we don't see it in crash logs. Presumably someone published a faulty form definition recently and that's why we see so many of these crashes on v1.28.x.

@lognaturel lognaturel changed the title java.lang.ArrayIndexOutOfBoundsException in FormEntryActivity.java line 1129 Crash when editable field with calculate is used in relevance expression Oct 26, 2020
@lognaturel
Copy link
Member

Addressed by #4750.

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

2 participants