Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16911] Android: Setting touchEnabled on labels (TextView) crashes intermittently on Axiom device

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-05-29T02:18:06.000+0000
Affected Version/sRelease 3.2.2
Fix Version/sRelease 4.1.0
ComponentsAndroid
Labelsn/a
ReporterAndrew Greenstreet
AssigneeHieu Pham
Created2014-04-25T18:36:52.000+0000
Updated2017-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

Comments

  1. Ritu Agrawal 2014-04-28

    We cannot diagnose such issues at the app level. Please provide a simple runnable test case to reproduce this error.
  2. Andrew Greenstreet 2014-04-30

    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:
       touchable.setEnabled(false);
       
    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
       try {
       touchable.setEnabled(false); 
       } catch (Exception e) {
       Log.d(TAG, "Could not set enabled on touchable");
       }
       
  3. Ritu Agrawal 2014-05-04

    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.
  4. Alex Bernier 2014-06-25

    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.
  5. Mike Fogg 2014-07-21

    @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 :)
  6. Alex Bernier 2014-07-22

    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?
  7. Andrew Greenstreet 2014-07-22

    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:
       protected void registerForTouch(final View touchable)
       {
       if (touchable == null) {
       return;
       }
       
       if (proxy.hasProperty(TiC.PROPERTY_TOUCH_ENABLED)) {
       boolean enabled = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_TOUCH_ENABLED), true);
       if (!enabled) {
       touchable.setEnabled(false); //This is where is fails
       }
       }
       registerTouchEvents(touchable);
       doSetClickable(touchable);
       
       }
       
    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).
  8. KT 2014-08-01

    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.
  9. SHOCKOE TEAM 2015-02-17

    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
  10. Ingo Muschenetz 2015-02-27

    [~rtlechuga] Do you have a device that reproduces this issue?
  11. Radamantis Torres-Lechuga 2015-02-27

    [~ingo] not sure, let me check and I'll update the ticket
  12. Jason Priebe 2015-04-09

    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!
  13. Andrew Greenstreet 2015-04-09

    If anyone wants a patched version that fixes this, send me an email andrew@gstreetmedia.com
  14. Radamantis Torres-Lechuga 2015-04-09

    [~jpriebe] you mind sharing your test case with us? We can not replicate this issue, that's why it has no traction. Thanks
  15. Jason Priebe 2015-04-09

    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.
  16. Ashraf Abu 2015-05-27

    CR, Functionally tested. PR approved. https://github.com/appcelerator/titanium_mobile/pull/6872
  17. Lee Morris 2017-03-22

    Closing ticket as fixed.

JSON Source