I or rather my clients are experiencing seemingly random errors when using SendToBack.
The error begins
java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.ComparableTimSort.mergeHi(ComparableTimSort.java:831)
I would like to try and implement
-Djava.util.Arrays.useLegacyMergeSort=true
to see if that fixes the issue. Can anyone help me figure out how to do this? I assume it needs reflection.
Dim sys As JavaObject
sys.InitializeStatic( "java.lang.System")
sys.RunMethod("setProperty", Array As Object("java.util.Arrays.useLegacyMergeSort", "true"))
This seems to work, at least the code runs. Since the error happens only once in a while I'm not sure this is a cure.
It happened again. Here is the log from Google Play crash report. It never happens to me. This was from a Samsung s5 with android 4.4.2. I have seen it reported on 4.3 as well. I thought uselagacymergesort woul fix it but...
java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.ComparableTimSort.mergeHi(ComparableTimSort.java:831)
at java.util.ComparableTimSort.mergeAt(ComparableTimSort.java:449)
at java.util.ComparableTimSort.mergeCollapse(ComparableTimSort.java:372)
at java.util.ComparableTimSort.sort(ComparableTimSort.java:178)
at java.util.ComparableTimSort.sort(ComparableTimSort.java:142)
at java.util.Arrays.sort(Arrays.java:1970)
at java.util.Collections.sort(Collections.java:1864)
at android.view.ViewGroup$ChildListForAccessibility.init(ViewGroup.java:6860)
at android.view.ViewGroup$ChildListForAccessibility.obtain(ViewGroup.java:6825)
at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:1761)
at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:1770)
at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:1770)
at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:1770)
at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:1770)
at android.view.ViewGroup.addChildrenForAccessibility(ViewGroup.java:1770)
at android.view.ViewGroup.onInitializeAccessibilityNodeInfoInternal(ViewGroup.java:2722)
at android.view.View.onInitializeAccessibilityNodeInfo(View.java:5404)
at android.widget.FrameLayout.onInitializeAccessibilityNodeInfo(FrameLayout.java:589)
at android.view.View.createAccessibilityNodeInfoInternal(View.java:5365)
at android.view.View.createAccessibilityNodeInfo(View.java:5352)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchPredecessorsOfRealNode(AccessibilityInteractionController.java:746)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchAccessibilityNodeInfos(AccessibilityInteractionController.java:714)
at android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread(AccessibilityInteractionController.java:147)
at android.view.AccessibilityInteractionController.access$300(AccessibilityInteractionController.java:49)
at android.view.AccessibilityInteractionController$PrivateHandler.handleMessage(AccessibilityInteractionController.java:971)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5579)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Yes, it does look the same. Unfortunately Google Play crash reports don't give us a way to contact the user. I'll try that accessibilty app, maybe I can make it crash on my own devices.
One client experiencing this reported he had LastPass installed. I asked him to uninstall it and report back. Have not heard back. I did install LastPass on my S4, but no crash...
Ok by enabling the LastPass feature which does AutoFill in apps, it crashes pretty much every time I change screens. I have emailed the devloper to as for a workaround or method of excluding our apps. So far no reply. Another App called Clean Master deletes our settings. Emails to them have gone unanswered. Apps that mess with other apps like this come perilously close to malware IMHO.
Lastpass does have a setting to exclude a particular app, and it is confirmed that excluding Touchsquid solves the crashing issue. But, in my opinion, deploying an app which crashes other apps is not a good practice, and could lead to being kicked off Google. At the least they should make it exclude all apps by default and make them enabled individually.
<EDIT>I did get a response from LastPass support. Apparently they do have an ignore list and I have asked them to add our apps to it.
Hi Erel. They have agreed to put an exception for our APKs. But turning on the built in Samsung Talkbalk feature will also cause this issue. I don't know of anybody actually using that feature, and it is not of any use in our apps which use mainly graphic icons without much text. However we are not doing anything exceptional in our app, so I think this may be a general issue with B4A or maybe just the Custom dialogs.
The crash does not throw an exception in B4A and I have not been able to pin down a single action that will make it happen every time but it always seems to be either entering or leaving a custom dialog.
You can download the free version of ZappIR from Google Play if you have a suitable Samsung or HTC device with ir blaster, and see for your self.
Dim OptionBox, EditLabel, EditButton As CustomDialog2
'add some controls to OptionsPanel
If Ini.ScreenOrientation = 1 Then
OptionBox.AddView(OptionsPanel, 800 * Common.HCF, 900 * Common.VCF)
Else
OptionBox.AddView(OptionsPanel, 800 * Common.HCF, 600 * Common.VCF)
End If
Dim Result As Int = OptionBox.Show(Common.Langs.Phrase("SelOptions"), Common.Langs.Phrase("OK"), Common.Langs.Phrase("Cancel"), "", Null)
Lastpass is not the only app that causes it. They have excluded our app now.
However ANY accessibility app including the built in TalkBalk app can cause it. I'm hoping there is something we could do in B4A that would block such apps.