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)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla21
blocking-b2g leo+
Tracking Status
firefox20 --- wontfix
firefox21 --- fixed
b2g18 --- fixed
b2g18-v1.0.0 --- wontfix
b2g18-v1.0.1 --- wontfix

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
Blocks: b2g-mms
OS: All → Gonk
Hardware: All → ARM
Summary: MMSService does not need asyncCopy → B2G MMS: MmsService does not need asyncCopy
Marking this as a mentored bug.
Whiteboard: [mentor=Yoric][lang=js]
Were it possible to create a blob in javascript? I think that's what we really need to store the whole message into IndexedDb.
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.
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: nobody → ctai
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]
Depends on: 823816
No longer depends on: 823816
Attached patch Save MMS attachments as blob (obsolete) (deleted) — Splinter Review
Attached patch Save MMS attachments as blob (obsolete) (deleted) — Splinter Review
Attachment #695383 - Attachment is obsolete: true
Attachment #695384 - Flags: feedback?(vyang)
Status: NEW → ASSIGNED
Attached patch Save MMS attachments as blob (obsolete) (deleted) — Splinter Review
Attachment #695384 - Attachment is obsolete: true
Attachment #695384 - Flags: feedback?(vyang)
Attachment #695568 - Flags: feedback?(vyang)
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-
(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
Depends on: 825836
File a new Bug 825836 for support Blob in JS components.
Attached patch WIP-Wait for 825836 (obsolete) (deleted) — Splinter Review
Attachment #695568 - Attachment is obsolete: true
Attached patch Save MMS attachments as blob (obsolete) (deleted) — Splinter Review
Attachment #697801 - Attachment is obsolete: true
Attachment #699205 - Flags: review?(vyang)
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)
Attached patch Save MMS attachments as blob (obsolete) (deleted) — Splinter Review
Attachment #699205 - Attachment is obsolete: true
Attachment #699224 - Flags: review?(vyang)
Attached patch Save MMS attachments as blob (obsolete) (deleted) — Splinter Review
Attachment #699224 - Attachment is obsolete: true
Attachment #699224 - Flags: review?(vyang)
Attachment #699725 - Flags: review?(vyang)
Attached patch Save MMS attachments as blob (obsolete) (deleted) — Splinter Review
Attachment #699725 - Attachment is obsolete: true
Attachment #699725 - Flags: review?(vyang)
Attachment #699729 - Flags: review?(vyang)
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)
Attached patch Save MMS attachments as blob (obsolete) (deleted) — Splinter Review
Attachment #699729 - Attachment is obsolete: true
Attachment #699803 - Flags: review?(vyang)
Attached patch Save MMS attachments as blob (deleted) — Splinter Review
Attachment #699803 - Attachment is obsolete: true
Attachment #699803 - Flags: review?(vyang)
Attachment #699805 - Flags: review?(vyang)
Attachment #699805 - Flags: review?(vyang) → review+
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
For mms merge to b2g18.
blocking-b2g: --- → leo?
blocking-b2g: leo? → leo+
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.
Flags: in-moztrap-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: