Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/org/commcare/activities/FormEntryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,8 @@ protected void onDestroy() {
}
}

mFormController = null;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid clearing mFormController during configuration changes.

onDestroy() is invoked on rotations; clearing the static controller can make the next instance hit the SessionUnavailableException path (Line 242) since mFormController is used to survive config changes (see Line 733). Guard the nulling to only run when the activity is truly finishing.

💡 Suggested fix
-        mFormController = null;
+        if (!isChangingConfigurations()) {
+            mFormController = null;
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mFormController = null;
if (!isChangingConfigurations()) {
mFormController = null;
}
🤖 Prompt for AI Agents
In `@app/src/org/commcare/activities/FormEntryActivity.java` at line 1255, The
onDestroy() currently unconditionally sets mFormController = null which breaks
the config-change survival path and can trigger the SessionUnavailableException
in the subsequent instance; change the logic in FormEntryActivity.onDestroy so
that mFormController is only cleared when the Activity is actually finishing
(use isFinishing() or equivalent) and leave mFormController intact across
rotations/config changes (refer to the mFormController field and the code paths
around SessionUnavailableException and the config-change survival logic).


TextToSpeechConverter.INSTANCE.shutDown();
super.onDestroy();
}
Expand Down