Closed
Bug 850941
Opened 13 years ago
Closed 12 years ago
blob size is wrong in open activity after bluetooth image transfer
Categories
(Core :: DOM: Device Interfaces, defect)
Core
DOM: Device Interfaces
Tracking
()
People
(Reporter: djf, Assigned: baku)
References
Details
(Whiteboard: inarirun2)
Attachments
(2 files, 2 obsolete files)
|
10.15 KB,
patch
|
baku
:
review+
|
Details | Diff | Splinter Review |
|
10.08 KB,
patch
|
baku
:
review+
|
Details | Diff | Splinter Review |
When I receive an image by bluetooth and open it, the open activity in apps/gallery/js/open.js is called to display it. That code wants to check the size of the file before attempting to open it to prevent OOM errors on very large images.
But the blob.size property is always 18446744073709552000 so all the images appear to be very, very large.
This seems like a gecko or activiies issue, so I probably have the component wrong.
Note that this blocks a bug that is tef+
| Reporter | ||
Comment 1•13 years ago
|
||
Marking this as blocking bug 848916.
Cc'ing Fabrice and Ben because they always seem to know what to do when blobs go bad. Also Evelyn and Ian in case this bug is specific to bluetooth.
Blocks: 848916
| Reporter | ||
Comment 2•13 years ago
|
||
Note that the received blob also has an empty type field. That might or might not be the same bug, however.
Needinfo fabrice, at his request.
Flags: needinfo?(fabrice)
| Reporter | ||
Comment 3•13 years ago
|
||
I've looked at this some more. I'm using the nightly b2g-18 build from today.
When I do a share activity from the Gallery to the Bluetooth app (both OOP) it works fine, and the receiving app gets a blob with a name, size and type.
But when the system app receives a file by bluetooth, and then uses an open activity to display the file, the same thing fails. System initiates the activity, passing a file object. Gallery handles the activity, but the blob it receives does not have a name or a type, and its size is always 0x10000000000000180. That's more than 64 bits so something pretty wacky is happening with the size conversion.
The blob itself seems to contain the right data. It just the properties that are broken, and apparently only when transfering from the system app to another app.
I have confirmed when the system app initiates the activity, the file has a valid name, size and type.
| Reporter | ||
Comment 4•13 years ago
|
||
Given that the blob seems to work as a valid file, I was hoping I could workaround the lack of size with:
blob = new Blob([blob]);
But I get the same size when I do that.
Next I tried new FileReader().readAsArrayBuffer(blob), thinking I could check the size of the array buffer it created. But that just crashed the app. (OOM maybe since the reported size is so big?)
| Reporter | ||
Comment 5•13 years ago
|
||
That blob size, 18446744073709552000, is how JavaScript prints Math.pow(2,64). Its the closest JS integer approximation. It would also be the closest approximation to 2**64 - 1, which would be the value -1 (or any small negative number) in an signed int64.
Comment 6•13 years ago
|
||
Talking with David on IRC, the system app gets the file from bluetooth, saves it to device storage, and then shares this file-backed blob. The size is correct in the system app, but gets corrupted afterwards.
Since David has a workaround for now, we are not blocked but more investigation is needed.
Flags: needinfo?(fabrice)
| Assignee | ||
Comment 7•12 years ago
|
||
(In reply to David Flanagan [:djf] from comment #5)
> That blob size, 18446744073709552000, is how JavaScript prints
> Math.pow(2,64). Its the closest JS integer approximation. It would also be
> the closest approximation to 2**64 - 1, which would be the value -1 (or any
> small negative number) in an signed int64.
When a nsIDOMFile is created, the size is set to UINT64_MAX, so that IsSizeUnknown() returns true. Then, just the first time GetSize() is called, if (isSizeUnknown()), the real size is read from the file.
I think the reason why this bug exists, is because somehow the serialization of blobs process-to-process is broken, or it doesn't share size and type.
This happens only -i'm not 100% sure about this yet- with MozActivity.
/me still debugging it.
| Assignee | ||
Comment 8•12 years ago
|
||
The activity starts from the system app that runs in the main process.
With this patch the blob is created fully (size, date and content type) as it is in the DeviceStorageRequestParent.cpp
Attachment #747331 -
Flags: review?(doug.turner)
| Assignee | ||
Updated•12 years ago
|
Assignee: nobody → amarchesini
| Assignee | ||
Comment 9•12 years ago
|
||
This patch fixes the cursor() and the get() requests.
Attachment #747331 -
Attachment is obsolete: true
Attachment #747331 -
Flags: review?(doug.turner)
Attachment #747904 -
Flags: review?(doug.turner)
Comment 10•12 years ago
|
||
Comment on attachment 747904 [details] [diff] [review]
patch
Review of attachment 747904 [details] [diff] [review]:
-----------------------------------------------------------------
shouldn't we do this work in the blob? lets get bent's review.
::: dom/devicestorage/nsDeviceStorage.cpp
@@ +712,5 @@
> +
> + nsAutoCString mimeType;
> + nsCOMPtr<nsIMIMEService> mimeService =
> + do_GetService(NS_MIMESERVICE_CONTRACTID);
> + if (mimeService) {
return early if !mimeService
@@ +720,5 @@
> + return rv;
> + }
> + }
> +
> + mMimeType = NS_ConvertUTF8toUTF16(mimeType);
probably best to set this to something unknown if this function fails.
Attachment #747904 -
Flags: review?(doug.turner) → review?(bent.mozilla)
Comment on attachment 747904 [details] [diff] [review]
patch
Review of attachment 747904 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good to me!
Attachment #747904 -
Flags: review?(bent.mozilla) → review+
Updated•12 years ago
|
Component: Gaia::Bluetooth File Transfer → DOM: Device Interfaces
OS: Mac OS X → All
Product: Boot2Gecko → Core
Hardware: x86 → All
Comment 15•12 years ago
|
||
Hi baku,
It seems that the patch has been ready for a few days. Shall we?
Updated•12 years ago
|
Flags: needinfo?(amarchesini)
| Assignee | ||
Comment 16•12 years ago
|
||
(In reply to Eric Chou [:ericchou] [:echou] from comment #15)
> Hi baku,
>
> It seems that the patch has been ready for a few days. Shall we?
It's almost green on try. There is still an orange related to certificates. I hope to see/make it green for today. Then, yes. We can land it.
Flags: needinfo?(amarchesini)
Comment 17•12 years ago
|
||
(In reply to Andrea Marchesini (:baku) from comment #16)
> (In reply to Eric Chou [:ericchou] [:echou] from comment #15)
> > Hi baku,
> >
> > It seems that the patch has been ready for a few days. Shall we?
>
> It's almost green on try. There is still an orange related to certificates.
> I hope to see/make it green for today. Then, yes. We can land it.
Thank you, baku.
| Assignee | ||
Comment 18•12 years ago
|
||
Attachment #747904 -
Attachment is obsolete: true
Attachment #751011 -
Flags: review+
| Assignee | ||
Comment 19•12 years ago
|
||
Attachment #751029 -
Flags: review+
| Assignee | ||
Updated•12 years ago
|
Keywords: checkin-needed
Comment 20•12 years ago
|
||
Flags: in-testsuite+
Keywords: checkin-needed
Comment 21•12 years ago
|
||
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
Comment 22•12 years ago
|
||
status-b2g18:
--- → fixed
status-b2g18-v1.0.0:
--- → wontfix
status-b2g18-v1.0.1:
--- → wontfix
status-firefox22:
--- → wontfix
status-firefox23:
--- → wontfix
status-firefox24:
--- → fixed
Updated•12 years ago
|
Flags: in-moztrap?
You need to log in
before you can comment on or make changes to this bug.
Description
•