gdk-pixbuf: pixbuf loader not emitting area-updated/area-prep for partial jpegs on Win32

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

gdk-pixbuf: pixbuf loader not emitting area-updated/area-prep for partial jpegs on Win32

Jethram Cockson
Hi group,

I'm having issues with gdk-pixbuf loader and JPEGs on my Windows 10
system with MSYS. The
loader works okay to construct pixbufs. But for some reason, it
refuses to emit area-updated and
area-prepared until the jpeg is 100% loaded already. That kind of
defeats the purpose of that
feature. On Linux, it successfully emits these signals with the same jpeg files.

I'm wondering, is there any trick to getting this to work on Windows
that I'm missing, or is this just
expected behavior? Or maybe a bug?


On MSYS(using the pacman packages for these):
$ pkg-config --modversion gdk-pixbuf-2.0
2.36.10
$ pkg-config --modversion gtk+-3.0
3.22.19

On Linux:
$ uname -a
$ pkg-config --modversion gdk-pixbuf-2.0
2.36.9
$ pkg-config --modversion gtk+-3.0
3.22.21

I've made a small test script in Python that demos this problem:
https://gist.github.com/anonymous/95424447867e1d6a99e32f3622a06565

import gi
gi.require_version('GdkPixbuf', '2.0')
from gi.repository import GdkPixbuf
from urllib import request
import sys

pbl = GdkPixbuf.PixbufLoader()
url = sys.argv[1]

def prepped(*args):
    pb: GdkPixbuf.Pixbuf = pbl.get_pixbuf()
    print('prepped', pb, pb.get_width(), 'x', pb.get_height())

def updated(*args):
    print('updated', *args)

pbl.connect('area-prepared', prepped)
pbl.connect('area-updated', updated)

with request.urlopen(url) as fp:
    while True:
        buf = fp.read(1024)
        if not buf:
            break
        pbl.write(buf)
    pbl.close()

pb: GdkPixbuf.Pixbuf = pbl.get_pixbuf()
print('pixbuf', pb, pb.get_width(), 'x', pb.get_height())


Notice on MSYS it only emits area-updated when its fully loaded.
MSYS:
$python3 pbl.py https://upload.wikimedia.org/wikipedia/en/5/58/Penny_test.jpg
prepped <GdkPixbuf.Pixbuf object at 0x000000000372e438 (GdkPixbuf at
0x0000000002d41600)> 198 x 238
updated <GdkPixbuf.PixbufLoader object at 0x0000000003147ea0
(GdkPixbufLoader at 0x0000000002d431e0)> 0 0 198 238
pixbuf <GdkPixbuf.Pixbuf object at 0x000000000372e438 (GdkPixbuf at
0x0000000002d41600)> 198 x 238


On Linux:
$ python3 pbl.py https://upload.wikimedia.org/wikipedia/en/5/58/Penny_test.jpg
prepped <GdkPixbuf.Pixbuf object at 0x7f89db837bd0 (GdkPixbuf at
0x56545f04f460)> 198 x 238
updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
(GdkPixbufLoader at 0x56545f05fcc0)> 0 0 198 1
updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
(GdkPixbufLoader at 0x56545f05fcc0)> 0 1 198 1
updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
(GdkPixbufLoader at 0x56545f05fcc0)> 0 2 198 1
updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
(GdkPixbufLoader at 0x56545f05fcc0)> 0 3 198 1
updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
(GdkPixbufLoader at 0x56545f05fcc0)> 0 4 198 1
updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
(GdkPixbufLoader at 0x56545f05fcc0)> 0 5 198 1

<a few hundred scanlines snipped for brevity>

updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
(GdkPixbufLoader at 0x56545f05fcc0)> 0 232 198 1
updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
(GdkPixbufLoader at 0x56545f05fcc0)> 0 233 198 1
updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
(GdkPixbufLoader at 0x56545f05fcc0)> 0 234 198 1
updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
(GdkPixbufLoader at 0x56545f05fcc0)> 0 235 198 1
updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
(GdkPixbufLoader at 0x56545f05fcc0)> 0 236 198 1
updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
(GdkPixbufLoader at 0x56545f05fcc0)> 0 237 198 1
pixbuf <GdkPixbuf.Pixbuf object at 0x7f89dd080480 (GdkPixbuf at
0x56545f04f460)> 198 x 238
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|

Re: gdk-pixbuf: pixbuf loader not emitting area-updated/area-prep for partial jpegs on Win32

Jethram Cockson
On Mon, Sep 25, 2017 at 1:59 AM, Jethram Cockson
<[hidden email]> wrote:

