JoshuaBonn1 / MuseScore

MuseScore is an open source and free music notation software. For support, contribution, bug reports, visit MuseScore.org. Fork and make pull requests!
https://musescore.org
Other
0 stars 0 forks source link

Timeline zooming causes serious lag #20

Closed JoshuaBonn1 closed 7 months ago

JoshuaBonn1 commented 5 years ago

Zooming in and out on the timeline using Ctrl + Scroll causes serious lag on large scores. This is likely because of redrawing the timeline every single time the zoom changes. There are a few solutions for this:

  1. Instead of redrawing the timeline, adjust the size and positions of all the effected items. This will remove the need to rescan the score every time.
  2. Use transforms. Instead of resizing or moving anything, simply change the transform that the timeline uses in order to shrink the timeline. This would work only for the grid. The meta rows would require a full redraw as the text would not resize properly.
JoshuaBonn1 commented 5 years ago

After using callgrind, the result is to be expected. After fixing some getFont() calls and other loop invariants, the clear slow down was clearing and recreating all the graphic items. My first fix will be adjusting all the widths of the items to see if there is any particular speed up. If that works, I will adjust the x position of the items as well and see what happens.

For the record, the meta actually took the most time to clear and redraw due to dealing with text items (expensive). Just reusing these would cause a large speedup (supposedly).

JoshuaBonn1 commented 5 years ago

While some graphical glitches remain, simply updating the x and width of the cells resulted in basically no slow down. With good news from this, creating a "redraw" of the meta should significantly decrease the zooming lag, hopefully down to 0.

JoshuaBonn1 commented 5 years ago

5d673b31bc49e512ccffd596f15e235b9ce288f8 attempts to fix the lag.