New issue
Advanced search Search tips

Issue 863038 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jul 17
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug



Sign in to add a comment

MacViews: Images used by themes are not cached

Project Member Reported by ccameron@chromium.org, Jul 12

Issue description

To reproduce:
1. Install Morpheon Dark (https://chrome.google.com/webstore/detail/morpheon-dark/mafbdhjdkjnoafhfelkjpchpaepjknad)
2. Enable UI GPU raster --enable-features=ViewsBrowserWindows,UiGpuRasterization
  - ViewsBrowserWindows may be needed on Mac
  - UiGpuRasterization is needed on non-Mac
3. Trace opening a tab (with cc, gpu enabled).

The trace will look similar to the attached trace.
- Starting at 3436.419 ms, we upload a 3840x240 image (in GpuMain)
- Then we upload an image of the same size at 3442.840 ms, 3450.659 ms, 3457.856 ms
- ... and we continue to upload this same-sized image basically every frame
- and each upload costs ~1 ms (some as much as 3 ms)
- and jank results
 
trace_theme-upload.json.gz
1.5 MB Download
Yup, I can see continuous uploads from the raster worker in the browser, each after a repaint in the ui. Is it the ui generating new bitmaps each time? You can try adding a trace to PaintImage::CreateFromBitmap to see where this is happening.
It doesn't seem to be coming from CreateFromBitmap (although there are lots of repeats of the same image there, too, just not of this huge image).

We seem to be generating lots of new SkImages with new SkImage::uniqueID()s through the following path
  cc::PaintImage::CreateSkImage()
  cc::PaintImageBuilder::TakePaintImage()
  gfx::CreateImageRepShaderForScale(gfx::ImageSkiaRep const&, SkShader::TileMode, SkMatrix const&, float)
  gfx::CreateImageRepShader(gfx::ImageSkiaRep const&, SkShader::TileMode, SkMatrix const&)
  gfx::Canvas::InitPaintFlagsForTiling(gfx::ImageSkia const&, int, int, float, float, int, int, cc::PaintFlags*)
  gfx::Canvas::TileImageInt(gfx::ImageSkia const&, int, int, int, int, int, int, float, cc::PaintFlags*)
  gfx::Canvas::TileImageInt(gfx::ImageSkia const&, int, int, int, int)
  BrowserNonClientFrameViewMac::PaintThemedFrame(gfx::Canvas*)
  BrowserNonClientFrameViewMac::OnPaint(gfx::Canvas*)

(this is a copy-paste in case there's something obvious -- still digging in)
In CreateImageRepShaderForScale, is there a reason that we do:

  return cc::PaintShader::MakeImage(
      cc::PaintImageBuilder::WithDefault()
          .set_id(cc::PaintImage::GetNextId())
          .set_image(SkImage::MakeFromBitmap(image_rep.sk_bitmap()),                              
                     cc::PaintImage::GetNextContentId())
          .TakePaintImage(),
      tile_mode, tile_mode, &shader_scale); 

as opposed to

  return cc::PaintShader::MakeImage(
      image_rep.paint_image(),
      tile_mode, tile_mode, &shader_scale);

That seems to do it...
Oh. Its just something I missed in the original change then. Looking through SkImage::MakeFromBitmap, I think this is the only remaining use in ui.

This should fix it: https://chromium-review.googlesource.com/c/chromium/src/+/1135963
Project Member

Comment 5 by bugdroid1@chromium.org, Jul 13

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/19049df109a2b8cfabf90392bb7a3962a40aca56

commit 19049df109a2b8cfabf90392bb7a3962a40aca56
Author: Khushal <khushalsagar@chromium.org>
Date: Fri Jul 13 01:28:34 2018

ui: Dont re-create PaintImages with the same backing bitmap.

R=asvitkine@chromium.org

Bug:  863038 
Change-Id: I520fac764e1cc1fda499a29a46aff3a663ad9ed1
Reviewed-on: https://chromium-review.googlesource.com/1135963
Commit-Queue: Khushal <khushalsagar@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574801}
[modify] https://crrev.com/19049df109a2b8cfabf90392bb7a3962a40aca56/ui/gfx/skia_paint_util.cc

Cc: ccameron@chromium.org
Owner: khushals...@chromium.org
Fixed?
Status: Assigned (was: Untriaged)
Owner: ccameron@chromium.org
I think Chris is still investigating repeated calls to PaintImage::CreateFromBitmap which could indicate the ui is unnecessary re-generating bitmaps which have to be uploaded.
Status: Fixed (was: Assigned)
Yeah, there may yet be more here. I think it's good enough to call done unless I see something else.

Sign in to add a comment