Skip to content

fix #34026: prevent unlimited memory for image via maxScaledImageDim#34038

Merged
alexpavlov96 merged 1 commit into
musescore:mainfrom
alexpavlov96:image-scaled-dim
Jul 2, 2026
Merged

fix #34026: prevent unlimited memory for image via maxScaledImageDim#34038
alexpavlov96 merged 1 commit into
musescore:mainfrom
alexpavlov96:image-scaled-dim

Conversation

@alexpavlov96

@alexpavlov96 alexpavlov96 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Resolves: #34026

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

A new configuration option maxScaledImageDim is added to IEngravingConfiguration, implemented in EngravingConfiguration with a default value of 4096, and exposed via a getter/setter pair. The corresponding mock class is updated with matching methods. In TDraw, raster image drawing logic now computes an estimated scaled image size from the current painter world transform and uses the configured maximum dimension, alongside the existing printing/SVG check, to decide whether to draw directly or use the buffered/offscreen scaling path.

Related PRs: None identified.

Suggested labels: engraving, rendering

Suggested reviewers: None identified.

A pixel dreams of growing tall,
but limits keep it from a sprawl.
Four thousand ninety-six, its ceiling bright,
direct or buffered — chosen right.
The rabbit hops through scaled delight. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning No PR description was provided, so the required resolves line, summary, and checklist items are missing. Add the template sections: a Resolves line, a short change summary, and the checklist items, including testing and CLA acknowledgement.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the change: it describes limiting image scaling to avoid memory issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Linked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped musescore/muse_framework.git.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/engraving/rendering/score/tdraw.cpp (1)

2067-2074: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Document the maxDim <= 0 disable semantics.

useDirectDraw silently skips the size-based clamp whenever maxDim <= 0. This is a reasonable escape hatch but isn't documented anywhere (interface, impl, or here), so a future reader/config author could set 0 expecting "always direct-draw" or misunderstand the behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/engraving/rendering/score/tdraw.cpp` around lines 2067 - 2074, Document
the `maxScaledImageDim()` disable behavior in `tdraw.cpp` around `useDirectDraw`
so it’s clear that `maxDim <= 0` turns off the size-based direct-draw clamp. Add
a brief note in the relevant implementation/comments near the `useDirectDraw`
decision, and if there is a matching configuration/interface declaration for
`maxScaledImageDim()`, document the same semantics there so readers understand
that 0 or negative means “no limit” rather than “always direct-draw.”
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/engraving/rendering/score/tdraw.cpp`:
- Around line 2067-2074: Document the `maxScaledImageDim()` disable behavior in
`tdraw.cpp` around `useDirectDraw` so it’s clear that `maxDim <= 0` turns off
the size-based direct-draw clamp. Add a brief note in the relevant
implementation/comments near the `useDirectDraw` decision, and if there is a
matching configuration/interface declaration for `maxScaledImageDim()`, document
the same semantics there so readers understand that 0 or negative means “no
limit” rather than “always direct-draw.”

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 63ada2b6-a937-4c8a-b222-1ce221505e86

📥 Commits

Reviewing files that changed from the base of the PR and between f9fe0fe and 0fd4b71.

📒 Files selected for processing (5)
  • src/engraving/iengravingconfiguration.h
  • src/engraving/internal/engravingconfiguration.cpp
  • src/engraving/internal/engravingconfiguration.h
  • src/engraving/rendering/score/tdraw.cpp
  • src/engraving/tests/mocks/engravingconfigurationmock.h

@alexpavlov96 alexpavlov96 linked an issue Jul 2, 2026 that may be closed by this pull request
4 tasks
@abariska

abariska commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🟢 TESTED on macOS 26.3, Win 11, Ubuntu 20
Please, merge to master

@alexpavlov96 alexpavlov96 merged commit b970739 into musescore:main Jul 2, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No RAM limit when zooming score with high resolution picture

3 participants