Closed Bug 1056122 Opened 10 years ago Closed 10 years ago

"Image corrupt or truncated" error when editing high resolution images from gallery

Categories

(Core :: Graphics: ImageLib, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: yjc92385, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36

Steps to reproduce:

scenario 1:
1:Open gallery
2:Open an image which is having more than 5MB size
3:Press on edit symbol 

scenario 2:
1: Copy 50 high resolution images[more than 4MB size] to gallery
2:Open gallery
3:Open an image and flip to the next image continuously and quickly for some time
4:after some time you can observe black screen with out showing any image 
  


Actual results:

Black screen is showing, not able to load image.
Below error is showing in logs
"Image corrupt or truncated: blob:54f2fb5d-0100-4d9e-b72b-49263f142dcf#-moz-samplesize=4" {file: "blob:54f2fb5d-0100-4d9e-b72b-49263f142dcf#-moz-samplesize=4" line: 0}]



Expected results:

It should open image with out any failure
Flags: needinfo?(image.gfx)
Flags: needinfo?(image-blocking)
Flags: needinfo?(imagelib)
Flags: needinfo?(dflanagan)
Mike: thanks for letting me know about this

Jayachandra: please tell us what version of FirefoxOS you were using and what device it was on. Also, please attach a sample image for which the error reproduces. In scenario #1, does this happen all the time?  In scenario #2: does this bug occur if you swipe slowly between the images, or only if you do it quickly?

I have seen this "image corrupt or truncated" error message before for blob: urls. I've never seen it associated with any visual issue, however, and have assumed that it was something benign.

I don't know where it comes from, but I can say for certain that it does not come from the Gallery app itself.  I'm guessing that the message is from imagelib, but suppose that the "truncated" part could have something to do with blobs.

So reassigning this bug to imagelib, and setting needinfo for Ben, in case there is anything blob-related here. 

If someone can tell me more about what causes this error message, I might have some ideas about what Gallery could be doing to trigger it...
Component: General → ImageLib
Flags: needinfo?(yjc92385)
Flags: needinfo?(dflanagan)
Flags: needinfo?(bent.mozilla)
Product: Firefox OS → Core
Issue is reproducible in 2.0 version as well as 2.1 version also

The issues are due to memory allocation limit in decoder.
In the file 
Decoder.cpp 
Decoder::AllocateFrame() not able to allocate memory for frame in error case, so mCurrentFrame value is becoming null.

while scrolling images one by one very fast, Images will be decoded very fast and discards some previously cached decoded images. 

In the file 
DiscardTracker.cpp there is a method to discord previous images MaybeDiscardSoon(), this is running in different thread which releases the memory.
In problematic scenario we are moving to next image quickly before it releases the required amount of memory, which leads to the error "Image corrupt or truncated" error

In file DiscardTracker.cpp
DiscardTracker::TryAllocation method 

bool enoughSpace =
!sHardLimitDecodedImageKB ||
(sHardLimitDecodedImageKB * 1024) - sCurrentDecodedImageBytes >= aBytes;

this calculation will returns zero value since requested bytes are not in decoder max buff limit

The value of sHardLimitDecodedImageKB is 66560 [which is 65MB] 
when [requested memory + already decoded memory] crosses 65MB it can not allocate any memory for the new image

the value sHardLimitDecodedImageKB is taking from below preference 
pref("image.mem.hard_limit_decoded_image_kb", 66560);

This can be increased to solve the issue 

We tried the below change and we found that both the issues are not reproducible with 2~4MB images

change:
In \gecko\b2g\app\b2g.js file
pref("image.mem.hard_limit_decoded_image_kb", 76800);//changed to 75MB from 65MB
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Flags: needinfo?(yjc92385)
Resolution: --- → WORKSFORME
Clearing needinfo requests on this resolved bug.
Flags: needinfo?(imagelib)
Flags: needinfo?(image.gfx)
Flags: needinfo?(image-blocking)
Flags: needinfo?(bent.mozilla)
You need to log in before you can comment on or make changes to this bug.