Duplicate / corrupt lines on save/reload in file imported from MusicXML

• Jul 4, 2015 - 22:48
S3 - Major

Ubuntu 14.04, GIT commit: 79a8fc8

1) load the attached MusicXML file, which contains a few simple text "direction" elements, including a "text line" at the start of measure 2. I created this MusicXML in MuseScore but manually moved the direction element in measure 1 from the beginning to the end of the measure, which seems to be a necessary condition for the bug to appear.

2) save (as MSCZ)

3) load the MSCZ

4) drag the textline in any direction

Result: you will see a duplicate textline (of zero length) has been created. Save and load again, and you get two more duplicates - it doubles each time. See #67001: Crash on opening file with apparently invalid note anchored textline - in this case, there were ~4096 duplicates of the line.

This issue is seen in both 2.0.1 and in current builds, so it apparently affects both the DOM and pull parsers.

I believe the MSCZ saved at step 2 is corrupt - it contains two textline starts with the same id. Somehow, this error keeps compounding itself.

I don't totally understand the cause of the problem, but I think it has to do with the direction element at the end of meausre 1 - I can't reproduce see the problem without it. But I also don't see the problem without either the element in measure 3 or the one in measure 4 - somehow, it's the interaction between these that causes the issue. Still, the direction element at the end of measure 1 seems to be the real key, I think, since that is the case we normally we not create ourselves (the original MusicXML file in #67001: Crash on opening file with apparently invalid note anchored textline came from Sibelius, I believe).

Attachment Size
duplicate-lines.xml 4.4 KB


I can't reproduce from scratch this issue.
By deleting "staff text" in your file, then by re-writing the same in the second measure, the anchorage is like this (as expected, "on" the barline)
staff text.jpg
After load and reload, no issue for me (one single "text line" displayed)

- In your file, the anchorage of "staff text" is like this ("before" the barline, or at the end of the first barline)
I can't duplicate this start of anchorage (in a empty first measure)
How do you explain and reproduce this? Thanks.

You say you cannot reproduce from scratch, but can you reproduce with the file I posted?

That file was generated from MuseScore but then edited by hand to simulate the file from Sibelius that was posted in #67001: Crash on opening file with apparently invalid note anchored textline. Thanks for pointing out the strange attachment of the text line, I think that is another symptom of what is going on.

FYI, normally, the MusicXML file might be structured like this:

1) measure 1
a) staff text
b) rest

2) measure 2
a) text line
b) rest

But in the file that came from Sibelius, the staff text in measure 1 appeared *after* the rest, not before it. So to reproduce this in my example, I took the MusicXML and edited it by hand to do the same.

I don't think MusicXML files generated by MuseScore would ever look like that and I suspect this is what is confusing the MusicXML import.

Yes, of course, I can reproduce with your file on a current nightly build. But also with this Nightly on May 19, 2014: 56177c3
With result: the same: excepted the text line size, which has changed - the default value - there is a while, no matter, it's not involved in this issue.
text line.jpg

The staff text is created in a segment on its own in the first measure. The segment is empty but has the staff text has annotation. When writing the first measure, we check if there is a spanner starting somewhere in the measure, with a segment on this tick. And yes, the staff text segment matches, so we write the line. Then we go to measure two, and the first chordrest segment also matches the start of the line, so we write it again...

I see two solutions
1/ We fix the MusicXML import to not create empty segment with staff text at the end of a measure. As far as I known it's not possible to create this construct with the UI. The end of the measure being tick 1920 for a 4/4 measure, that should be the start of next measure. I can see how it could be a problem for last measure...
2/ We fix the writing of spanners to make sure they start on a segment containing elements and not annotations only. I couldn't find a way to create a text line starting on an empty segment since now we automatically delete a spanner if the segment doesn't have elements.

I would prefer 1/. Maybe we should use the previous chordrest instead of the next measure?

Would be interesting to know how Sibelius creates that - is this the normal result of attaching text to a measure rest, or maybe it was attached to the barline, or maybe they have some other mechanism?

Staff text at the end of a measure is a fairly common pattern in MusicXML. Both Finale and Sibelius support it. E.g. see Recordares Telemann sample at the end of measures 9, 15 and 32.

This means MuseScore should be able to handle it without issues. Moving end of measure staff text to the start of the next measure (and ignoring staff text at the end of the last measure) seems good enough to me (solution 1/).