> Hi group,
>
> I'm having issues with gdk-pixbuf loader and JPEGs on my Windows 10
> system with MSYS. The
> loader works okay to construct pixbufs. But for some reason, it
> refuses to emit area-updated and
> area-prepared until the jpeg is 100% loaded already. That kind of
> defeats the purpose of that
> feature. On Linux, it successfully emits these signals with the same jpeg files.
>
> I'm wondering, is there any trick to getting this to work on Windows
> that I'm missing, or is this just
> expected behavior? Or maybe a bug?
>
>
> On MSYS(using the pacman packages for these):
> $ pkg-config --modversion gdk-pixbuf-2.0
> 2.36.10
> $ pkg-config --modversion gtk+-3.0
> 3.22.19
>
> On Linux:
> $ uname -a
> $ pkg-config --modversion gdk-pixbuf-2.0
> 2.36.9
> $ pkg-config --modversion gtk+-3.0
> 3.22.21
>
> I've made a small test script in Python that demos this problem:
> https://gist.github.com/anonymous/95424447867e1d6a99e32f3622a06565
>
> import gi
> gi.require_version('GdkPixbuf', '2.0')
> from gi.repository import GdkPixbuf
> from urllib import request
> import sys
>
> pbl = GdkPixbuf.PixbufLoader()
> url = sys.argv[1]
>
> def prepped(*args):
>     pb: GdkPixbuf.Pixbuf = pbl.get_pixbuf()
>     print('prepped', pb, pb.get_width(), 'x', pb.get_height())
>
> def updated(*args):
>     print('updated', *args)
>
> pbl.connect('area-prepared', prepped)
> pbl.connect('area-updated', updated)
>
> with request.urlopen(url) as fp:
>     while True:
>         buf = fp.read(1024)
>         if not buf:
>             break
>         pbl.write(buf)
>     pbl.close()
>
> pb: GdkPixbuf.Pixbuf = pbl.get_pixbuf()
> print('pixbuf', pb, pb.get_width(), 'x', pb.get_height())
>
>
> Notice on MSYS it only emits area-updated when its fully loaded.
> MSYS:
> $python3 pbl.py https://upload.wikimedia.org/wikipedia/en/5/58/Penny_test.jpg
> prepped <GdkPixbuf.Pixbuf object at 0x000000000372e438 (GdkPixbuf at
> 0x0000000002d41600)> 198 x 238
> updated <GdkPixbuf.PixbufLoader object at 0x0000000003147ea0
> (GdkPixbufLoader at 0x0000000002d431e0)> 0 0 198 238
> pixbuf <GdkPixbuf.Pixbuf object at 0x000000000372e438 (GdkPixbuf at
> 0x0000000002d41600)> 198 x 238
>
>
> On Linux:
> $ python3 pbl.py https://upload.wikimedia.org/wikipedia/en/5/58/Penny_test.jpg
> prepped <GdkPixbuf.Pixbuf object at 0x7f89db837bd0 (GdkPixbuf at
> 0x56545f04f460)> 198 x 238
> updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
> (GdkPixbufLoader at 0x56545f05fcc0)> 0 0 198 1
> updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
> (GdkPixbufLoader at 0x56545f05fcc0)> 0 1 198 1
> updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
> (GdkPixbufLoader at 0x56545f05fcc0)> 0 2 198 1
> updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
> (GdkPixbufLoader at 0x56545f05fcc0)> 0 3 198 1
> updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
> (GdkPixbufLoader at 0x56545f05fcc0)> 0 4 198 1
> updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
> (GdkPixbufLoader at 0x56545f05fcc0)> 0 5 198 1
>
> <a few hundred scanlines snipped for brevity>
>
> updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
> (GdkPixbufLoader at 0x56545f05fcc0)> 0 232 198 1
> updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
> (GdkPixbufLoader at 0x56545f05fcc0)> 0 233 198 1
> updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
> (GdkPixbufLoader at 0x56545f05fcc0)> 0 234 198 1
> updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
> (GdkPixbufLoader at 0x56545f05fcc0)> 0 235 198 1
> updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
> (GdkPixbufLoader at 0x56545f05fcc0)> 0 236 198 1
> updated <GdkPixbuf.PixbufLoader object at 0x7f89debd1480
> (GdkPixbufLoader at 0x56545f05fcc0)> 0 237 198 1
> pixbuf <GdkPixbuf.Pixbuf object at 0x7f89dd080480 (GdkPixbuf at
> 0x56545f04f460)> 198 x 238


Realized there was a stray type annotation in the script. Removed in
case it causes problems:

https://gist.github.com/anonymous/592658623d5317e7db40164e4d75b95c

import gi
gi.require_version('GdkPixbuf', '2.0')
from gi.repository import GdkPixbuf
from urllib import request
import sys

pbl = GdkPixbuf.PixbufLoader()
url = sys.argv[1]

def prepped(*args):
    pb: GdkPixbuf.Pixbuf = pbl.get_pixbuf()
    print('prepped', pb, pb.get_width(), 'x', pb.get_height())

def updated(*args):
    print('updated', *args)

pbl.connect('area-prepared', prepped)
pbl.connect('area-updated', updated)

with request.urlopen(url) as fp:
    while True:
        buf = fp.read(1024)
        if not buf:
            break
        pbl.write(buf)
    pbl.close()

pb = pbl.get_pixbuf()
print('pixbuf', pb, pb.get_width(), 'x', pb.get_height())
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list