Closed Bug 1006281 Opened 10 years ago Closed 10 years ago

[tarako]Camera app can't use internal storage when internal storage size is less than 5MB.

Categories

(Firefox OS Graveyard :: Gaia::Camera, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(blocking-b2g:1.3T+, b2g-v1.3T fixed, b2g-v1.4 fixed)

RESOLVED FIXED
2.0 S1 (9may)
blocking-b2g 1.3T+
Tracking Status
b2g-v1.3T --- fixed
b2g-v1.4 --- fixed

People

(Reporter: thomas, Assigned: justindarc)

Details

(Whiteboard: [tarako_only])

Attachments

(3 files)

https://github.com/mozilla-b2g/gaia/blob/v1.3t/apps/camera/js/camera.js#L1379-L1383
    // Now verify that there is enough space to store a picture
    // 4 bytes per pixel plus some room for a header should be more
    // than enough for a JPEG image.
    var MAX_IMAGE_SIZE =
      (this._pictureSize.width * this._pictureSize.height * 4) + 4096;

The jpeg file size is far smaller than the raw image size, so is it possible to check the file size after a jpeg file is generated?
Since this internal storage is very small 10MB only.
blocking-b2g: --- → 1.3T?
triage: 1.3T+ to make use of the internal storage fully
ni? djf
Thanks
blocking-b2g: 1.3T? → 1.3T+
Flags: needinfo?(dflanagan)
(In reply to thomas tsai from comment #0)
>
> is it possible
> to check the file size after a jpeg file is generated?
> Since this internal storage is very small 10MB only.

The takePicture() callback returns a blob, which has a .size property[1].

1. https://developer.mozilla.org/en-US/docs/Web/API/Blob#Properties
Assignee: nobody → jdarcangelo
Mike: The idea behind the file size guesstimate is to prohibit additional pictures from being taken if there's not enough space left to store them. We have another global constant in v1.4 that can estimate what the *JPEG* size will be which is what is needed here. Simply taking `width * height * 4` will give you the raw bitmap size (in bytes) which is overkill. Additionally, I think we're wrong in multiplying by `4` here anyway because shouldn't it really be 24-bits-per-pixel and not 32bpp?
Justin, 

Thanks for taking this. You're right that using 3 instead of 4 would have made more sense. In either case, though, that would be a extreme upper bound.

It would be really bad if we allow the user to take a picture and then can't save it, so we need an upper bound on the file size that is very unlikely to be exceeded.  I think I'd go with width * height * .5.
Flags: needinfo?(dflanagan)
The challenge is that the size of the final JPEG depends heavily on the content of the image. I can appreciate not wanting to put the person in a position where a taken photo can't be saved, but I wonder about preventing the user from taking a picture that -might- be able to be saved.
Attached file pull-request (v1.3t)
Attachment #8418249 - Flags: review?(dflanagan)
Comment on attachment 8418249 [details] [review]
pull-request (v1.3t)

The code looks fine. I'd prefer a simpler calculation, though.  See my comment on github.
Attachment #8418249 - Flags: review?(dflanagan) → review+
Landed on v1.3t:

https://github.com/mozilla-b2g/gaia/commit/746934a1e331b9ce578bd9fbdb4614d950baf765
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
should this land on master as well?
I think we're ok on v1.4 and master since they both have the refactored camera. I remember introducing a piece of code that used a configurable average JPEG compression ratio for estimating file sizes.
Thank you for tarako only workaround.
We have kicked off v1.4 dolphin and shark project, we meeting this issue again.
Yang, can you help to cherry-pick this patch to v1.4?
Flags: needinfo?(yang.zhao)
(In reply to James Zhang from comment #12)
> We have kicked off v1.4 dolphin and shark project, we meeting this issue
> again.
> Yang, can you help to cherry-pick this patch to v1.4?

Have conflicts when cherry-pick to v1.4.
This code is completely different in 1.4 and master. I will look at making a patch for 1.4/master.
Attached file pull-request (master)
David: Please have a quick look at this patch converted for 1.4/master. Thanks!
Attachment #8424892 - Flags: review?(dflanagan)
Target Milestone: --- → 2.0 S1 (9may)
Comment on attachment 8424892 [details] [review]
pull-request (master)

Looks good to me.
Attachment #8424892 - Flags: review?(dflanagan) → review+
Attached file pull-request (v1.4)
Pull Request for v1.4 -- carrying R+ over from patch for master
Attachment #8425104 - Flags: review+
Please see comment # 19,already landed in v1.4.
Flags: needinfo?(yang.zhao)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: