Skip to content

mapcairo.c: avoid double scaling of SVG symbols (fixes: #7430) - #7583

Merged
jmckenna merged 6 commits into
MapServer:mainfrom
johanez:revert-librsvg-render
Aug 11, 2026
Merged

mapcairo.c: avoid double scaling of SVG symbols (fixes: #7430)#7583
jmckenna merged 6 commits into
MapServer:mainfrom
johanez:revert-librsvg-render

Conversation

@johanez

@johanez johanez commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Since 8.6, rsvg_handle_render_cairo() (marked as deprecated) was replaced with the newer rsvg_handle_render_document(), however this caused scaling issues (#7430). This PR implements a simple workaround by reverting back to the legacy function, solving the issues.
This PR removes a duplicate application of scale when rendering svgs to raster with librsvg.

What does this PR do?

Path symbol size directly to rsvg_handle_render_document() without scaling as the scaling is already passed with the viewport parameter, while mainting options to use the deprecated rsvg_handle_render_cairo() vor librvg versions before v2.46.

What are related issues/pull requests?

AI tool usage

Tasklist

  • Make sure code is correctly formatted (cf pre-commit configuration)
  • Add test case(s) in /msautotest (follow steps in Regression Testing)
  • Add documentation
  • Review
  • Adjust for comments
  • All CI builds and checks have passed

Since 8.6, rsvg_handle_render_cairo() (marked as depriceated) was replaced with the newer rsvg_handle_render_document(), however this caused scaling issues (MapServer#7430). This PR implements a simple workaround by reverting back to the legacy function, solving the issues.
@johanez

johanez commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

This fails two CI checks, because the use of the deprecated function svg_handle_render_cairo() (which is the base of this workaround).

  • maybe I can add exemption from throwing a build error?
  • else proper a solution with rsvg_handle_render_document() might be needed

@jmckenna

Copy link
Copy Markdown
Member

@johanez there are actually 2 different failing errors in your tests (click on each of the 2 runs, and you will see what I mean). For example: https://github.com/MapServer/MapServer/actions/runs/29905134730/job/88913132480?pr=7583

@johanez

johanez commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@jmckenna I found another possible solution, using the non-deprecated rsvg_handle_render_document() and not using cairo_scale() for rsvg rasterization, as the scaling is already done by setting the viewport.

@jmckenna

jmckenna commented Aug 5, 2026

Copy link
Copy Markdown
Member

@johanez can you join the discussion in #7430 to propose your change / give feedback for the other proposed change?

@jmckenna

jmckenna commented Aug 5, 2026

Copy link
Copy Markdown
Member

@johanez please also update the title of this pull request, thanks.

@johanez

johanez commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

I updated the test files. As svg rendering was not working correctly, the coordinates used in the test point-identify with anchor test were not correct.

@johanez johanez changed the title mapcairo.c: revert to svg_handle_render_cairo() (fixes: #7430) mapcairo.c: avoid double scaling of SVG symbols (fixes: #7430) Aug 5, 2026
… version

This allows cairo and older rsvgr rendering with scale_cairo>
Also fixed incorrect test png file name
@johanez

johanez commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Update from my side: I used the solution suggested by @bhark, as it more easily allows to be compatibel with older librsvg versions (<2.43) as well.

Some test still fail, I think mostly because the expected results are made with broken svg sld/expected/sld_url_linemark.png

However, it's quite a task for me to go through this (skill and capacity wise, I have a very un-efficient test setup now), so if anyone want to have a look, more than welcome!

@jmckenna

jmckenna commented Aug 6, 2026

Copy link
Copy Markdown
Member

@johanez thanks. At this point, the issue isn't fixing the tests in this pull request, the issue is that people in #7430 have confirmed a different fix, than this one. I really want everyone to agree on one fix...I'll give this a few days more to await everyone's feedback here. Thanks for pushing this forward @johanez very appreciated!

@bhark

bhark commented Aug 7, 2026

Copy link
Copy Markdown

@jmckenna The fix implemented here is the same as i suggested in #7430, and seems functional to me. #7462 just adds the guard, which is already in this PR.

With regards to the failing tests @johanez the original commit that introduced this issue also regenerated the reference pictures, so they're currently checking the correct rendering against a faulty baseline. I think we just need to regenerate the references (all 6) and call it a day. I'll open a PR on @johanez fork if i get the time later today.

@jmckenna jmckenna added the backport branch-8-6 To backport a pull request to branch-8-6 label Aug 7, 2026
@jmckenna

jmckenna commented Aug 7, 2026

Copy link
Copy Markdown
Member

@johanez @bhark I've updated the expected test results here, and the rendering looks a lot better (see 87144bb )

@johanez

johanez commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @jmckenna and @bhark . I indeed changed it into using the same fix as @bhark suggested, as it's simpler to keep the older librsvg version guard.

Looks like this is ready to merge and great if you backport it to 8.6.6!

@jmckenna

Copy link
Copy Markdown
Member

thanks again @johanez and @bhark !

@jmckenna
jmckenna merged commit 3abd4dc into MapServer:main Aug 11, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport branch-8-6 To backport a pull request to branch-8-6

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants