Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26841] Android: Reading TextField "backgroundDisabledColor" will crash if background/border color is assigned

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2019-05-09T09:09:09.000+0000
Affected Version/sRelease 7.5.0
Fix Version/sRelease 8.1.0
ComponentsAndroid
Labelsandroid, background, engSchedule, view
ReporterRakhi Mitro
AssigneeYordan Banev
Created2019-02-21T09:11:28.000+0000
Updated2019-05-09T09:09:09.000+0000

Description

Using Android SDK 7.5.0, text field touch start event is failing with below error.
[WARN] :   Settings: mValues not put! needsGenerationTracker: true currentGeneration: -1 name: enable_navbar value: null
[ERROR] :  TiExceptionHandler: (main) [39572,39572] ti:/titanium.js:207
[ERROR] :  TiExceptionHandler: 			serialized[k] = this[k];
[ERROR] :  TiExceptionHandler:                        ^
[ERROR] :  TiExceptionHandler: Error: android.graphics.drawable.PaintDrawable cannot be cast to android.graphics.drawable.StateListDrawable
[ERROR] :  TiExceptionHandler:     at TextField.value (ti:/titanium.js:207:24)
[ERROR] :  TiExceptionHandler:     at JSON.stringify (<anonymous>)
[ERROR] :  TiExceptionHandler:     at TextField.<anonymous> (/app.js:23:20)
[ERROR] :  TiExceptionHandler:     at TextField.value (ti:/events.js:49:21)
[ERROR] :  TiExceptionHandler:     at TextField.value (ti:/events.js:101:19)
[ERROR] :  TiExceptionHandler:
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.proxy.TiViewProxy.getBackgroundDisabledColor(TiViewProxy.java:1190)
[ERROR] :  TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
[ERROR] :  TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:63)
[ERROR] :  TiExceptionHandler:     org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:971)
[ERROR] :  TiExceptionHandler:     org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1196)
[ERROR] :  TiExceptionHandler:     org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:401)
[ERROR] :  TiExceptionHandler:     ti.modules.titanium.ui.TextFieldProxy.handleMessage(TextFieldProxy.java:157)
[ERROR] :  TiExceptionHandler:     android.os.Handler.dispatchMessage(Handler.java:104)
[ERROR] :  TiExceptionHandler:     android.os.Looper.loop(Looper.java:166)
[ERROR] :  TiExceptionHandler:     android.app.ActivityThread.main(ActivityThread.java:7425)
[INFO] :   zygote64: Do partial code cache collection, code=30KB, data=30KB
*Test steps:* 1. Create a new project 2. Paste the sample test code and run on android device 3. After running, start touching on the text field and got the error. *Test code:*
var win = Ti.UI.createWindow({ 
backgroundColor : 'gray' 
}); 


var view = Ti.UI.createView({ 
height : Ti.UI.SIZE, 
borderColor : "red", 
width : Ti.UI.FILL, 
layout : "vertical" 
}); 


var TF = Ti.UI.createTextField({ 
height : 40, 
width : Ti.UI.FILL, 
backgroundColor : "#FAFAFA", 
borderColor : "black", 
top : 20 
}); 
TF.addEventListener("touchstart", function(e) { 
	
Ti.API.debug(JSON.stringify(e)); 
}); 
win.add(TF); 

win.add(view); 
win.open();
*Test Environment:*
Appcelerator Command-Line Interface, version 7.0.9
Operating System
  Name                        = Mac OS X
  Version                     = 10.13.6
  Architecture                = 64bit
  # CPUs                      = 4
  Memory                      = 8589934592
Node.js
  Node.js Version             = 8.9.1
  npm Version                 = 5.5.1
Titanium CLI
  CLI Version                 = 5.1.1
Titanium SDK
  SDK Version                 = 7.5.0.GA
  SDK Path                    = /Users/sharifabudarda/Library/Application Support/Titanium/mobilesdk/osx/7.5.0.GA
  Target Platform             = android
Device:Huawei Y9 2018

Comments

  1. Joshua Quick 2019-02-22

    I've confirmed that this is a regression introduced in 7.5.0. But it's not a bug with the TextField's "touchstart" event. This crash will only happen when reading the TextField's newly added "backgroundDisabledColor" property after setting its "backgroundColor" and a border property such as "borderColor" or "borderWidth". The "backgroundDisabledColor" property is being read by the attached code's "JSON.stringify(e)" since the passed in event references the {{TextField} that was touched. You can work-around this issue by setting the "backgroundDisabledColor" property to a value. For example:
       var TF = Ti.UI.createTextField({
       	height : 40,
       	width : Ti.UI.FILL,
       	backgroundColor : "#FAFAFA",
       	backgroundDisabledColor : "gray",   // <- Add this.
       	borderColor : "black",
       	top : 20,
       });
       
    Alternatively, you can work-around this by removing the JSON.stringify() of the TextField.
  2. Joshua Quick 2019-02-22

    The below code is a simpler test case. It will crash on app startup as of 7.5.0 unless you uncomment then "backgroundDisabledColor" line.
       var window = Ti.UI.createWindow();
       var textField = Ti.UI.createTextField({
       	width: "80%",
       	color: "white",
       	backgroundColor: "black",
       	borderColor: "white",
       //	backgroundDisabledColor: "gray",
       });
       window.add(textField);
       window.open();
       Ti.API.info("### backgroundDisabledColor: " + textField.backgroundDisabledColor);
       Ti.API.info("### JSON.stringify(textField): " + JSON.stringify(textField));
       
  3. Rakhi Mitro 2019-02-24

    [~jquick], Thanks for your explanation. The customer is informed about this. Will be back here after getting any feedback from them.
  4. Joshua Quick 2019-03-02

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/10744
  5. Gary Mathews 2019-04-30

    master: https://github.com/appcelerator/titanium_mobile/pull/10393
  6. Keerthi Mahalingam 2019-05-02

    FR passed. NO crashing . https://github.com/appcelerator/titanium_mobile/pull/10393 PR merged.
  7. Keerthi Mahalingam 2019-05-08

    Verified the Fix on sdk 8.1.0.v20190508095544. Works as expected.
       Operating System
         Name                        = Mac OS X
         Version                     = 10.13.6
         Architecture                = 64bit
       Node.js
         Node.js Version             = 8.9.1
         npm Version                 = 5.5.1
       Titanium CLI
         CLI Version                 = 5.1.1
       Titanium SDK
         SDK Version                 = 8.1.0.v20190508095544
       Device =samsung s5 android 6
       Emulator =pixel 3xl android 9
       

JSON Source