all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Ponce <da_vid@orange.fr>
To: Eli Zaretskii <eliz@gnu.org>, Alan Third <alan@idiocy.org>
Cc: 64908@debbugs.gnu.org
Subject: bug#64908: 29.1; svg parse failure
Date: Fri, 4 Aug 2023 18:23:11 +0200	[thread overview]
Message-ID: <cb83ce08-49fa-5e75-8db4-5e597ddb7ac4@orange.fr> (raw)
In-Reply-To: <835y5vw1ay.fsf@gnu.org>

On 04/08/2023 12:26, Eli Zaretskii wrote:
>> Date: Fri, 4 Aug 2023 09:55:03 +0200
>> Cc: 64908@debbugs.gnu.org
>> From: David Ponce <da_vid@orange.fr>
>>
>> On 04/08/2023 07:23, Eli Zaretskii wrote:
>>>> Date: Thu, 3 Aug 2023 21:16:35 +0200
>>>> From: David Ponce <da_vid@orange.fr>
>>>>
>>>> In case it could help, using emacs from master (see details at end
>>>> below), with librsvg2-2.56.0-1.fc38.x86_64 I can insert-image
>>>> dir-src-open.svg and dir-public-open.svg in the *scratch-buffer*
>>>> without issue (see Screenshot1).
>>>>
>>>> However, the same failed using librsvg2-2.56.3-1.fc38.x86_64 (see
>>>> Screenshot2).
>>>>
>>>> I did test also with some KDE breeze icons.
>>>>
>>>> No issue with librsvg2-2.56.0-1.fc38.x86_64.
>>>>
>>>> With librsvg2-2.56.3-1.fc38.x86_64 some icons works, some not (see an
>>>> example in Screenshot3):
>>>>
>>>> /usr/share/icons/breeze/actions/22/go-next.svg doesn't work:
>>>>
>> [...]
>>>>
>>>> /usr/share/icons/breeze/actions/22/go-next.svg works:
>>>>
>> [...]
>>>>
>>>> As far as I can see, other applications (Gwenview, Geeqie, Firefox) don't have
>>>> problem to display the same images with librsvg2-2.56.3-1.fc38.x86_64 installed.
>>>
>>> Thanks, this helps.
>>>
>>> When an image fails to display, do you see any error messages from
>>> librsvg?  Those are usually emitted to stderr, so perhaps you need to
>>> run Emacs in a way that stderr is not discarded, but either shown on
>>> the terminal or written to a file.
>>
>> Hello ELi,
>>
>> I don't see any message on stderr, but a bunch of messages:
>> "Invalid image size (see ‘max-image-size’)" in the *Messages* buffer,
>> probably related to the display of an invalid image (empty square)
>> in the *scratch* buffer. Also, the result of image-size is not the
>> expected image size (22x22 px in example). I attached a screenshot.
> 
> Thanks.  I hope this will help an SVG expert to figure out what's
> going on with these images.
> 
> Alan, do you have time to look into this, per chance?

I investigated further the issue with GDB, with a break in
svg_load_image in image.c, trying to display the image
"/usr/share/icons/breeze/actions/22/go-next.svg":

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
    <defs id="defs3051">
      <style type="text/css" id="current-color-scheme">
        .ColorScheme-Text {
          color:#232629;
        }
        </style>
    </defs>
   <path
      style="fill:currentColor;fill-opacity:1;stroke:none"
	d="m7.707031 3l-.707031.707031 6.125 6.125 1.167969 1.167969-1.167969 1.167969-6.125 6.125.707031.707031 6.125-6.125 1.875-1.875-1.875-1.875-6.125-6.125"
      class="ColorScheme-Text"
      />
</svg>

I think the problem is after the call to
rsvg_handle_get_intrinsic_dimensions at line 11354 in image.c.
Here is the relevant portion of code:

       rsvg_handle_get_intrinsic_dimensions (rsvg_handle,
                                             &has_width, &iwidth,
                                             &has_height, &iheight,
                                             &has_viewbox, &viewbox);

       if (has_width && has_height)
         {
           /* Success!  We can use these values directly.  */
           viewbox_width = svg_css_length_to_pixels (iwidth, dpi,
                                                     img->face_font_size);
           viewbox_height = svg_css_length_to_pixels (iheight, dpi,
                                                      img->face_font_size);

           /* Here one dimension could be zero because in percent unit.
              So calculate this dimension with the other.  */
           if (! (0 < viewbox_width) && (iwidth.unit == RSVG_UNIT_PERCENT))
             viewbox_width = (viewbox_height * viewbox.width / viewbox.height)
               * iwidth.length;
           else if (! (0 < viewbox_height) && (iheight.unit == RSVG_UNIT_PERCENT))
             viewbox_height = (viewbox_width * viewbox.height / viewbox.width)
               * iheight.length;
         }

