musescore / musescore/MuseScore

XmlStreamReader is not a stream reader

Open
#23,725 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

P3 tech debt
Dominant language
C++
Stars
15.1k
Forks
3.3k
Avg merge
2d 2h
Merged PRs (30d)
91

Description

Contrary to what the name suggests, it loads the entire file at once, parses it all at once, and then pretends to be a stream reader by using the same inconvenient interface as a stream reader would have.

If the whole document is parsed at once into some DOM / data structure, a much more convenient interface is possible: then you could just query elements and attributes in any order you want. See for example PugiXml in the MEI module, or TinyXML's actual interface.
But the disadvantage is higher memory usage. Most MuseScore files are too small for this to become a real problem, but still.

With a stream reader interface, the memory usage is lower because only some state parameters and a small portion of XML data need to be in memory. But the disadvantage is the disability to query things in an arbitrary order. Instead, it just looks at the element that comes next, and you will need to handle that at that moment, instead of whatever moment is convenient for you.

What we have now, is worst of both worlds: the limited interface of a stream reader, combined with the memory usage of a DOM model. This makes little sense :)

Since we're used to the stream reader interface, I vote we fix the implementation to be a real stream reader, but other options can be considered as well.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the XmlStreamReader implementation and its callers, then compare its behavior with the PugiXml usage in the MEI module and the TinyXML interface mentioned in the issue. Define whether the intended result is true streaming or another interface before changing code; done requires an agreed design and matching memory and access behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.