New issue
Advanced search Search tips

Issue 591296 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug



Sign in to add a comment

UserImage::CreateAndEncode() should not be called on UI thread

Project Member Reported by satorux@chromium.org, Mar 2 2016

Issue description

UserImage::CreateAndEncode() is an expensive function (converting a bitmap into JPEG format) thus should not be used on the UI thread.

For instance, the following code is to convert the profile image downloaded from the server (512x512 pixels for me) to JPEG format, on UI thread.

void UserImageManagerImpl::SaveUserImageFromProfileImage() {
  if (IsUserImageManaged())
    return;
  // Use the profile image if it has been downloaded already. Otherwise, use a    
  // stub image (gray avatar).                                                    
  job_.reset(new Job(this));
  job_->SetToImage(user_manager::User::USER_IMAGE_PROFILE,
                   downloaded_profile_image_.isNull()
                       ? user_manager::UserImage()
                       : user_manager::UserImage::CreateAndEncode(
                             downloaded_profile_image_));

I haven't done a benchmark but it'd probably take like a millisecond on slow devices.
 
Tested on squawks. It took 3259 microseconds to handle a profile image of 440x440 pixels (it wasn't 512x512 pixels for me).  3 milliseconds would be slow enough to cause a frame drop.
Components: Internals>Images

Sign in to add a comment