After the call to rsvg_handle_get_intrinsic_dimensions, the returned
values are:

(gdb) print has_width
$8 = 1
(gdb) print iwidth
$9 = {length = 1, unit = RSVG_UNIT_PERCENT}
(gdb) print iheight
$10 = {length = 1, unit = RSVG_UNIT_PERCENT}
(gdb) print viewbox
$11 = {x = 0, y = 0, width = 22, height = 22}

has_width and has_height are both 1 with iwidth and iheight set to
100%.  has_viewbox is also set to 1, and viewport contains the
dimensions of the image (22x22 pixels).

Then, the code matching "if (has_width && has_height)" is executed,
which, in this case, sets both viewbox_width and viewbox_height to 0,
which further leads to an image_size_error.

Maybe, it is due to a change of specifications since librsvg 2.54.0.

Here is what the spec I found at
<https://gnome.pages.gitlab.gnome.org/librsvg/Rsvg-2.0/method.Handle.get_intrinsic_dimensions.html>
says:

-----
Before librsvg 2.54.0, the out_has_width and out_has_height arguments
would be set to true or false depending on whether the SVG document
actually had width and height attributes, respectively.

However, since librsvg 2.54.0, width and height are now geometry
properties per the SVG2 specification; they are not plain
attributes. SVG2 made it so that the initial value of those properties
is auto, which is equivalent to specifing a value of 100%. In this
sense, even SVG documents which lack width or height attributes
semantically have to make them default to 100%. This is why since
librsvg 2.54.0, out_has_width and out_has_heigth are always returned
as TRUE, since with SVG2 all documents have a default width and height
of 100%.

As an example, the following SVG element has a width of 100 pixels and
a height of 400 pixels, but no viewBox. This function will return
those sizes in out_width and out_height, and set out_has_viewbox to
FALSE.

<svg xmlns="http://www.w3.org/2000/svg" width="100" height="400">

Conversely, the following element has a viewBox, but no width or
height. This function will set out_has_viewbox to TRUE, and it will
also set out_has_width and out_has_height to TRUE but return both
length values as 100%.

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 400">
-----

I hope it will help an SVG expert to fix the issue.

Thanks
  









  reply	other threads:[~2023-08-04 16:23 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-28  1:10 bug#64908: 29.1; svg parse failure Daniel Vianna
2023-07-28  6:05 ` Eli Zaretskii
     [not found]   ` <CAMLJ+NHO38NYGPctAj9MmMwy4tz8aSqHgLDWQhQaDm7FUP7Yqw@mail.gmail.com>
2023-07-28 11:00     ` Eli Zaretskii
2023-07-28 12:48       ` Visuwesh
2023-08-03  8:11         ` Eli Zaretskii
2023-08-03 19:16 ` David Ponce
2023-08-04  5:23   ` Eli Zaretskii
2023-08-04  7:55     ` David Ponce
2023-08-04 10:26       ` Eli Zaretskii
2023-08-04 16:23         ` David Ponce [this message]
2023-08-04 18:32         ` Alan Third
2023-08-04 19:08           ` Eli Zaretskii
2023-08-04 21:08             ` David Ponce
2023-08-05  8:30               ` David Ponce
2023-08-05  9:58                 ` Alan Third
2023-08-05 10:07                   ` Eli Zaretskii
2023-08-05 10:24                     ` Alan Third
2023-08-05 10:41                       ` Eli Zaretskii
2023-08-05 12:32                   ` David Ponce
2023-08-05 15:14                     ` Alan Third
2023-08-05 15:53                       ` David Ponce
2023-08-05 16:02                         ` Alan Third
2023-08-05 16:24                           ` David Ponce
2023-08-05 16:31                             ` Alan Third
2023-08-05 17:37                               ` David Ponce
2023-08-05 17:39                                 ` Alan Third
2023-08-05 18:00                                   ` David Ponce
2023-08-05 18:31                                     ` Alan Third
2023-08-05 20:04                                       ` David Ponce
2023-08-08 13:58                                         ` David Ponce
2023-08-08 21:18                                           ` Alan Third
2023-08-08 22:22                                             ` David Ponce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cb83ce08-49fa-5e75-8db4-5e597ddb7ac4@orange.fr \
    --to=da_vid@orange.fr \
    --cc=64908@debbugs.gnu.org \
    --cc=alan@idiocy.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.