Android/Delphi Firemonkey apps crashing at startup due to a problem in FMXEditText.java or in Android itself

705 Views Asked by At

We are seeing an issue with an android firemonkey delphi app written with Delphi 10.4 and approved for sale in the Google Play store that only fails on some devices, and not on the devices that the development team has access to, with a java.util.ConcurrentMOdificationException raised at startup. In logcat on an affected device we see:

2022-06-03 12:02:23.919 17757-17757/com.ourcompany.ourapp E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.ourcompany.ourapp, PID: 17757
    java.util.ConcurrentModificationException
        at java.util.ArrayList$Itr.next(ArrayList.java:860)
        at com.embarcadero.firemonkey.text.FMXEditText$ChangeWatcher.onTextChanged(FMXEditText.java:369)
        at android.widget.TextView.sendOnTextChanged(TextView.java:11785)
        at android.widget.TextView.handleTextChanged(TextView.java:11907)
        at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:15253)
        at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:1277)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:586)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:517)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:38)
        at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:867)
        at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:199)
        at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:177)
        at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:345)
        at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:93)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:8653)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
2022-06-03 12:02:24.016 17757-17757/com.idealss.OneMobilePOS I/Process: Sending signal. PID: 17757 SIG: 9
  1. There is none of our own company application code involved.

  2. Only android.* java code and com.embarcadero.firemonkey.* java code are involved.

  3. It happens at startup before our form create or form show are called.

It appears probable that it is a bug in firemonkey, or a problem in the firemonkey java classes that has to be fixed by Embarcadero but we have no idea how to prove that or report such a problem, and are hoping someone has an idea on what could cause this or what can be done about it.

We suspect that only certain android versions and certain android devices have this problem. The app is not yet portable to delphi 11, but if I can isolate the issue further, I thought this question could serve as a useful launching off point for others encountering this strange exception at startup in firemonkey apps. If I can prove, or anyone else can prove that this does not happen in Delphi 11, then the answer to this question would be "don't use delphi 10.4 anymore on modern android". If it still happens in Delphi 11, I will update the question, but that will take time, and time to propagate out into the wild and see if this weird glitch goes away. I am hoping someone has seen this and knows what this is and can guide me in the direction of the solution.

0

There are 0 best solutions below