[TIMOB-16911] Android: Setting touchEnabled on labels (TextView) crashes intermittently on Axiom device
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-05-29T02:18:06.000+0000 |
Affected Version/s | Release 3.2.2 |
Fix Version/s | Release 4.1.0 |
Components | Android |
Labels | n/a |
Reporter | Andrew Greenstreet |
Assignee | Hieu Pham |
Created | 2014-04-25T18:36:52.000+0000 |
Updated | 2017-03-22T22:48:30.000+0000 |
Description
I'm getting this crash report on Google Play for a Galaxy Axiom
java.lang.ClassCastException: java.lang.String cannot be cast to android.text.Spannable
at android.widget.TextView.setEnabled(TextView.java:1432)
at org.appcelerator.titanium.view.TiUIView.registerForTouch(TiUIView.java:1457)
at org.appcelerator.titanium.view.TiUIView.registerForTouch(TiUIView.java:1271)
at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:472)
at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449)
at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:487)
at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:471)
at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449)
at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:487)
at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:471)
at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449)
at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:487)
at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:471)
at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449)
at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:566)
at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:218)
at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:100)
at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:443)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4962)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
at dalvik.system.NativeStart.main(Native Method)
My preliminary research indicates this can happen when calling "setEnabled" on a TextView that doesn't yet have a value.
You can find our app @
https://play.google.com/store/apps/details?id=com.findingrover.findingrover
If you happen to have a Samsung Axiom laying around running Android 4.1
We cannot diagnose such issues at the app level. Please provide a simple runnable test case to reproduce this error.
I'm not quite sure how. We tested this app on 20+ android devices and it only fails in the line mentioned above on one device. I'm really just alerting you to the fact that in TiUIView.java @ line 1457 the code:
Can cause a crash when set on a TextView (TiUILabel) that doesn't have a value. This was a change made to TiUIView.java sometime between 3.1.3 and 3.2.3. The only fix i could come up with is
Moving this ticket to engineering to evaluate the call stack and proposed fix. I was not able to reproduce this issue as I don't have this specific device.
I just started seeing this on SDK 3.2.4.v20140519174127. These are the devices I see affected in Crittercism: Samsung Stratosphere, android 4.1.2 SGH-I547C, android 4.1.2 I can provide the stack traces or other details, if desired. I know at least one of the crashes is happening without the "setEnabled" cause because the user can't login and there are no "setEnabled" calls on public screens. I have yet to narrow down where they're getting the crash, but if I do I'll add more detail here.
@Alejandro, I'm curious if you're using touchEnabled at all (not necessarily 'setEnabled') on the pages you're seeing crashes on? I'm seeing this issue *a lot* on multiple devices, all running *Android 4.1.2* and am trying to create a sample app that breaks so that we can get it fixued up but cannot seem to recreate it... very frustrating. Just trying to see if I can get any more hints that might help me figure out how to break it :)
Hey @mfogg, are you asking if I have touchEnabled set on any of the object I'm using at creation time, or if I modify the touchEnabled property on any objects after creation? Let me know and I'll look. I was thinking of changing all setEnabled calls to touchEnabled because setEnabled is deprecated in SDK 3.3 I believe. I don't know if that will have any affect on this, FYI. Do you?
This crash is happening when setting touchEnabled. If you look at the underlying Java code in TiUIView.java, you can see that the view (e.g. Android TextView) is set to enabled or not, only when this property is present:
Right now, the only solution is to use 3.2.2 or a custom build of 3.3.0 with this fixed (which is what we're opting for).
I'm me-tooing this just to let you know it's not an isolated incident. The same crash and stack trace, and only (so far) on Samsung Galaxy Stratosphere 2 (which someone mentioned previously for this bug) running 4.1.
This issue is becoming urgent as more Android devices are having the same issue. Users with other Samsung devices like the Galaxy Rugby are having this issue. This specific device is running Android 4.1.2
[~rtlechuga] Do you have a device that reproduces this issue?
[~ingo] not sure, let me check and I'll update the ticket
This is a complete show-stopper for us. If we add a label to a TableViewRow, and we don't set the label's touchEnabled property to false, then tapping the label will have no visual effect -- the backgroundSelectedColor will not be activated. If we *do* set touchEnabled to false, the app works, but it will crash on many devices: - Galaxy Axiom (infiniteusc) - Samsung Galaxy Stratosphere2 (aegis2vzw) - Galaxy Victory (goghvmu) - Galaxy Victory (goghspr) Please give this priority! And you probably should start by fixing the issue where touch events that bubble to the TableViewRow through its children still activate the backgroundSelectedColor. Then I would have never set touchEnabled to false in the first place!
If anyone wants a patched version that fixes this, send me an email andrew@gstreetmedia.com
[~jpriebe] you mind sharing your test case with us? We can not replicate this issue, that's why it has no traction. Thanks
I don't have one of the devices to test with, so I haven't been able to build a test case. I'm just working off our APM reports. I may purchase one of these terrible phones just so I can do some more testing. But my second point is that the backgroundSelectedColor should get activated on a TableViewRow whether the user is tapping empty space in the row or tapping a label in the row. That is highly repeatable; I think you could probably even find an example in the KitchenSink. I realize that is a separate bug, but if it were fixed, there would almost never be a need to set touchEnabled=false on a label. For the life of me, I cannot think of another way around the backgroundSelectedColor problem. I tried putting an invisible overlay on top of the TableViewRow (over top of all its children), and setting toucheEnabled=false on that view. But the touch events bubbled through in exactly the same way as without the overlay, and the backgroundSelectedColor did not activate. If you have any ideas on that, I would be very interested in hearing them.
CR, Functionally tested. PR approved. https://github.com/appcelerator/titanium_mobile/pull/6872
Closing ticket as fixed.