<?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>23514</bug_id>
          
          <creation_ts>2013-10-14 22:08:32 +0000</creation_ts>
          <short_desc>&lt;canvas&gt;: Manual memory management for image assets used in canvas games</short_desc>
          <delta_ts>2016-04-21 17:14:59 +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></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>Needs Impl Interest</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ian &apos;Hixie&apos; Hickson">ian</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>ian</cc>
    
    <cc>junov</cc>
    
    <cc>mike</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>94723</commentid>
    <comment_count>0</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-10-14 22:08:32 +0000</bug_when>
    <thetext>On Thu, 18 Jul 2013, Ian Hickson wrote:
&gt; On Wed, 9 Jan 2013, Ashley Gullen wrote:
&gt; &gt;
&gt; &gt; Some developers are starting to design large scale games using our HTML5
&gt; &gt; game engine, and we&apos;re finding we&apos;re running in to memory management
&gt; &gt; issues.  Consider a device with 50mb of texture memory available.  A
&gt; &gt; game might contain 100mb of texture assets, but only use a maximum of
&gt; &gt; 30mb of them at a time (e.g. if there are three levels each using 30mb
&gt; &gt; of different assets, and a menu that uses 10mb of assets).  This game
&gt; &gt; ought to fit in memory at all times, but if a user agent is not smart
&gt; &gt; about how image loading is handled, it could run out of memory.
&gt; &gt;
&gt; &gt; [...]
&gt; &gt;
&gt; &gt; Some ideas:
&gt; &gt; 1) add new functions to the canvas 2D context, such as:
&gt; &gt; ctx.load(image): cache an image in memory so it can be immediately drawn
&gt; &gt; when drawImage() is first used
&gt; &gt; ctx.unload(image): release the image from memory
&gt;
&gt; The Web API tries to use garbage collection for this; the idea being that
&gt; you load the images you need when you need them, then discard then when
&gt; you&apos;re done, and the memory gets reclaimed when possible.
&gt;
&gt; We could introduce a mechanism to flush ImageBitmap objects more forcibly,
&gt; e.g. imageBitmap.discard(). This would be a pretty new thing, though. Are
&gt; there any browser vendors who have opinions about this?
&gt;
&gt; We should probably wait to see if people are able to use ImageBitmap with
&gt; garbage collection first. Note, though, that ImageBitmap doesn&apos;t really
&gt; add anything you couldn&apos;t do with &lt;img&gt; before, in the non-Worker case.
&gt; That is, you could just create &lt;img&gt; elements then lose references to them
&gt; when you wanted them GC&apos;ed; if that isn&apos;t working today, I don&apos;t see why
&gt; it would start working with ImageBitmap.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125999</commentid>
    <comment_count>1</comment_count>
    <who name="Justin Novosad">junov</who>
    <bug_when>2016-04-21 17:14:59 +0000</bug_when>
    <thetext>This issue has been resolved thanks to the addition of the ImageBitmap API, and a more recent addition to that interface: the close() method which gives direct control over discarding the object&apos;s underlying image data without waiting for garbage collection.

See: https://github.com/whatwg/html/pull/1078</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>