Closed
Bug 801632
Opened 12 years ago
Closed 12 years ago
B2G MMS: use Blob for attachment raw data
Categories
(Core :: DOM: Device Interfaces, defect)
Tracking
()
People
(Reporter: Yoric, Assigned: ctai)
References
Details
Attachments
(2 files, 9 obsolete files)
(deleted),
patch
|
vicamo
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
Details | Diff | Splinter Review |
See e.g.http://hg.mozilla.org/mozilla-central/annotate/942ed5747b63/dom/mms/src/ril/MmsService.js#l323
We could get rid of this trivially with OS.File.writeAtomic.
Updated•12 years ago
|
Blocks: b2g-mms
OS: All → Gonk
Hardware: All → ARM
Summary: MMSService does not need asyncCopy → B2G MMS: MmsService does not need asyncCopy
Reporter | ||
Comment 1•12 years ago
|
||
Marking this as a mentored bug.
Whiteboard: [mentor=Yoric][lang=js]
Comment 2•12 years ago
|
||
Were it possible to create a blob in javascript? I think that's what we really need to store the whole message into IndexedDb.
Reporter | ||
Comment 3•12 years ago
|
||
If we just want to move the code to off main thread file I/O with OS.File.writeAtomic, we do not need a Blob.
But otherwise, yes, I am almost certain that |new Blob(array)| works, where |array| can be either a regular array or a typed array.
Updated•12 years ago
|
Depends on: message-database
Updated•12 years ago
|
Blocks: message-database
No longer depends on: message-database
(In reply to David Rajchenbach Teller [:Yoric] from comment #3)
> But otherwise, yes, I am almost certain that |new Blob(array)| works, where
> |array| can be either a regular array or a typed array.
You can't pass an ArrayBuffer directly to the Blob constructor. You have to always pass a JS array. But you can do something like |new Blob([arraybuffer])|.
Hmm.. you might actually need to pass an ArrayBufferView. So something like
|new Blob([new Int8Array(arraybuffer)])|.
Sorry, the binary API is a mess :(
By the way, we shouldn't be doing file-io manually here. We should just create Blob objects and then save those in indexedDB along with the other MMS data. IndexedDB allows treating Blob data just like any other data, so you can do something like:
objectStore.put({ type: "mms", smil: "...", to: ["+1234567"], attachments: [{ name: "foo", blob: myBlobObject }, { name: "bar", blob: myOtherBlobObject }]})
The indexedDB implementation will make sure to do all of the IO on a background thread.
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → ctai
Updated•12 years ago
|
No longer blocks: 801599
Keywords: main-thread-io,
perf
Summary: B2G MMS: MmsService does not need asyncCopy → B2G MMS: use Blob for attachment raw data
Whiteboard: [mentor=Yoric][lang=js]
Assignee | ||
Comment 6•12 years ago
|
||
Assignee | ||
Comment 7•12 years ago
|
||
Attachment #695383 -
Attachment is obsolete: true
Assignee | ||
Updated•12 years ago
|
Attachment #695384 -
Flags: feedback?(vyang)
Assignee | ||
Comment 8•12 years ago
|
||
I refer https://mxr.mozilla.org/mozilla-central/source/content/base/src/nsContentUtils.cpp#6087 for MmsBlobService::CreateBlob(...)
Status: NEW → ASSIGNED
Assignee | ||
Comment 9•12 years ago
|
||
Attachment #695384 -
Attachment is obsolete: true
Attachment #695384 -
Flags: feedback?(vyang)
Attachment #695568 -
Flags: feedback?(vyang)
Comment 10•12 years ago
|
||
Comment on attachment 695568 [details] [diff] [review]
Save MMS attachments as blob
Review of attachment 695568 [details] [diff] [review]:
-----------------------------------------------------------------
Jonas, could you help review this?
Attachment #695568 -
Flags: review?(jonas)
Attachment #695568 -
Flags: feedback?(vyang)
Attachment #695568 -
Flags: feedback+
Comment on attachment 695568 [details] [diff] [review]
Save MMS attachments as blob
Review of attachment 695568 [details] [diff] [review]:
-----------------------------------------------------------------
All of this really shouldn't be needed. We already support creating a Blob by simply doing |new Blob([data], { type: mimetype })|.
What type is msg.parts[x].content? Is it a JS-array of bytes? If so you can do something like:
data = new Uint32Array(msg.content.length);
msg.content.forEach(function(v, index) {
data[index] = v;
});
blob = new Blob([data], { type: msg.headers["content-type"].media });
But of course even better would be if the MmsPduHelper created an Uint32Array directly rather than using a normal JS array of numbers. JS arrays of numbers is a terribly inefficient way of storing data so I'm a little bit worried about memory usage.
Either way, there should be no need for the new MmsBlobService.
Attachment #695568 -
Flags: review?(jonas) → review-
Comment 12•12 years ago
|
||
(In reply to Jonas Sicking (:sicking) from comment #11)
> All of this really shouldn't be needed. We already support
> creating a Blob by simply doing |new Blob([data], { type:
> mimetype })|.
I didn't find similar commit in the history, could you help pointing it out? Last time we talked about this, it was still an unimplemented request. We can definitely try again though.
Hmm.. you might be right that |new Blob| doesn't work in JS components yet. But it should require less code to make that work than what you are doing here. Basically you just need to hook up a Blob constructor the same way that the File constructor is hooked up [1][2]. You basically just need to call [3] to create the blob and then [4] to initialize it.
[1] http://mxr.mozilla.org/mozilla-central/source/js/xpconnect/loader/mozJSComponentLoader.cpp#290
[2] http://mxr.mozilla.org/mozilla-central/source/js/xpconnect/loader/mozJSComponentLoader.cpp#238
[3] http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsDOMBlobBuilder.cpp#154
[4] http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsDOMBlobBuilder.cpp#169
Assignee | ||
Comment 14•12 years ago
|
||
File a new Bug 825836 for support Blob in JS components.
Assignee | ||
Comment 15•12 years ago
|
||
Attachment #695568 -
Attachment is obsolete: true
Assignee | ||
Comment 16•12 years ago
|
||
Attachment #697801 -
Attachment is obsolete: true
Assignee | ||
Updated•12 years ago
|
Attachment #699205 -
Flags: review?(vyang)
Comment 17•12 years ago
|
||
Comment on attachment 699205 [details] [diff] [review]
Save MMS attachments as blob
Review of attachment 699205 [details] [diff] [review]:
-----------------------------------------------------------------
Let's remove all file storing related code here. Shall we?
Attachment #699205 -
Flags: review?(vyang)
Assignee | ||
Comment 18•12 years ago
|
||
Attachment #699205 -
Attachment is obsolete: true
Assignee | ||
Updated•12 years ago
|
Attachment #699224 -
Flags: review?(vyang)
Assignee | ||
Comment 19•12 years ago
|
||
Attachment #699224 -
Attachment is obsolete: true
Attachment #699224 -
Flags: review?(vyang)
Assignee | ||
Updated•12 years ago
|
Attachment #699725 -
Flags: review?(vyang)
Assignee | ||
Comment 20•12 years ago
|
||
Attachment #699725 -
Attachment is obsolete: true
Attachment #699725 -
Flags: review?(vyang)
Attachment #699729 -
Flags: review?(vyang)
Comment 21•12 years ago
|
||
Comment on attachment 699729 [details] [diff] [review]
Save MMS attachments as blob
Review of attachment 699729 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/mms/src/ril/MmsService.js
@@ +535,5 @@
> return;
> }
> + // Todo: Please add code for inserting msg into database
> + // right here.
> + // see bug id: 811252 - B2G MMS: implement MMS database
Trailing space. Besides, it's fine to save a line break here, I think :)
::: dom/mms/src/ril/WspPduHelper.jsm
@@ +2240,5 @@
> let content = Octet.decodeMultiple(data, contentEnd);
> + if(content) {
> + content = new Blob([content],
> + {"type" : headers["content-type"].media});
> + }
Please just have two distinct variables for different uses. And mind a space char after 'if'.
Attachment #699729 -
Flags: review?(vyang)
Assignee | ||
Comment 22•12 years ago
|
||
Attachment #699729 -
Attachment is obsolete: true
Attachment #699803 -
Flags: review?(vyang)
Assignee | ||
Comment 23•12 years ago
|
||
Attachment #699803 -
Attachment is obsolete: true
Attachment #699803 -
Flags: review?(vyang)
Attachment #699805 -
Flags: review?(vyang)
Updated•12 years ago
|
Attachment #699805 -
Flags: review?(vyang) → review+
Comment 24•12 years ago
|
||
Assignee | ||
Comment 25•12 years ago
|
||
Comment 26•12 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
Updated•12 years ago
|
blocking-b2g: leo? → leo+
Assignee | ||
Comment 28•12 years ago
|
||
Comment 29•12 years ago
|
||
status-b2g18:
--- → fixed
status-b2g18-v1.0.0:
--- → wontfix
status-b2g18-v1.0.1:
--- → wontfix
status-firefox21:
--- → fixed
Comment 30•12 years ago
|
||
The entire set of clian's pushes was backed out for multiple reasons.
https://tbpl.mozilla.org/?tree=Mozilla-B2g18&rev=a0b06192f882
1.) The tree rules are clear that you are not to land on top of bustage. At the time you pushed, both B2G Mn and B2G xpcshell had bustage from prior commits that hadn't been backed out yet.
2.) The tree rules are also clear that you are to watch your pushes for any bustage and handle them accordingly. mozilla-inbound is the ONLY tree where this rule does not apply.
3.) Even after the earlier bustage was backed out, something in one of your many pushes was causing further B2G Mn failures as shown in the log below.
https://tbpl.mozilla.org/php/getParsedLog.php?id=20424173&tree=Mozilla-B2g18
4.) This isn't cause for backout by itself, but it is also strongly preferred to not push each commit individually as our build and testing resources are limited and doing so stretches them even thinner. Please limit your number of pushes as much as possible unless you have good reason for keeping them separate.
status-firefox20:
--- → wontfix
Comment 31•12 years ago
|
||
Updated•11 years ago
|
Flags: in-moztrap-
You need to log in
before you can comment on or make changes to this bug.
Description
•