Collect crashes when switching languages

1. What is the problem? Be very detailed.
I think I found a bug. Attached is a minimal form with two languages (English (en) and Bavarian (bar)), three fields in a group, one of them has an image label. Included is the .odkbuild save file which will work on ODK Build 0.4.0 (currently running at https://tom.build.getodk.org/).

When I change the language inside the form, Collect crashes and goes to the main menu.
When I open a new form, the default language is the first by alphabetic order - Bavarian. When I change the language to English, Collect crashes again.

2. What app or server are you using and on what device and operating system? Include version numbers.

3. What you have you tried to fix the problem?
TODO: shrink the form to MVE. My bottleneck: available time.

4. What steps can we take to reproduce the problem?
Deploy the attached XForm to Central, attach the two media images, test on Collect. Try and get the form to show English.

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.
Forms: Collect0crash.zip (1.7 KB)

Just to be really clear: you mean clicking the options (the three dots/kebab) menu and then clicking "Change Language" right?

The attached zip only includes a .odkbuild file. Could you reupload with media and ideally an XLS or XForm?

Collect crash.zip (804.5 KB)

Let me try that upload again, sorry!

I think I've narrowed it down to forms with media labels present.

Form without media label (configured via QR code, then fill blank form before the media files download):

  • Fill Blank Form > Test040
  • Form shows no media labels.
  • In the form (screen "Group 1") > kebab > Change Language (defaults to "English") > select "Bavarian" > works.
  • Changing language back to English works.

Configure form again, wait for media to download:

  • Form shows media labels.
  • Language defaults to Bavarian.
  • Kebab > change language > select English > screen goes white with black header showing "ODK Collect", then goes back to Main menu.

So repro is:

  • Publish form draft, don't attach media
  • test > can change language
  • attach media > crashes on changing language

Does that help?

Hi @Florian_May
Thanks for the form. I was able to reproduce the crash so I'm going to investigate it. Could you maybe attach xls version of your form not only xml? If you don't have it that's fine just let me know.

Thanks for chasing this up!
Test040-export (1).xlsx (11.7 KB)
Converted the form using the new ODK Build 0.4.0 \m/

How did you produce your xml form? Did you add anything manually?
I'm asking because if I take that xml form I can reproduce the crash but if I convert the xls version using https://getodk.org/xlsform/ and use then everything seems to be fine so I guess there is something spoiled in the xml form. I'm wondering if ODK Build adds something incorrect or maybe you have added something manually?

I've built the form in ODK Build, testing out the new media labels, then exported it straight to XML and XLS (using build2xlsform). Media labels come from the latest additions to Build, so maybe Build produces invalid XML?

Edit: just checked and saw that build2xlsform does not support media labels yet (will add), so the xls will not crash.

Collect crash.zip (807.2 KB)
Getting closer to an MVE.

Attached ZIP contains three form versions.
Common:

  • Two languages: English (en), Bavarian (bar)
  • The form has a text field with a label and a media label
  • Media label has different images for different languages
  • The text field has a "short" title in only one language

Difference:
The form that is broken contains an English "short" label in addition to the media label.
Test040_broken.xml (5.4 KB)

          <text id="/data/group1/text1:label">
            <value>Text 1 label</value>
            <value form="short">Text 1 short</value>
            <value form="image">jr://images/turtle.png</value>
          </text>

Deleting the "short" label makes the form work with media labels (attached as Test040_noshort_works.xml). I think this means that ODK Build 0.4.0 does not produce invalid XML for media labels then.
Test040_noshort_works.xml (5.4 KB)

          <text id="/data/group1/text1:label">
            <value>Text 1 label</value>
            <value form="image">jr://images/turtle.png</value>
          </text>

Removing the media labels and only leaving the field with a label (bar) and a label&short (en) still produces the crash.
Test040_nomedia_onlyshort.xml (5.3 KB)

# bavarian
          <text id="/data/group1/text1:label">
            <value>Da text</value>
          </text>
          <text id="/data/group1/text1:hint">
            <value>I sog da wos</value>
            <value form="guidance">Jetzad bass fei guad auf, Biascherl</value>
          </text>

# english
          <text id="/data/group1/text1:label">
            <value>Text 1 label</value>
            <value form="short">Text 1 short</value>
          </text>
          <text id="/data/group1/text1:hint">
            <value>Text 1 hint</value>
            <value form="guidance">Text 1 guidance</value>
          </text>

Adding a short label to the other language fixes the crash!
Test040_two_short.xml (5.5 KB)

          <text id="/data/group1/text1:label">
            <value>Da text</value>
            <value form="short">Kuaz</value>
            <value form="image">jr://images/flo_off.jpg</value>
          </text>

          <text id="/data/group1/text1:label">
            <value>Text 1 label</value>
            <value form="short">Text 1 short</value>
            <value form="image">jr://images/turtle.png</value>
          </text>

This gets wilder.
Since Bavarian is the first language in the XML (in which languages seem to be sorted A-Z although in Build English comes first and Bavarian was added), a form with a short for Bavarian and no short for English does not crash, but shows the Bavarian short title in place of the English one.
Test040_bar_short.xml (5.4 KB)

TLDR:
The above tells me that the crash is caused by the presence of a short label in a field the second language for which the first language has no short label.
Forms with consistent use of short labels seem not to crash.

Sorry for the late response but I was on a sick leave.
Thanks for all those details!

I've investigated your form and I agree that the crash is caused because one of your languages has translation for short label and the second one doesn't and the problem here is that it completly lacks that element in xml form but it should exists, just holds an empty value.

If you support multiple languages the first one (in xml form) is treated as the default one (Bavarian in your case) and when you open that form for the first time it is used.
If other translations (English in your case) have translations for elements that the first language lacks (no matter if those are translations for label or short label) you will end up with that crash (NoLocalizedTextException in javarosa).

So to solve your problem please add all that translations in the same way or remove those that exist only in some languages (non default)

I don't think it's something we should handle in Collect or Javarosa it's nothing new.
I think it's a bug in ODK build, why? Because if you don't have translations for some elements those elements should still be present in xml form but with empty values. ODK Build handles that case correctly if you for example do the same for normal labels but somehow for short labels it ignores that element in xml form at all.
If you build a form using xls you are also protected because missing translations will be represented as -

So to sum up the issue might take place only if you build a form using ODK Build (or manually edit your xml file) and only if you use that short label.

BTW what's that short label for? Is there any pleace in ODK Collect where it is used?

1 Like

Thanks for the detailed analysis! Hope you're feeling better now.

That analysis sounds sensible, thanks.

The short label is shown in the hierarchy view and a recent addition of mine to Build.

I will investigate and add a fix to Build.

1 Like