Skip to content
This repository has been archived by the owner on Oct 14, 2019. It is now read-only.

Massive lag with ListViews #345

Open
MintPaw opened this issue Mar 18, 2016 · 4 comments
Open

Massive lag with ListViews #345

MintPaw opened this issue Mar 18, 2016 · 4 comments

Comments

@MintPaw
Copy link

MintPaw commented Mar 18, 2016

This is more of a question than an issue as I'm likely simply doing something wrong. I'm trying to make a list of periodically updating text values in a ListView, a list in which I sometime need to completely change to new data. I'm doing this as:

_list.dataSource.removeAll();
for (c in _topEntry.children) _list.dataSource.add(c.dsEntry);

Where c.dsEntry is an object containing only a .text property be updated.

Also, individual objects don't update automatically, after updating each tick my "data source objects" I must also dispatch:

cast(_list.dataSource, DataSource).dispatchEvent(new Event(Event.CHANGE));

Although this isn't very relevant.

The removeAll/add stage is incredibly slow often taking 7+ seconds only removing/adding 100 objects total, what am I doing wrong? The call stack showing the lag is here

Is there a better place for me to learn haxeui than here? The lack of documentation makes it almost impossible to learn, unless you're an expert in a similar API I presume. And I'm not seeing any forums or IRC channels.

@ianharrigan
Copy link
Owner

Hi,

The problem is each time you add to the data source the whole list invalidates which is an expensive operation. One way around this is:

list.dataSource.removeAll();
list.dataSource.allowEvents = false;
for (i in item) {
    list.dataSource.add(i);
}
list.dataSource.allowEvents = true;

That should stop all the invalidations and speed things up considerably. The data source emitting events isnt the best design and i dont think it will come over to V2, at least not in the way it works currently.

As for you docs, im afraid the docs are pretty poor... Simply put i dont have time to rectify it either :(

@MintPaw
Copy link
Author

MintPaw commented Mar 18, 2016

That's actually the first thing I tried, setting them to false works, but setting them back true throws an error

Class cast error
Called from haxe.ui.toolkit.containers.ListView::syncUI line 252
Called from haxe.ui.toolkit.containers.ListView::_onDataSourceChanged line 224
Called from openfl._legacy.events.EventDispatcher::dispatchEvent line 98
Called from haxe.ui.toolkit.data.DataSource::dispatchChanged line 202
Called from haxe.ui.toolkit.data.DataSource::set_allowEvents line 46
Called from mintDebugger.MintDebugger::setScope line 95 // allowEvents = true

This is using the latest git version.

@ianharrigan
Copy link
Owner

Thats very strange. If you have time and can create a minimal sample, especially one that shows that error, then it will be easier to help work out whats going one. Ive used that .allowEvents with no problems.

@MintPaw
Copy link
Author

MintPaw commented Mar 18, 2016

I was able to fix it using:

var newDS:ArrayDataSource = new ArrayDataSource();
for (c in _topEntry.children) newDS.add(c.dsEntry);
_list.dataSource = newDS;

This works for now I guess, I'm guessing I've broken it since I've just been hacking stuff together.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants