New issue
Advanced search Search tips

Issue 813418 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Feb 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 3
Type: Feature



Sign in to add a comment

Feature request: support loading image synchronously

Reported by project....@gmail.com, Feb 18 2018

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36

Steps to reproduce the problem:
Now the image object can only be loaded asynchronously even the data is already in the memory.  The example code is shown in the following:
--------------------------------------
var imageDataInBase64 = '.........';
  var image = new Image();
  image.src = `data:image/png;base64' + imageDataInBase64;

  image.onload = function() {
    // Loading is done and do something else.
  };
--------------------------------------

What is the expected behavior?

What went wrong?

Enforced "loading asynchronously" is painful.

Please review all asynchronous API (such as image, xmlhttprequest and others) in the 2018 because:
1: The core of Chromium is used in many cases other than WEB. NW.js/Electron has millions of users.

2: Provide a set of synchronous APIs with a timeout option! Thus web developers can have more options.  "asynchronous only" is not painful.

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 64.0.3282.167  Channel: stable
OS Version: OS X 10.13.3
Flash Version:
 

Comment 1 by ajha@chromium.org, Feb 19 2018

Labels: -Type-Bug Needs-Triage-M64 Type-Feature
Components: Blink>Image
Labels: Triaged-ET M-66 FoundIn-66 OS-Linux OS-Windows
Status: Untriaged (was: Unconfirmed)
As per comment#0 from the reporter considering this issue as Feature request and marking as Untriaged.

Thanks!
Components: -Blink>Image Blink>Scheduling
Labels: -Pri-2 Pri-3
I don't think we can can load synchronously, presuming you mean the JS can assume the image is available on the line after the image.src asignment is made. The Javascript must return so that a document lifecycle can execute to update CSS and fetch the image, even if it is a data URL.

I'm tempted to WontFix, but others might differ. Waiting on confirmation from the scheduling team because maybe I am misunderstanding what's possible.
Status: WontFix (was: Untriaged)
Yeah, I don't think this is really compatible with the execution model of JavaScript. If we decoded the image synchronously, we'd be blocking other UI events from getting processed which would lead to a bad user experience.

One option might be to allow synchronous image decodes on a worker thread, but I'm really sure what the end goal here is: what data are you depending on from the loaded image?

I'll WontFix this for now but please reopen if I missed something.
The goal is very simple: keep the code workflow simple and natural. Examples are:
var image = new Image();
image.src = `data:image/png;base64' + imageDataInBase64;
// If the image is loaded synchronously. Then we can use it now! In Computer Graphics, many cases can depend on images, such as textures/videos etc.

myGraphicsTextureObject.addImage(image); //Now we can use the image 


myGraphicsVideoObject.addImage(image);  //Now we can use the image 

Sign in to add a comment