wxDataViewListCtrl performance issues + crashes Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
User avatar
RedStreak
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Mar 30, 2018 4:58 pm

wxDataViewListCtrl performance issues + crashes

Post by RedStreak » Fri Mar 30, 2018 5:22 pm

Hi everyone,

I've been a long time lurker of this forum and just recently decided to register because of a problem I've been having with wxDataViewListCtrl.

Not sure if anyone else has come across this, I have a few wxDataViewListCtrl's that contain simple list data ( maximum of about four columns of text only ). I noticed that when adding a lot of items to the wxDataViewListCtrl, i.e. 400+ rows, during the time it would take to fill the control, if I clicked any of the sortable columns, this would cause a crash. As a workaround, I disabled the control while filling it which helped reduce crashes but still occasionally when filling the control with a lot of data it would randomly crash.

I had thought of using wxListCtrl but for some of the tasks I need to perform, wxDataViewListCtrl seems like the best option. However it's performance for large amounts of data is not that great.

Has anyone else experienced such issues with wxDataViewListCtrl?

Thanks,

Some details:
wxWidgets version: 3.1.0
Platform: Windows 10 Pro x64

User avatar
doublemax
Moderator
Moderator
Posts: 15289
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxDataViewListCtrl performance issues + crashes

Post by doublemax » Fri Mar 30, 2018 6:39 pm

Unless you're adding items from a secondary thread (which you're not allowed to), the control must not crash. If you can reproduce this in the "dataview" sample, you should open a bug report at http://trac.wxwidgets.org

Performance wise, are you talking about the time it takes to add the items or about the general performance once you've added many items to it?

Instead of disabling the control while adding, try Freeze()/Thaw().
Use the source, Luke!

User avatar
RedStreak
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Mar 30, 2018 4:58 pm

Re: wxDataViewListCtrl performance issues + crashes

Post by RedStreak » Sat Mar 31, 2018 9:40 am

Thanks for the quick response doublemax, I'll look into reproducing the issue if possible, though as you've pointed out, I've just realized I am using the control in a multi threaded app so there could be something funny going on.

Regarding the control itself, I think both the usage and filling performance of the control take a considerable hit once you're adding/have added a lot of items. Sorting for example seems to be quite slow if the control has a lot of items. I was thinking this is because the underlying data view model actually stores all the data and so I doubt there is a workaround.

The main reason I wanted to use this control was because of the simple interface and because I could associate items by rows easily.

User avatar
doublemax
Moderator
Moderator
Posts: 15289
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxDataViewListCtrl performance issues + crashes

Post by doublemax » Sat Mar 31, 2018 1:15 pm

Which features of wxDataViewListCtrl do you actually need? I would use wxDVC or wxGrid only as a last resort, i think their API is unnecessarily complicated. Whenever possible i would try to get away with a wxListCtrl in virtual mode (meaning i manage the data myself, the controls only displays it). I've handled a table with about 1 million entries coming from a SQlite database through wxSQLite3 without problems. I could scroll through it in realtime (proper indexing of the database is of course required).
Use the source, Luke!

User avatar
RedStreak
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Mar 30, 2018 4:58 pm

Re: wxDataViewListCtrl performance issues + crashes

Post by RedStreak » Sat Mar 31, 2018 5:21 pm

I guess the biggest advantage for me anyway of the wxDVLC is that I don't have to store or handle the list data especially since I have several of them. I initially thought of using the wxListCtrl in virtual mode as you suggest but I didn't go through with it as I realized I'd have to re-do the item selection handling wxDVLC already has and also find an efficient way to store all the items.

Code: Select all

int 	GetSelectedRow () const
void 	SelectRow (unsigned row)
void 	UnselectRow (unsigned row)
bool 	IsRowSelected (unsigned row) const
But I guess everything has a price, I will look into wxListCtrl again. Thank you once again.

Anil8753
Experienced Solver
Experienced Solver
Posts: 92
Joined: Sat Jan 16, 2016 5:57 am
Location: India

Re: wxDataViewListCtrl performance issues + crashes

Post by Anil8753 » Mon Apr 02, 2018 7:17 am

I could not understand your issue completely. I am not sure about crashes but performance issues can be solved. I am using wxDataViewCtrl with more than ~10K rows and 200 columns.

Remember one thing, if wxDVC has sorting applied to any column and you add/delete/update any row, causes the resorting again.
Think of if you have thousands of rows in wxDVC and adding/deleting rows in a loop or in bulk operation.

wxDataViewModel

Code: Select all

    bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item );
    bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items );
    bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item );
    bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items );
    bool ItemChanged( const wxDataViewItem &item );
    bool ItemsChanged( const wxDataViewItemArray &items );
In all cases resorting happens, that causes the huge impact on performance.

You have 2 solutions:
1. Remove sorting (API already available), perform all your add/delete/update operations and apply sorting again (API available)
2. Preferred way: Lock the wxDataViewCtrl updates by using

Code: Select all

wxWindowUpdateLocker noUpdates(this);
ItemAdded(...);
or
ItemsAdded(...);
wxDataViewCtrl internally checks if control is locked for update it skips the sorting while add/delete/update operation. This is the solution I am using.

User avatar
RedStreak
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Mar 30, 2018 4:58 pm

Re: wxDataViewListCtrl performance issues + crashes

Post by RedStreak » Mon Apr 02, 2018 10:19 am

Anil, I think that might be exactly what I was looking for thank you. I should probably have phrased the question better. I've noticed an improvement in filling performance by locking the updates to the wxDVLC as you suggest.

Regarding the other part of the question ( the crashes ) those are probably related to directly updating the control from another thread, which is something I should not have done in the first place.

Post Reply