getodk / collect

ODK Collect is an Android app for filling out forms. It's been used to collect billions of data points in challenging environments around the world. Contribute and make the world a better place! ✨📋✨
https://docs.getodk.org/collect-intro
Other
718 stars 1.38k forks source link

Only the ref of the first odk:recordaudio action to fire is populated with a background audio filename #4387

Open lognaturel opened 3 years ago

lognaturel commented 3 years ago

Launch a form with multiple odk:recordaudio actions such as one-question-background-audio-multiple.xml.zip. For that form, both recording1 and recording2 should be populated with the same audio filename. However, only recording1 is populated.

I believe the issue is a race condition. I think the first call on startBackgroundRecording has not yet completed when the second one is fired and so the second check on isBackgroundRecording is false.

I don't think this is a big deal. It's good that we have a strategy for supporting the multiple actions but not critical that it be supported immediately. We can document that if there's more than one action, all but the first will be ignored. This is especially the case since it looks like Central does not support receiving the multiple files: https://github.com/getodk/central-backend/issues/330

seadowg commented 3 years ago

Ah the isBackgroundRecording call is probably not what we want here. We can probably fix but just doing audioRecorder.getCurrentSession().getValue().getId() instanceof Set instead.

seadowg commented 3 years ago

Oh and I think this probably doesn't fail in tests as it isn't using a service behind the scenes. It's probably easy enough to drive the fix out with a test at the BackgroundAudioViewModel level though.