After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 694148 - gdk_pixbuf_animation_new_from_file() can't load png files
gdk_pixbuf_animation_new_from_file() can't load png files
Status: RESOLVED FIXED
Product: gdk-pixbuf
Classification: Platform
Component: general
git master
Other All
: Normal major
: ---
Assigned To: gdk-pixbuf-maint
gdk-pixbuf-maint
: 694708 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-02-19 08:02 UTC by LRN
Modified: 2013-02-25 22:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Do not rely on prepared_notify() to be called immediately (502 bytes, patch)
2013-02-19 09:59 UTC, LRN
none Details | Review

Description LRN 2013-02-19 08:02:46 UTC
1) gtk_image_new_from_file (gtk_image_new_from_file_utf8 in my case) calls gtk_image_set_from_file
2) gtk_image_set_from_file calls gdk_pixbuf_animation_new_from_file on the filename. Note that this code is decade-old.
3) gdk_pixbuf_animation_new_from_file () finds a module to use (png module ranks at 100 and is used - as expected).
4) png module does not provide load_animation (as expected), but provides begin_load, so gdk-pixbuf uses that.
5) gdk-pixbuf calls:
context = image_module->begin_load (NULL, prepared_notify, NULL, &animation, error);
However, prepared_notify is never called by the png module (it probably will be called later, once the loading process beings).
Because prepared_notify is never called, the "animation" variable it is supposed to fill remains NULL.
6) if (!context || !animation) { goto fail_progressive_load; } (note that context is non-NULL, only animation is NULL)
7) Thus gdk_pixbuf_animation_new_from_file() fails
8) gtk_image_set_from_file() uses the "missing" image instead.

Possible cause:
gdk-pixbuf came to depend on prepared_notify() being called by a loader module after just preparing the reading process (presumably - reading the header).
This is not really a requirement. prepared_notify() code will just call gdk_pixbuf_non_anim_new() for non-animated images (or ref existing GdkPixbufAnimation object for animated images), and store its pointer in user_data (the &animation).
After that the &animation is not used until it's time to return the loaded image. The code doesn't really need to check that animation is non-NULL that early.

Instead it should only check that context is non-NULL, and then proceed to load the image. Only check for animation being non-NULL once the loading process is complete (or failed).
Comment 1 LRN 2013-02-19 09:59:55 UTC
Created attachment 236732 [details] [review]
Do not rely on prepared_notify() to be called immediately

This is a patch against 2.27.1
Should also apply to master (it's just one line...).

Works for me.
Comment 2 Benjamin Otte (Company) 2013-02-25 22:14:54 UTC
*** Bug 694708 has been marked as a duplicate of this bug. ***