The problem
While working on an Alloy project that used
autoStyle
on some views, I sow these 4 lines scrolling by all the time:
[WARN] could not find image: <null>
[WARN] could not find image: <null>
[WARN] could not find image: <null>
[WARN] could not find image: <null>
The source
I tracked it down to a call to
$.removeClass($.proxy, \['class'\])
.
When Alloy removes a class it will use a [RESET object](
https://github.com/appcelerator/alloy/blob/master/Alloy/lib/alloy.js#L38) as defaults for the remaining styles.
I then made a test case that reproduces:
var w = Ti.UI.createWindow({
backgroundColor: 'green'
});
var v = Ti.UI.createButton({ // replacing with Ti.UI.View reduces from 4 to 0 warning (!)
width: 100,
height: 100,
backgroundColor: 'red'
});
w.add(v);
w.open();
v.applyProperties({
"backgroundColor": 'red', // removing reduces from 4 to 2 warnings
"shadowColor": null, // removing reduces from 4 to 2 warnings
"shadowOffset": null, // removing reduces from 4 to 2 warnings
"backgroundImage": null, // removing reduces from 4 to 1 warning (!)
"backgroundRepeat": null, // removing reduces from 4 to 2 warnings
"backgroundSelectedColor": null, // removing reduces from 4 to 2 warnings
"backgroundSelectedImage": null, // removing reduces from 4 to 1 warning (!)
"visible": true, // removing reduces from 4 to 2 warnings
"backgroundGradient": {}, // removing reduces from 4 to 2 warnings
"borderRadius": 0, // removing reduces from 4 to 2 warnings
"backgroundLeftCap": 0, // removing reduces from 4 to 2 warnings
"backgroundTopCap": 0 // removing reduces from 4 to 2 warnings
});
The actually error must originate from:
https://github.com/appcelerator/titanium_mobile/blob/58198c641d77e17d156431666e80bae732b5c130/iphone/Classes/TiUIView.m#L315
But what is weird is that on line 311 of the above source, it checks for the image to be
nil
which I assume the
null
values of the above test case should have been converted to.
It's also striking that these warnings don't show for a
View
, but only for a
Button
. So the issue must be somewhere between lines 233 and 255 of [TiUIButton.m](
https://github.com/appcelerator/titanium_mobile/blob/58198c641d77e17d156431666e80bae732b5c130/iphone/Classes/TiUIButton.m#L233-L255)
Having the same issue using $.resetClass(view, 'class1 class2');
Still having this issue on 7.5.1GA when using $.resetClass(view, 'class1 class2');