ArthurClemens / polythene

Material Design component library for Mithril and React
590 stars 43 forks source link

Excessive rendering with multiple elements #79

Closed andershol closed 5 years ago

andershol commented 5 years ago

If you have many fields on a page the will redraw many times. For example this simple test with 100 rows each with 10 text fields will redraw 3001 times in both Firefox and Chrome which could take minutes: https://jsbin.com/jivezitaku/edit?html,output

ArthurClemens commented 5 years ago

Thanks for your report. I hadn't noticed the performance penalty before.

Several observations:

andershol commented 5 years ago

I only noticed this after I tried using real data for something I did a while ago, so I was also surprised (especially that it was so non-linear -- going from 5 to 10 items per row). It sound like the changes you are planning will also help make normal pages a little faster and not just this kind of contrived huge page, so that is good. I assume Mithril will only call redraw for events that have been subscribed to, so if polythene did more of its styling updates with css, maybe it could avoid subscribing to the events. And of course, thanks a lot for all your work on this project.

ArthurClemens commented 5 years ago

I assume Mithril will only call redraw for events that have been subscribed to

No, Mithril redraws for all events.

ArthurClemens commented 5 years ago

You can see progress in this flems.

andershol commented 5 years ago

No, Mithril redraws for all events.

Okay, it was just an idea, and it is probably not that important as human-generated events are often far apart (several ms). But I don't think I understand the link to say that it will redraw for event handlers that are not used, and a little test also seems to say that it isn't so.

You can see progress in this flems.

Very nice. 👍