Closed
Bug 1240665
Opened 9 years ago
Closed 8 years ago
Make image loading error log messages more accurate
Categories
(Core :: Graphics: ImageLib, defect)
Core
Graphics: ImageLib
Tracking
()
RESOLVED
FIXED
mozilla51
Tracking | Status | |
---|---|---|
firefox51 | --- | fixed |
People
(Reporter: daniel.f.starke, Assigned: glennrp+bmo)
References
Details
Attachments
(2 files, 10 obsolete files)
921.57 KB,
image/png
|
Details | |
4.28 KB,
patch
|
tnikkel
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36
Steps to reproduce:
I did open a large PNG file like the one attached with Firefox ESR 38.5.2.
Actual results:
Firefox only shows a black page with "The image ... cannot be displayed because it contains errors."
Expected results:
Chrome, Internet Explorer, Photoshop or IrfanView for example show no issue in opening this file.
As the file itself is totally fine, Firefox should at least display a different error than "file is broken". This is really confusing.
The best solution would be to make Firefox support such PNG files.
Reporter | ||
Updated•9 years ago
|
Component: Untriaged → File Handling
Status: UNCONFIRMED → NEW
Component: File Handling → ImageLib
Ever confirmed: true
Product: Firefox → Core
Assignee | ||
Updated•9 years ago
|
QA Contact: glennrp+bmo
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → glennrp+bmo
QA Contact: glennrp+bmo
Assignee | ||
Updated•9 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 1•9 years ago
|
||
To get more useful information, run firefox from a console window, with
NSPR_LOG_MODULES=PNGDecoder:3 in the environment. Then besides the
"image cannot be displayed" screen you also get the following in the
console window:
[0x7f02ee2603e0]: W/PNGDecoder libpng warning: Image width exceeds user limit in IHDR
[0x7f02ee2603e0]: E/PNGDecoder libpng error: Invalid IHDR data
Assignee | ||
Comment 2•9 years ago
|
||
See bug #408568 which is the same issue, but with JPEG.
Assignee | ||
Comment 3•9 years ago
|
||
To get more useful information, run firefox from a console window, with
NSPR_LOG_MODULES=PNGDecoder:3 in the environment. Then besides the
"image cannot be displayed" screen you also get the following in the
console window:
[0x7f02ee2603e0]: W/PNGDecoder libpng warning: Image width exceeds user limit in IHDR
[0x7f02ee2603e0]: E/PNGDecoder libpng error: Invalid IHDR data
Summary: Error on loading large PNG files → Error "image ... cannot be displayed because it contains errors" on loading large PNG files
Reporter | ||
Comment 4•9 years ago
|
||
I did not see such a message within the console windows of my Firefox.
And the JPEG bug is quite old and still unsolved.
But anyway, will there be a bugfix for this or is there a workaround available?
Maybe some magic setting in about:config?
In recent months I have been finding a lot of jpg and png images on Imgur which 'contain errors'
on ff42 vista, but render fine on everything else.
Here is a 2160 x 3840 px image of a pepsi bottle which firefox wont render
http://i.imgur.com/jmxTwAp.jpg
I flick through imgur gallery randomly 4 images until i get another which firefox wont render.
http://i.imgur.com/Efon9ni.jpg 2546 x 1738px - a slightly crude meme
I flick randomly again, this see 17 successful images before another broken jpg
http://i.imgur.com/San5GYN.jpg 2895 x 2895 - a celeb mugshot
Once more, just 5 images before the next broken
http://i.imgur.com/p5K3PWc.jpg 2650 x 1600px - nature satelite photo or such
I think ive noticed this since around ff39, it looks like a serious issue at large
with the new image decoding.
However after a restart, they all load in fine. This issue's example.png does not however.
Sorry if this isnt the right place to have noted my intermittent problem.
Assignee | ||
Comment 7•9 years ago
|
||
Some errors in image/decoders/nsPNGDecoder.cpp call png_longjmp() instead of png_error(), which bypasses the MOZ_LOG() call. This patch changes these png_longjmp() calls to png_error() calls.
Assignee | ||
Comment 8•9 years ago
|
||
Note that the two "SuccessfulEarlyFinish" calls to png_longjmp() are left intact by the v00 patch, because it's appropriate for these to not emit an error message.
Assignee | ||
Comment 9•9 years ago
|
||
Rebase, fix typo in one error message
Attachment #8724858 -
Attachment is obsolete: true
Comment 10•9 years ago
|
||
The following link is a bug affecting imlib2. I don't know if Firefox uses or shares any of the same code but Firefox has similar symptoms (without the segfault).
https://github.com/muennich/sxiv/issues/236#issuecomment-220143248
It seems that if either width or height is bigger than 32768 pixels rendering of the image fails.
Assignee | ||
Comment 11•8 years ago
|
||
Fix bit rot due to landing of bug #1255107
Attachment #8730023 -
Attachment is obsolete: true
Comment 12•8 years ago
|
||
Why is more logging needed?
># define MOZ_PNG_MAX_DIMENSION 32767
> if (width > MOZ_PNG_MAX_DIMENSION || height > MOZ_PNG_MAX_DIMENSION) {
>- png_longjmp(decoder->mPNG, 1);
>+ png_error(decoder->mPNG," Image dimensions exceed Mozilla's limits");
> }
Obviously this is the cause of the bug. The comment #0 image has 93765 px wide.
Updated•8 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Assignee | ||
Comment 14•8 years ago
|
||
In my opinion, "Image dimensions exceed Mozilla's limits" is more obvious (and accurate) than "The image ... cannot be displayed because it contains errors."
Comment 15•8 years ago
|
||
Oh, is this message user-visible? I see.
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Summary: Error "image ... cannot be displayed because it contains errors" on loading large PNG files → Make image loading error messages more user-friendly
Assignee | ||
Comment 16•8 years ago
|
||
It only makes the message user-visible when the user runs Firefox from a terminal/console window. It would be nice to put the libpng message in the image window, where the "The image ... cannot be displayed because it contains errors" is currently displayed, but the patch doesn't do that.
Updated•8 years ago
|
Summary: Make image loading error messages more user-friendly → Make image loading error log messages more accurate
Assignee | ||
Comment 17•8 years ago
|
||
Rebased after landing bug #1282566. Please "try".
Attachment #8765713 -
Attachment is obsolete: true
Flags: needinfo?(ryanvm)
Comment 18•8 years ago
|
||
Flags: needinfo?(ryanvm)
Assignee | ||
Comment 19•8 years ago
|
||
Comment on attachment 8766838 [details] [diff] [review]
v03-1240665-log-all-png-errors
"try" result is very green. R?
Attachment #8766838 -
Flags: review?(seth)
Comment 20•8 years ago
|
||
Comment on attachment 8766838 [details] [diff] [review]
v03-1240665-log-all-png-errors
Review of attachment 8766838 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks Glenn! r+, but please fix the formatting issues below.
::: image/decoders/nsPNGDecoder.cpp
@@ +550,5 @@
> &interlace_type, &compression_type, &filter_type);
>
> // Are we too big?
> if (width > MOZ_PNG_MAX_DIMENSION || height > MOZ_PNG_MAX_DIMENSION) {
> + png_error(decoder->mPNG," Image dimensions exceed Mozilla's limits");
Nit: |mPNG," Image| should be |mPNG, "Image| - in other words, the position of the quote and the space are reversed.
@@ +559,5 @@
> // Post our size to the superclass
> decoder->PostSize(frameRect.width, frameRect.height);
> if (decoder->HasError()) {
> // Setting the size led to an error.
> + png_error(decoder->mPNG," Sizing error");
Same as above.
@@ +672,5 @@
>
> if (decoder->mDownscaler && !decoder->IsFirstFrameDecode()) {
> MOZ_ASSERT_UNREACHABLE("Doing downscale-during-decode "
> "for an animated image?");
> + png_error(decoder->mPNG,"Invalid downscale attempt"); // Abort the decode.
Nit: there's a missing space between the comma and the quote.
@@ +709,2 @@
> if (NS_FAILED(rv)) {
> + png_error(decoder->mPNG,"CreateFrame failed");
Same as above.
@@ +718,5 @@
> uint32_t bpp[] = { 0, 3, 4, 3, 4 };
> decoder->mCMSLine =
> static_cast<uint8_t*>(malloc(bpp[channels] * frameRect.width));
> if (!decoder->mCMSLine) {
> + png_error(decoder->mPNG,"malloc of mCMSLine failed");
Same as above.
Attachment #8766838 -
Flags: review?(seth) → review+
Comment 21•8 years ago
|
||
(In reply to Masatoshi Kimura [:emk] from comment #12)
> Why is more logging needed?
>
> ># define MOZ_PNG_MAX_DIMENSION 32767
> > if (width > MOZ_PNG_MAX_DIMENSION || height > MOZ_PNG_MAX_DIMENSION) {
> >- png_longjmp(decoder->mPNG, 1);
> >+ png_error(decoder->mPNG," Image dimensions exceed Mozilla's limits");
> > }
>
> Obviously this is the cause of the bug. The comment #0 image has 93765 px
> wide.
Yep, that's true. A 32767 x 32767 image is 4GB, and allocating that much memory is either dangerous or impossible on many platforms that we have to support. (We could probably relax those limits on some platforms, but it requires some careful thought; this isn't the bug to do it in.) However, we don't need to forbid images that are over 32767 in one dimension but whose total size may be much lower. The image in comment 0 is 93765px wide, but only 640px high, which works to 240MB; that's no problem. This is probably a pretty quick fix, though I need to take a look at the code and make sure we're not in danger of overflow anywhere if we naively make this change.
Updated•8 years ago
|
Keywords: leave-open
Comment 22•8 years ago
|
||
Since this bug is about improving the logging messages, let's just deal with that here. We'll make the image in comment 0 successfully decode in bug 1283961.
Updated•8 years ago
|
Keywords: leave-open
Assignee | ||
Comment 23•8 years ago
|
||
Nits fixed.
Attachment #8766838 -
Attachment is obsolete: true
Attachment #8767378 -
Flags: review?(seth)
Assignee | ||
Comment 24•8 years ago
|
||
Rebased. Please transfer the r+ from the v03 patch to v05.
Attachment #8767378 -
Attachment is obsolete: true
Attachment #8767378 -
Flags: review?(seth)
Attachment #8770235 -
Flags: review?(seth)
Assignee | ||
Comment 25•8 years ago
|
||
Rebased.
Attachment #8770235 -
Attachment is obsolete: true
Attachment #8770235 -
Flags: review?(seth)
Attachment #8772164 -
Flags: review?(seth)
Assignee | ||
Comment 26•8 years ago
|
||
Rebased
Attachment #8772164 -
Attachment is obsolete: true
Attachment #8772164 -
Flags: review?(seth)
Attachment #8772919 -
Flags: review?(seth)
Assignee | ||
Comment 27•8 years ago
|
||
Rebased again, and destroy png structs before returning from error handler. Please run this through "try".
Attachment #8772919 -
Attachment is obsolete: true
Attachment #8772919 -
Flags: review?(seth.bugzilla)
Flags: needinfo?(ryanvm)
Attachment #8773903 -
Flags: review?(seth.bugzilla)
Comment 28•8 years ago
|
||
Flags: needinfo?(ryanvm)
Assignee | ||
Comment 29•8 years ago
|
||
Removed incorrect line added to isValidICO().
Attachment #8773903 -
Attachment is obsolete: true
Attachment #8773903 -
Flags: review?(seth.bugzilla)
Comment 31•8 years ago
|
||
Flags: needinfo?(ryanvm)
Assignee | ||
Comment 32•8 years ago
|
||
Comment on attachment 8774807 [details] [diff] [review]
v09-1240665-log-all-png-errors
Try B are green. R?
Attachment #8774807 -
Flags: review?(tnikkel)
Assignee | ||
Updated•8 years ago
|
OS: Unspecified → All
Hardware: Unspecified → All
Version: 38 Branch → Trunk
Assignee | ||
Comment 33•8 years ago
|
||
Rebased after landing Bug #1283961
Attachment #8774807 -
Attachment is obsolete: true
Attachment #8774807 -
Flags: review?(tnikkel)
Attachment #8775938 -
Flags: review?(tnikkel)
Updated•8 years ago
|
Attachment #8775938 -
Flags: review?(tnikkel) → review+
Assignee | ||
Updated•8 years ago
|
Keywords: checkin-needed
Comment 34•8 years ago
|
||
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/4581a6d4a620
Log all error returns from the PNG decoder. r=tnikkel
Keywords: checkin-needed
Comment 35•8 years ago
|
||
bugherder |
Status: REOPENED → RESOLVED
Closed: 8 years ago → 8 years ago
status-firefox51:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
You need to log in
before you can comment on or make changes to this bug.
Description
•