<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>25662</bug_id>
          
          <creation_ts>2014-05-12 18:12:32 +0000</creation_ts>
          <short_desc>ImageBitmap Promise usage review</short_desc>
          <delta_ts>2014-09-22 18:28:31 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#images</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>d</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>105737</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-05-12 18:12:32 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html
Multipage: http://www.whatwg.org/C#images
Complete: http://www.whatwg.org/c#images
Referrer: http://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=13&amp;ved=0CDoQFjACOAo&amp;url=http%3A%2F%2Fwww.whatwg.org%2Fspecs%2Fweb-apps%2Fcurrent-work%2Fmultipage%2Ftimers.html&amp;ei=Xg1xU7ymIsmvyATkioK4Cw&amp;usg=AFQjCNF2Xnrwgun2m7KcyqkqLsqEvc8LYQ&amp;sig2=DubxYrOGGBzkcQ2wIFEwRA&amp;bvm=bv.66330100,d.aWw

Comment:
Promise usage review:

- Can use Promise&lt;ImageBitmap&gt; WebIDL syntax for better documentation
- All the &quot;throw an exception&quot; steps will be automatically fixed by WebIDL to
become rejected promises, but you could make it clearer to the reader by
saying &quot;return a promise rejected with an IndexSizeError exception&quot; instead of
&quot;throw an IndexSizeError exception.&quot;
- &quot;Fulfill the Promise&apos;s associated resolver with ... as the value&quot; should
become &quot;resolve the promise with ...&quot;
- There is no need to perform steps asynchronously if there is no off-main
thread work going on. E.g. many cases do no actual work, but just resolve the
promise with a new ImageBitmap. There is no need to do those in a separate set
of async steps after the main algorithm returns.
- Relatedly, it seems like there is some heavy processing going on that is not
being done asynchronously, e.g. cropping and so on. Shouldn&apos;t those steps be
done async?

Code example: change Promise.every(...) to Promise.all([...])

The constructor parameter changed slightly. The new version should be:

var resolve;
new Promise(function (arg) { resolve = arg; });

resolve(Promise.all([...]))


Posted from: 12.173.83.50
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:29.0) Gecko/20100101 Firefox/29.0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105888</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-05-13 18:35:05 +0000</bug_when>
    <thetext>Why can&apos;t I throw an exception from this method? Separate from rejecting the promise later, I mean, which would happen if there was some unexpected problem rather than one that can be statically and synchronously detected when the method is invoked and indicates an authoring error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105895</commentid>
    <comment_count>2</comment_count>
    <who name="Domenic Denicola">d</who>
    <bug_when>2014-05-13 19:04:04 +0000</bug_when>
    <thetext>Forcing users to include two ways of detecting exceptions from your methods is bad. Then they have to do

```js
try {
  asyncThing().catch(handleError);
} catch (e) {
  handleError(e);
}

function handleError(e) {
  // recover and continue
}
```

instead of

```js
asyncThing().catch(e =&gt; {
  // recover and continue
});
```

Previous discussion at https://github.com/domenic/promises-unwrapping/issues/24</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105908</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-05-13 20:35:45 +0000</bug_when>
    <thetext>I don&apos;t think these exceptions are exceptions that you&apos;d normally ever want to catch. The problem is that I don&apos;t want these exceptions to get mixed in with the &quot;expected&quot; exceptions that are things like &quot;this file isn&apos;t a valid image&quot;.

Back when this API used callbacks, the distinction would have been that bad arguments would throw synchronously, while bad data (something that might happen even if the script has no logic errors) would result in the callback being invoked with &quot;null&quot; as the result, or some such.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111307</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2014-09-09 23:21:37 +0000</bug_when>
    <thetext>Ok, I give up. It&apos;s a lame language design decision, but it&apos;s time for me to move on.

Here&apos;s my game plan:

1. Update the IDL to use Promise&lt;ImageBitmap&gt;.
2. Use &quot;return a promise rejected with an [...] exception&quot; where I 
   use &quot;throw&quot; currently.
3. &quot;Fulfill the Promise&apos;s associated resolver with ... as the value&quot; should
   become &quot;resolve the promise with ...&quot; or whatever WebIDL defines.
4. Change Promise.every(...) to Promise.all([...]) in the example.
5. Change resolver.resolve() to just resolver() in the example.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111970</commentid>
    <comment_count>5</comment_count>
    <who name="">contributor</who>
    <bug_when>2014-09-22 18:28:31 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r8804.
Check-in comment: Integrate with new promise stuff better
https://html5.org/tools/web-apps-tracker?from=8803&amp;to=8804</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>