Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20266] Android: ListView with attributed strings are not rendering sometimes

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2019-01-15T11:09:48.000+0000
Affected Version/sn/a
Fix Version/sRelease 8.0.0, Release 7.5.1
ComponentsAndroid
Labelsandroid
Reporter Ricardo Ramirez
AssigneeGary Mathews
Created2016-01-22T05:44:27.000+0000
Updated2019-01-16T10:34:41.000+0000

Description

Issue Description

When the user scroll very fast some attributed strings are missing (See attached screenshots), this is not happening on normal labels and if you scroll back slowly the attributed strings are showed.

Steps to Reproduce

Create a new default alloy project

replace the views/index.xml with the next code:

<Alloy>
	<Window class="container">
		<ListView id="listView">
			<Templates>
				<ItemTemplate name="simpleLabel">
					<Label bindId="label1" id="label1"/>
				</ItemTemplate>
			</Templates>
		</ListView>
	</Window>
</Alloy>

Replace the controllers/index.js code with the next code:


var listSection = Ti.UI.createListSection();
var dataItems = [];

for (var i = 0; i < 100; i++) {

	var data = {
		template: "simpleLabel",
		label1: {},
	};

	if (i % 2 === 1) {

		data.label1.attributedString = Ti.UI.createAttributedString({
			text: "Italic row row row" + i,
			attributes: [
				{
					type: Ti.UI.ATTRIBUTE_FONT,
					value: {
						fontWeight: "normal",
						fontStyle: "italic",
					},
					range: [0, 6],
				}
			]
		});

	} else {
		//data.label1.text = "Normal";
		data.label1.text="Normal" + i; 
	}

	dataItems.push(data);
};

listSection.setItems(dataItems);

$.listView.setSections([listSection]);

$.index.open();

Replace the code inside styles/index.tss with the next code:

".container": {
	backgroundColor: "#fff",
	layout: "vertical",
}

"#listView": {
	height: Ti.UI.FILL,
	width: Ti.UI.FILL,
}
"#label1": {
	font: {
		fontSize: 26,
	},
	color: "#000",
}

"Label": {
	color: "#000",
	font: {
		fontSize: 30,
	},
}

Run

Scroll fast and stop

Attachments

FileDateSize
Screenshot_2016-01-21-09-26-22.png2016-01-22T05:35:03.000+0000202632
Screenshot_2016-01-21-09-26-29.png2016-01-22T05:35:12.000+0000191159
Screenshot_2016-01-21-09-26-33.png2016-01-22T05:35:13.000+0000177482

Comments

  1. Collin Price 2016-01-25

    I have also been able to recreate this by simply changing the device orientation.
  2. Hieu Pham 2016-03-30

    master PR: https://github.com/appcelerator/titanium_mobile/pull/7895
  3. Ashraf Abu 2016-03-31

    PR reviewed and merged.
  4. Lokesh Choudhary 2016-06-23

    Verified the fix. Attributed strings don't disappear on fast scrolling & changing orientation. Closing. Environment: Appc Studio : 4.7.0.201606150733 Ti SDK : 5.4.0.v20160617074028 Ti CLI : 5.0.9 Alloy : 1.9.0 MAC El Capitan : 10.11.4 Appc NPM : 4.2.7-2 Appc CLI : 5.4.0-18 Node: 4.4.4 Nexus 6 - Android 6.0.1
  5. Srinivasan Pulipakkam 2018-11-26

    [~lchoudhary] Can you please verify if this issue reappears in 7.5
  6. Lokesh Choudhary 2018-11-26

    [~spulipakkam], I can reproduce the issue with 7.5.0.GA. It appears to be a regression. I don't see it on 7.4.1.GA
  7. Gary Mathews 2019-01-07

    Here's a simplified test case:
       const win = Ti.UI.createWindow({ backgroundColor: 'gray' });
       const listView = Ti.UI.createListView({
           templates: {
               template: {
                   childTemplates: [
                       {
                           type: 'Ti.UI.Label',
                           bindId: 'label'
                       }
                   ]
               }
           },
           defaultItemTemplate: 'template'
       });
       const section = Ti.UI.createListSection();
       
       let items = [];
       for (let i = 0; i < 100; i++) {
       	let item = {
       		template: 'template',
       		label: {}
       	};
       	if (i % 2 === 1) {
       		item.label.attributedString = Ti.UI.createAttributedString({
       			text: 'italic row ' + i,
       			attributes: [
       				{
       					type: Ti.UI.ATTRIBUTE_FONT,
       					value: {
       						fontWeight: 'normal',
       						fontStyle: 'italic',
       					},
       					range: [0, 6]
       				}
       			]
       		});
       	} else {
       		item.label.text = 'normal ' + i;
       	}
       	items.push(item);
       }
       
       section.setItems(items);
       listView.setSections([ section ]);
       
       win.add(listView);
       win.open();
       
  8. Gary Mathews 2019-01-07

    master: https://github.com/appcelerator/titanium_mobile/pull/10575
  9. Samir Mohammed 2019-01-08

    FR Passed, waiting on Jenkins build to merge.
  10. Carlos Henrique Zinato 2019-01-11

    Awesome! I'm facing this problem on my current version (7.5.1.RC). Is this fix on 7.5.1.v20190108052418 (version from 08 of January)? Thanks!
  11. Carlos Henrique Zinato 2019-01-11

    Nope, it does not work for this version. Working fine on 7.4.3.v20190108080441 but not working with 7.5.1.v20190108052418. Is this going to be merged into 7.5.1 before GA?
  12. Ygor Lemos 2019-01-14

    Please merge this on 7.5.1.GA, we have several new screens depending on this for production release!
  13. Gary Mathews 2019-01-14

    7_5_X: https://github.com/appcelerator/titanium_mobile/pull/10611
  14. Carlos Henrique Zinato 2019-01-15

    yay! Gonna run a couple of tests and let you know how is it looking. Cheers!
  15. Samir Mohammed 2019-01-15

    Closing ticket, Verified fix in SDK Version 8.1.0.v20190115054502 and SDK version 8.0.0.v20190114160512. Test and other information can be found at: 7_5_X: https://github.com/appcelerator/titanium_mobile/pull/10611 8.0.0: https://github.com/appcelerator/titanium_mobile/pull/10575 Verified with the test case mentioned above by [~gmathews].
  16. Samir Mohammed 2019-01-15

    Also verified using SDK version 7.5.1.v20190115054254
  17. Carlos Henrique Zinato 2019-01-16

    Tested and everything looks fine! Thanks guys

JSON Source