Closed
Bug 1106137
Opened 10 years ago
Closed 10 years ago
Make canvas debugger faster by avoiding a double-copy operation when deserializing image data
Categories
(DevTools Graveyard :: Canvas Debugger, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 37
People
(Reporter: vporof, Assigned: vporof)
Details
Attachments
(2 files, 1 obsolete file)
13.71 KB,
patch
|
Details | Diff | Splinter Review | |
23.66 KB,
patch
|
pbro
:
review+
|
Details | Diff | Splinter Review |
No description provided.
Assignee | ||
Comment 1•10 years ago
|
||
Assignee: nobody → vporof
Status: NEW → ASSIGNED
Assignee | ||
Comment 2•10 years ago
|
||
Explaining this seemingly weird mess of array buffer constructors: Previous behavior: 1. make an array buffer (representing pixels) in the actor 2. manipulate its 32-bit view somehow (one pixel at a time) 3. pass that 32-bit view to the protocol's serializer - since array buffer views can't be properly stringified as JSON, manually join the numbers with commas to represent a plain array 4. deserialize it on the client as plain array and create a 32-bit view from it 5. create an ImageData object 6. copy the previously created 32-bit view's buffer into the ImageData's 8-bit view's buffer A keen observer would realize that this involves one extra redundant copy operation: step 4 vs. 6. The new approach is: 1. make an array buffer (representing pixels) in the actor 2. manipulate its 32-bit view somehow (one pixel at a time) 3. pass an 8-bit view of that array buffer to the protocol's serializer 4. deserialize it on the client as plain array 5. create an ImageData object 6. copy the previously deserialized array representing an 8-bit view into the ImageData's 8-bit view's buffer This saves us a very costly copy operation, at the expense of serializing 4 times as many numbers. This is a good exchange. Obviously, it'd still be better if protocol.js could just "hand over" the array buffer without serializing one of its views, but what we have right now is still mostly ok.
Attachment #8530390 -
Attachment is obsolete: true
Attachment #8530449 -
Flags: review?(pbrosset)
Assignee | ||
Comment 3•10 years ago
|
||
Comment on attachment 8530449 [details] [diff] [review] avoid-double-copy.patch Review of attachment 8530449 [details] [diff] [review]: ----------------------------------------------------------------- ::: toolkit/devtools/server/actors/canvas.js @@ +62,2 @@ > write: (v) => "[" + Array.join(v, ",") + "]", > + read: (v) => JSON.parse(v) To be more precise, this was the redundant copy. Creating an array buffer view from a regular js array (or another view) involves a copy, as opposed to creating it from a buffer, which does not.
Assignee | ||
Comment 5•10 years ago
|
||
Ugly run, but green for this bug: https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=c31b4c9a4c65
Assignee | ||
Updated•10 years ago
|
Attachment #8530449 -
Flags: review?(pbrosset)
Comment 6•10 years ago
|
||
Comment on attachment 8532589 [details] [diff] [review] v2 Review of attachment 8532589 [details] [diff] [review]: ----------------------------------------------------------------- This all looks good to me. I'd like to see a comment (something general at the top of canvas.js) that explains the approach described in comment 2.
Attachment #8532589 -
Flags: review?(pbrosset) → review+
Assignee | ||
Comment 7•10 years ago
|
||
Added comment and landed: https://hg.mozilla.org/integration/fx-team/rev/8a6b14d8320e
Whiteboard: [fixed-in-fx-team]
Comment 8•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/8a6b14d8320e
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 37
Updated•6 years ago
|
Product: Firefox → DevTools
Updated•5 years ago
|
Product: DevTools → DevTools Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•