musescore / 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
12.08k stars 2.61k forks source link

[MU4 Issue] Autosave freezes application for 5-15 seconds #15259

Closed joshuaboniface closed 11 months ago

joshuaboniface commented 1 year ago

Describe the bug While working in Musescore (4.0 stable and 4.0 nightlies at least since August 2022 when I started testing them) on Debian Linux 11.0 with the AppImage, the app will occasionally freeze and become unresponsive for anywhere from 5-15 seconds. Adjusting the autosave time will change the apparent frequency that these happen, so it certainly seems related.

Running with the application in the terminal, I see the following log lines, with the first 3 repeated approximately 30 times during the freeze. I tend to get the "force close application?" dialog from my desktop environment about when the last ERROR is printed, then it clears anywhere from 1-4 seconds later and it becomes responsive again as soon as the doSave: success line is printed.

23:50:57.183 | ERROR | main_thread | LayoutSystem | justifySystem: *** System justification error ***
23:50:57.226 | ERROR | main_thread | LayoutSystem | justifySystem: *** System justification error ***
23:50:57.266 | ERROR | main_thread | LayoutSystem | justifySystem: *** System justification error ***
23:50:59.744 | INFO  | main_thread | NotationProject | doSave: success save file: "/home/joshua/Music/The Battle of Epping Forest.mscz.autosave" 

This was previously reported in https://musescore.org/en/node/313431 but aside from the workaround of "disabling autosaves", this doesn't really solve the problem (autosaves are important!). Given that this is still occurring in 4.0 stable and I don't see any obviously-related existing open or closed issues, I figured I'd bring it up.

I'm on a high-quality high-performance NVMe drive with plenty of free RAM, so this isn't a backend disk issue; it seems to be the application itself, and the error is cryptic about what the cause might be.

This is just one example score, I've had it happen in multiple. If it might be related, I tend to work a lot with imported MIDI files; I rarely write from-scratch scores so that might have something to do with it.

To Reproduce Steps to reproduce the behavior:

  1. Run Musescore on (presumably any) Linux with the Appimage
  2. Work in a large score (imported from MIDI file?)
  3. See occasional freezes and crashes
  4. Reduce or increase autosave time to adjust frequency of freezes
  5. Observe error above in terminal

Expected behavior The app should be able to gracefully autosave in the background while continuing to run and be responsive to the user at all times. Background tasks should not interrupt flow.

Screenshots See log output above.

Platform information

Additional context More than willing to test bugfix PRs. Seems to also happen with manual saves as well.

dxing97 commented 1 year ago

I'm having a similar issue on macOS 12.5 and Ubuntu 20.04. Command line warnings are fairly inconsistent while saving though. Usually I'll see something like this:

14:25:22.853 | INFO  | main_thread | ActionsDispatcher | dispatch: try call action: file-save
14:25:33.108 | WARN  | main_thread | SpannerWriter | SpannerWriter: SpannerWriter: spanner (HairPin) doesn't have an endpoint!
14:25:33.108 | WARN  | main_thread | SpannerWriter | SpannerWriter: SpannerWriter: spanner (HairPin) doesn't have an endpoint!
14:25:33.132 | WARN  | main_thread | Score      | endCmd: no command active
14:25:41.514 | WARN  | main_thread | SpannerWriter | SpannerWriter: SpannerWriter: spanner (HairPin) doesn't have an endpoint!
14:25:41.515 | WARN  | main_thread | SpannerWriter | SpannerWriter: SpannerWriter: spanner (HairPin) doesn't have an endpoint!
14:25:41.761 | INFO  | main_thread | NotationProject | doSave: success save file: "/home/

Although the number of warnings varies. Sometimes they don't appear at all! These errors seem like they may be related; they appear most of the time when I make changes to the score, which can also be slow at times:

14:41:16.956 | ERROR | 139892982015744 | MuseSamplerSequencer | addNoteEvent: Unable to add event for track
Ending previous ranged articulation, but no 'end ranged' call occurred!
14:41:16.956 | ERROR | 139892982015744 | MuseSamplerSequencer | addNoteEvent: Unable to add event for track
Ending previous ranged articulation, but no 'end ranged' call occurred!
14:41:16.957 | ERROR | 139892982015744 | MuseSamplerSequencer | addNoteEvent: Unable to add event for track
Ending previous ranged articulation, but no 'end ranged' call occurred!
14:41:16.957 | ERROR | 139892982015744 | MuseSamplerSequencer | addNoteEvent: Unable to add event for track
Ending previous ranged articulation, but no 'end ranged' call occurred!
14:41:16.959 | ERROR | 139892982015744 | MuseSamplerSequencer | addNoteEvent: Unable to add event for track
Ending previous ranged articulation, but no 'end ranged' call occurred!

The only other thing I can think of is just that this score is huge (3.1MB file size with VSTs, 1.2 MB without, 50ish parts). It was typed in by hand and imported from musescore 3, so it's not directly related to MIDI import at least.

akberg commented 1 year ago

This is a big issue when scores get large. Both engraving and saving seems (not surprisingly) to be very resource heavy tasks. Are they actually both done on the main thread, as the profile report below shows?

image

When MS hangs it usually still doesn't use more than some 13% of CPU power (4-core Intel core i5-1135G7). Could it be worth investigating how the threads can be used wiser?

It would also be nice with a feature to reduce the rendering quality of the score while working.

RrOoSsSsOo commented 1 year ago

Even worst on 1.5-2.0 MB of .mscz file. But also Windows is affecred. Please put as P0 priority because it's a crippling bug: imagine to had set the auto-save to 1 minute and the saving during for 100-120 seconds... MS4 is always locked!

image

RrOoSsSsOo commented 1 year ago

Is possible to make saving a "not locking interface" task? (Or save immediately the music xml and then, in a not loking interface way, compress it into .mscz?)

RomanPudashkin commented 1 year ago

@joshuaboniface @dxing97 @akberg @RrOoSsSsOo hello! Could someone please try this fix (please note that the default autosave interval has been increased: 3 min -> 5 min)? Is it better? Thanks! https://github.com/musescore/MuseScore/pull/18922

RomanPudashkin commented 11 months ago

Closing, no response. Autosave should be less annoying now

joshuaboniface commented 11 months ago

Sorry, yes - running the latest release it doesn't seem to be occurring any longer. If it reoccurs I will update the issue.