Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 757492 - qt48/qtwebkit-2.2 : PNG support is broken
Summary: qt48/qtwebkit-2.2 : PNG support is broken
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Fedora
Classification: Fedora
Component: qtwebkit
Version: 16
Hardware: All
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Rex Dieter
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-11-27 13:20 UTC by Raphael Groner
Modified: 2011-12-20 09:19 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-12-20 09:19:19 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
test application (3.32 KB, application/x-xz)
2011-11-27 13:25 UTC, Raphael Groner
no flags Details
actual result (8.21 KB, image/png)
2011-11-27 13:29 UTC, Raphael Groner
no flags Details
expected result (6.93 KB, image/png)
2011-11-27 13:36 UTC, Raphael Groner
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 757559 0 unspecified CLOSED [abrt] tumbler-0.1.22-4.fc16: __libc_message: Process /usr/lib64/tumbler-1/tumblerd was killed by signal 6 (SIGABRT) 2022-05-16 11:32:56 UTC

Internal Links: 757559

Description Raphael Groner 2011-11-27 13:20:35 UTC
Description of problem:
QtWebkit seems not to handle png content as it was in Qt4.7.

Version-Release number of selected component (if applicable):
qt-4.8.0-0.23.rc1.fc16
qtwebkit-2.2.0-1.fc16
libpng-1.2.46-1.fc16
(tested for both i686 and x86_64)

How reproducible:
always

Steps to Reproduce:
1. build and run the attached test application: qmake-qt4 && make && ./test
2.
3.
  
Actual results:
not all pictures visible in the pop up window

Expected results:
four smileys

Additional info:
Tested on ArchLinux - works.
Qt              : 4.7.4-3
libpng          : 1.4.8-1

Comment 1 Raphael Groner 2011-11-27 13:25:02 UTC
Created attachment 537096 [details]
test application

Comment 2 Raphael Groner 2011-11-27 13:29:44 UTC
Created attachment 537098 [details]
actual result

This is the output of my program running in Fedora 16:

createRequest: "file:///home/raphael/build/test/qtwebkit/page.html" 
createRequest: "file:///home/raphael/build/test/qtwebkit/smile.png" 
createRequest: "icon:smile.png" 
readIcon: -1 "" 5 
readIcon: "smile.png" 476 
DebugReply: 476 image/png 
createRequest: "convert:smile.png" 
readIcon: -1 "" 5 
readIcon: "smile.png" 476 
DebugReply: 476 image/xpm 
createRequest: "direct:smile.png" 
readIcon: "smile.png" 770 
DebugReply: 770 
bytesAvailable: 476 
readData: 14 
bytesAvailable: 462 
bytesAvailable: 462 
readData: 448 
bytesAvailable: 476 
bytesAvailable: 476 
readData: 476 
bytesAvailable: 770 
readData: 512 
bytesAvailable: 258 
bytesAvailable: 258 
libpng error: Read Error
libpng error: IDAT: CRC error

Comment 3 Raphael Groner 2011-11-27 13:36:04 UTC
Created attachment 537099 [details]
expected result

This is the output of my program running on ArchLinux with Qt4.7 and libpng1.2:

createRequest: "file:///home/raphael/builds/test/qtwebkit/page.html" 
createRequest: "file:///home/raphael/builds/test/qtwebkit/smile.png" 
createRequest: "icon:smile.png" 
readIcon: -1 "" 5 
readIcon: "smile.png" 476 
DebugReply: 476 image/png 
createRequest: "convert:smile.png" 
readIcon: -1 "" 5 
readIcon: "smile.png" 476 
DebugReply: 476 image/xpm 
createRequest: "direct:smile.png" 
readIcon: "smile.png" 770 
DebugReply: 770 
bytesAvailable: 476 
readData: 476 
bytesAvailable: 476 
readData: 476 
bytesAvailable: 770 
readData: 770

