New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 741946 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 728627
issue 741029



Sign in to add a comment

Avoid duplicate copy of encoded images in Blink during load

Project Member Reported by chrishtr@chromium.org, Jul 13 2017

Issue description

At the moment, we appear to have three copies of the encoded form of every
image during load. After an image has finished loading, one of the duplicates
is removed. (*)

This can result in a spike of memory during load, which is undesireable.

One copy is passed along in the mojo IPC from the browser copy.
A second copy is in a SharedBuffer owned by the ImageResource.
A third is in a SkRWBuffer owned by the DeferredImageDecoder.


It seems we can avoid creating the 
SharedBuffer in the first place, and when ImageResource::AppendData() is
called, update the SkRWBuffer directly. To do so will be some refactoring work,
however, perhaps with complications for multipart images.

(*) https://codereview.chromium.org/2054643003/ implemented the behavior of
deleting the second copy after load.
https://docs.google.com/document/d/1v0yTAZ6wkqX2U_M6BNIGUJpM1s0TIw1VsqpxoL7aciY/edit#
describes the flow of information and updates.

 
Blocking: 741029
@hajimehoshi: what do you think of this idea? Worth doing? Harder than I think?
Labels: BugSource-Team PaintTeamTriaged-20170713
Chris, see issue 728627 which I think is exactly what you are also thinking of.
Thanks for the pointer. 728627 sounds like a tracking bug to simplify things
to the point that ideas like 741946 are possible. And we both agree that
more investment in reducing the complexity here is desireable.
The last point on 728627 is making SharedBuffer backed by a SkRWBuffer, which would remove the need for that third copy in your list.

But splitting into a separate/more focused bug sgtm.
Blocking: 728627
Oh if that's what point (3) in the other bug means, then yes. :)

Marking blocking bugs.
Cc: hirosh...@chromium.org haraken@chromium.org
Components: Blink>Loader
Labels: Performance-Memory
Is this also related to Issue 727995 (draft CL: https://codereview.chromium.org/2918443003/)?

Random thoughts about implementation:
How does this interact with the UpdateImage() throttling introduced by https://codereview.chromium.org/2361263003?
Tthe rhrottling requires buffering of data in ImageResource before passing the data to ImageResourceContent and blink::Image, and thus SharedBuffer might be still needed if we want to preserve this behavior, or we have to move throttling logic to blink::Image (add data always to SkRWBuffer, but throttle decoding).

> perhaps with complications for multipart images.
Agree... (we might want to keep SharedBuffer for multipart images, because probably we have to keep two buffers anyway, one (SkRWBuffer) for the previous part and one for the current part (SharedBuffer), but this might complicates the code)

Cc: khushals...@chromium.org
It's related, yes.

One thing I didn't mention is that I surveyed the callsites to Data() for ImageResource, and there
don't seem to be any callsites. All of them are for resources that are not images it seems.

I also discussed the throttling w/vmpstr, and we agreed that that would need to be moved. The throttling
can happen in ImageResourceContent, because the purpose of the throttling is to prevent over-invalidation
of images during load, not to prevent the buffers from being filled.

Finally, I agree that we can skip this optimization for multipart. These are very uncommon.
> @hajimehoshi: what do you think of this idea? Worth doing? Harder than I think?

The situation has been much changed as hiroshige@'s refactoring. Now it looks like ImageResource(Content) doesn't own SharedBuffer, right? Am I missing something?

Anyway, I'm really happy with SharedBuffer's refactoring by fmalita@.
Project Member

Comment 11 by sheriffbot@chromium.org, Jul 16

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: Available (was: Untriaged)

Sign in to add a comment