Accept padding at the end of image data?
(edit: This comment isn't 100% accurate, see the comment below!)
The notification spec has a rowstride
argument for image-data
, which is separate from the existing information in width
/ bits_per_sample
/ channels
.
However, in _notify_daemon_pixbuf_from_data_hint
, notification-daemon does:
expected_len = (height - 1) * rowstride + width
* ((n_channels * bits_per_sample + 7) / 8);
if (expected_len != g_variant_get_size (data_variant)) {
g_warning ("Expected image data to be of length %" G_GSIZE_FORMAT
" but got a " "length of %" G_GSIZE_FORMAT,
expected_len,
g_variant_get_size (data_variant));
return NULL;
}
i.e. it requires the rowstride to be minimal instead of ignoring the padding (which I think gdk_pixbuf_new_from_data
does just fine!). I think it'd make sense for this check to use expeced_len < ...
instead?
Having such padding can be useful to optimize image operations on the stored image data, and would allow applications to send the existing image data with padding, without having to reorganize (and/or copy) it. In my case, I'm implementing notification support in qutebrowser, which gets the image data from the underlying QtWebEngine / Chromium, but Chromium seems to pad the data so that every scan line is on a 4-byte-boundary.
The spec also says:
This image format is derived from gdk-pixbuf.
and their documentation also hints at this being somewhat usual:
The
gdk_pixbuf_new()
function will compute an optimal rowstride so that rendering can be performed with an efficient algorithm.
So this could potentially affect other applications using GDK pixbufs as well.
Note that GNOME Shell seems to do the right thing from a quick look - it's only this repository (and many other notification daemons likely derived from it) suffering from this issue.
(As an aside: I'm opening issues similar to this in many different notification daemons, since I've found various of them suffering from this issue. I've taken care to avoid copy-paste mistakes and include specific details, but if I've missed something, I apologize. FWIW, so far I know that GNOME Shell, KDE Plasma, awesomewm and Cinnamon handle this correctly, but most others do not)