Comment 4 Raphael Groner 2011-11-27 13:37:29 UTC
Comment on attachment 537099 [details]
expected result

Sorry, my fault. libpng 1.4 is in Arch.

Comment 5 Rex Dieter 2011-11-27 15:28:48 UTC
Cant' build test app:
$ qmake-qt4 
WARNING: Failure to find: test.moc

Comment 6 Raphael Groner 2011-11-27 15:46:22 UTC
(In reply to comment #5)
> WARNING: Failure to find: test.moc
Try "qmake-qt4 -project", it will create test.moc and moc_bytearrayreply.[cpp|h]. Then replace the file test.pro afterwards again, it gets overwritten by qmake-qt4 that isn't able to detect automatically the need for webkit and network modules.

Comment 7 Rex Dieter 2011-11-27 16:03:30 UTC
OK,

I'd suggest contacting upstream mailing list for advice,
http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt

Could very well simply be a libpng bug/error as well (the error message does originate from libpng afterall).

Comment 8 Raphael Groner 2011-11-27 17:05:01 UTC
> Could very well simply be a libpng bug/error as well (the error message does
originate from libpng afterall).
No. That's very unlikely. Either it's due to a bug in Qt / QtWebkit or because of a failing in the combination of Qt 4.8 and libpng 1.2. As said already, libpng 1.4 doesn't show the issue, though only tested with Qt 4.7 and another distribution.

I'll contact upstream ASAP. Thanks.

Comment 9 Raphael Groner 2011-11-27 21:16:05 UTC
Trying to reassign to libpng. I have another issue with that library, see bug #757559 .

Comment 10 Raphael Groner 2011-11-27 21:21:07 UTC
Some users of Russian Fedora Remix (based on Fedora 16 official packages) did confirm this bug.

Comment 11 Tom Lane 2011-11-27 23:06:42 UTC
I see no reason to believe this is a libpng bug.  It's not unlikely that qt 4.8 hasn't been tested with libpng 1.2, since the latter is pretty darn ancient.  But we're not going to rebase libpng in F16 at this point, so the onus is on qt not libpng to cope.

Comment 12 Raphael Groner 2011-11-28 09:55:09 UTC
(In reply to comment #11)
> I see no reason to believe this is a libpng bug.
Tim, thanks for the fast response.
I can see that there are efforts to ship the actual upstream libpng 1.5.6 in Fedora 17. 
My question to you is if Qt 4.8 fc17 will or sould be built against libpng-compat or libpng. The name libpng-compat-1.5.6 is misleading and confusing: in reality, it is 1.2.

(In reply to comment #7)
> I'd suggest contacting upstream mailing list for advice,
I tried to subscribe to the mailing list. There is a strange problem with confirmation. So for now, first trying to contact the webkit maintainer.

Comment 13 Tom Lane 2011-11-28 15:31:24 UTC
(In reply to comment #12)
> My question to you is if Qt 4.8 fc17 will or sould be built against
> libpng-compat or libpng.

There is no way to "build against libpng-compat", because it contains no devel support files (no headers, no .so symlink).  I see that qt hasn't been rebuilt since 3-Nov, but next time it's successfully built in rawhide, it will be using libpng 1.5.

> The name libpng-compat-1.5.6 is misleading and confusing: in reality, it is 1.2.

If it were intended to survive for any length of time, I might worry about that.  It will only exist until dependent packages are all rebuilt.

Comment 14 Rex Dieter 2011-11-28 16:05:40 UTC
Triaged back to qtwebkit (WebKit component in bz is deprecated)

Comment 15 Raphael Groner 2011-11-28 18:29:32 UTC
My workaround is now:

(...)
		if (req.url().scheme() == "icon") {
			QByteArray bytes;
			
			// FIXME: Qt4.8 seems to do strange things to png content
			// and webkit is not able to understand.
			// see https://bugzilla.redhat.com/show_bug.cgi?id=757492
			#if QT_VERSION >= 0x040800
			#define FORMAT "xpm"
			#else
			#define FORMAT "png"
			#endif
			
			loadIcon(bytes, req.url().path(), FORMAT);
			return new DebugReply(bytes, "image/"FORMAT);
		}
(...)

Though, direct data transfer ("direct:") isn't working.

Comment 16 Rex Dieter 2011-11-28 18:53:41 UTC
fwiw, qt-everywhere-opensource-src-4.8.0/src/3rdparty/libpng is 1.5.4
for giggles, I'll redo this test using the bundled copy

Comment 17 Kevin Kofler 2011-11-28 19:51:35 UTC
So the more we look at this, the more it looks like not a PNG issue, but an issue with the ByteArrayReply class in your code which just happens to be triggered by Qt 4.8's PNG loading code.

The evidence leading me to that conclusion:
* Using the bundled libpng 1.5.4 didn't help. (Rex tried it.)
* Replacing the smile.png with a known good PNG didn't help, either.
* All the other QtWebKit-using apps display PNGs just fine.
The difference between what works and what doesn't work is that ByteArrayReply class.

I would suggest rewriting that class from scratch, reimplementing ALL the virtual methods of QIODevice and forwarding them all as is to the backing QBuffer. (Well, you can add the QIODevice::Unbuffered flag in open because buffering a buffer is not helpful, but otherwise I'd forward everything as is.)

Comment 18 Kevin Kofler 2011-11-28 19:53:18 UTC
Oh, and close() should probably call both QNetworkReply::close() and the QBuffer's close() method. Currently it does neither.

Comment 20 Raphael Groner 2011-11-29 11:07:04 UTC
(In reply to comment #17)
> * All the other QtWebKit-using apps display PNGs just fine.
no. I doubt that theory. What does "All" mean in this context? At least, not the apps that'll use QNetworkReply class.
I experienced that QtWebkit of Qt4.7 did not require a content type header "image/png" explicitly set for the reply data content. QtWebkit 2.2 seems to enforce this, otherwise afaik. the transferred data will be ignored, as it seems.
Further cause of that, the internal type sniffer of Qt seems to not behave like the one been in Qt 4.7.
Summary: The behaviour of QtWebkit 2.2 is definitely different to the "common" one as expected from Qt 4.7, in which all that hackery worked just fine. :)

Comment 21 Kevin Kofler 2011-11-29 11:19:27 UTC
> no. I doubt that theory. What does "All" mean in this context? At least, not
> the apps that'll use QNetworkReply class.

As far as I can see, only stuff using that ByteArrayReply subclass included in your code sample is affected, QNetworkReply itself looks fine.

> Further cause of that, the internal type sniffer of Qt seems to not behave like
> the one been in Qt 4.7.

It might be doing some operations on QNetworkReply which ByteArrayReply doesn't implement (properly).

(But then again, images are supposed to be declared with the correct MIME type, real web servers normally send them that way.)


If you think there's an issue in QNetworkReply or in the type detection themselves, we will need some evidence that it can be reproduced with a test case NOT involving that ByteArrayReply class.

FYI, Rekonq and the kwebkitpart for Konqueror use the QNetworkAccess API including QNetworkReply to use KIO to provide the data, yet by all reports I have, they're working just fine. Show me a testcase broken the same way in Rekonq or Konqueror+kwebkitpart and I'll believe that there's a QNetworkReply bug.

Comment 22 Raphael Groner 2011-11-29 14:58:14 UTC
(In reply to comment #21)
... see my comment #19, please.

Comment 23 Raphael Groner 2011-11-29 15:39:20 UTC
Well, could it be an issue with glibc? There are other issues of non-qt applications, e.g. tumbler, that seem to have problems with png reading, too.

Comment 24 Kevin Kofler 2011-11-29 15:57:00 UTC
> ... see my comment #19, please.

I don't see how that link is relevant to the issue at hand. It summarizes the QNetworkAccess API, but the question at hand is whether the ByteArrayReply class in your code is compliant to the API or not.

> Well, could it be an issue with glibc? There are other issues of non-qt
> applications, e.g. tumbler, that seem to have problems with png reading, too.

shared-mime-info maybe? But it might actually be a completely different issue, too.

Comment 26 Raphael Groner 2011-12-14 20:48:56 UTC
(In reply to comment #16)
> fwiw, qt-everywhere-opensource-src-4.8.0/src/3rdparty/libpng is 1.5.4
> for giggles, I'll redo this test using the bundled copy

Are you away of this? Or is it patched in Fedora?
gui/image/qpnghandler.cpp:#include <../../3rdparty/libpng/png.h>
gui/image/qpnghandler.cpp:#include <../../3rdparty/libpng/pngconf.h>


(In reply to comment #17)
> * Using the bundled libpng 1.5.4 didn't help. (Rex tried it.)

Well, then it's a bug with Qt 4.8, for sure. As said already, it works with Qt 4.7 cause the implementation of ByteArrayReply is exactly the same 1:1 from the official patches to psi-plus (package is included in Russian Fedora). See the copyright in the file. I guess there are also differences with the webkit source part between both Qt versions.

(In reply to comment #24)
> the question at hand is whether the ByteArrayReply class in your code is
> compliant to the API or not.

Anyways, it does not make much sense to discuss a broken feature that is documented (see link of comment #19) and has worked in a previous version. It is clearly an upstream issue!

Comment 27 Kevin Kofler 2011-12-15 01:56:29 UTC
> gui/image/qpnghandler.cpp:#include <../../3rdparty/libpng/png.h>
> gui/image/qpnghandler.cpp:#include <../../3rdparty/libpng/pngconf.h>

These are under #ifdef:
#ifdef QT_USE_BUNDLED_LIBPNG
#include <../../3rdparty/libpng/png.h>
#include <../../3rdparty/libpng/pngconf.h>
#else
#include <png.h>
#include <pngconf.h>
#endif
which looks right to me.

> cause the implementation of ByteArrayReply is exactly the same 1:1 from the
> official patches to psi-plus (package is included in Russian Fedora).

That doesn't mean it's correct. Please either look for errors in it or ask the original author to do so. It might just work by accident in 4.7 (e.g. 4.7 might just happen not to be using the APIs from the interface which aren't implemented correctly).

> Anyways, it does not make much sense to discuss a broken feature that is
> documented (see link of comment #19)

Again, the fact that the API is documented doesn't actually mean that the ByteArrayReply class complies with the documented interface! This API is special in that it requires some interfaces YOU have to implement. If you don't implement them, or if you implement them incorrectly, things will not work.

I have seen that link. It is just a general overview page about the API, you have to look into the documentation of the actual classes to check whether ByteArrayReply's implementation of the required interfaces is compliant.

The fact that ALL the other QtWebKit users work, including the kwebkitpart users which definitely make use of the QNetworkAccess API (it's used to wrap KIO for QtWebKit to use), clearly points me into ByteArrayReply's direction as to the faulty component, and you still don't provide any convincing argument why it's not, you apparently haven't even LOOKED into it, nor talked to the upstream author about it.

> It is clearly an upstream issue!

Which upstream? Qt upstream or ByteArrayReply upstream? My guess is the latter.

Comment 28 Raphael Groner 2011-12-19 13:29:10 UTC
Are you sure to have used the right gcc and linker options?

There's still an open bug, although Qt4.8 is stable now.
https://bugreports.qt.nokia.com//browse/QTBUG-8338

Comment 29 Raphael Groner 2011-12-19 23:33:19 UTC
Just for documentation: We should better use the standardized data:// scheme for images.

http://www.websiteoptimization.com/speed/tweak/inline-images/


Note You need to log in before you can comment on or make changes to this bug.