Subject: bug#55322: closed (Re: bug#55322: 28.1; :base-uri not working for svg images on mac)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 11 May 2022 17:00:03 +0000

Your bug report

#55322: 28.1; :base-uri not working for svg images on mac

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
55322: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55322
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#55322: 28.1; :base-uri not working for svg images on mac
From: Alan Third <[email-masked]>
To: Howard Melman <[email-masked]>
Cc: [email-masked]
Date: Wed, 11 May 2022 17:59:20 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

On Tue, May 10, 2022 at 08:17:32PM -0400, Howard Melman wrote:
> On May 10, 2022, at 1:17 PM, Alan Third <[email-masked]> wrote:
> > 
> > Maybe try Jim's builds:
> > 
> >    https://github.com/jimeh/emacs-builds
> > 
> > I know SVG was working on them recently.
> 
> It works fine with this build and the latest version of osm.
> The relevant portion of the image is below, so it is clear
> that the :base-uri is working and is the same as what
> didn't previously work for me.
> 
> My best guess is that the version from emacsformac
> I was using had an old librsvg linked.

Thanks for working it through. I guess this means it's a problem with
the emacsformacosx.com builds.
-- 
Alan Third

Subject: 28.1; :base-uri not working for svg images on mac
From: Howard Melman <[email-masked]>
To: GNU Emacs <[email-masked]>
Date: Sun, 8 May 2022 15:16:02 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Please forgive this bug report, I'm a bit out of my depth on the
technologies here but I'm trying.

I found this on the macport of Emacs 28.1 but it fails in a similar
though slightly different way on vanilla emacs 28.1 -Q.  from
https://emacsformacosx.com/

I only know how to reproduce this with the osm package available from
GNU ELPA or https://github.com/minad/osm This renders maps from open
street maps inside emacs.  It requires the package compat.

To reproduce, load the package compat and then osm (just osm.elc) and
do M-x osm-search and enter a place with completion, I used London for
this example.  In Emacs 28.1 -Q it renders as follows:

The issue is that one of the tiles isn't being rendered.  osm displays an svg
location marker at the searched for location and displays the map tile 
behind that. On the macport it renders as follows which I think exposes
the issue more clearly:

In Emacs 27, osm displays this tile just fine because it included
the tile image as base64 encoded data because :base-uri 
functionality didn't exist.  As of Emacs 28 it tries to use it
for performance reasons an apparently it works fine on
linux systems. This can be found on line 929 of osm.el

The text of the image can be obtained via (buffer-string) in
the *osm* buffer.  For the above I see (with a few newlines
added for clarity)::

#("    
    
" 0 1 (display ((slice 170 194 86 62) (image :width 256 :height 256 :file "/Users/hmelman/.emacs.d/var/osm/default/9-254-169.png" :type png)))
1 2 (display ((slice 0 194 256 62) (image :width 256 :height 256 :file "/Users/hmelman/.emacs.d/var/osm/default/9-255-169.png" :type png)))
2 3 (display ((slice 0 194 256 62) (image :width 256 :height 256 :file "/Users/hmelman/.emacs.d/var/osm/default/9-256-169.png" :type png)))
3 4 (display ((slice 0 194 256 62) (image :width 256 :height 256 :file "/Users/hmelman/.emacs.d/var/osm/default/9-257-169.png" :type png)))
5 6 (display ((slice 170 0 86 256) (image :width 256 :height 256 :file "/Users/hmelman/.emacs.d/var/osm/default/9-254-170.png" :type png)))
6 7 (display (image :width 256 :height 256 :type svg :base-uri "/Users/hmelman/.emacs.d/var/osm/default/9-255-170.png" :data "<svg width='256' height='256' version='1.1'
xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
<image xlink:href='9-255-170.png' height='256' width='256'/>
<g fill='#08f' stroke='#028' stroke-width='9' transform='translate(209 64) scale(0.09) translate(-256 -512)'>
<path d='M256 0C167.641 0 96 71.625 96 160c0 24.75 5.625 48.219 15.672
69.125C112.234 230.313 256 512 256 512l142.594-279.375
C409.719 210.844 416 186.156 416 160C416 71.625 344.375
0 256 0z M256 256c-53.016 0-96-43-96-96s42.984-96 96-96
c53 0 96 43 96 96S309 256 256 256z'/>
</g></svg>" :map (((poly . [209 64 189 24 209 14 229 24]) osm-transient (help-echo "London, Westminster, Greater London, En…" pointer hand)))
)) 7 8 (display (image :width 256 :height 256 :file "/Users/hmelman/.emacs.d/var/osm/default/9-256-170.png" :type png)) 8 9 (display (image :width 256 :height 256 :file "/Users/hmelman/.emacs.d/var/osm/default/9-257-170.png" :type png)))

The issue is the image referenced as:
    xlink:href='9-255-170.png'
isn't found even though it is in the directory
    /Users/hmelman/.emacs.d/var/osm/default/

Apparently this works fine on linux.  I originally reported
it here: https://github.com/minad/osm/issues/23

I believe the emacs from https://emacsformacosx.com/
uses librsvg and the macport uses Webkit instead for
the rendering svg, but both fail, so I think it's in whatever
is handling :base-uri.

I don't know how to use the svg.el library but the
equivalent is apparently done via svg-embed-base-uri-image.
Is there a test case I could run via that to generate a
simpler recipe?

Can anyone else verify the use of :base-uri on a mac?

-- 

Howard