Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8092801

[Canvas] Canvas buffers commands indefinitely when it isn't visible leading to Out of Memory Exception



      The Canvas added in JavaFX 2.2 allows developers to paint their own images. This was something needed to implement rendering of generated content. However, due to a design flaw in the implementation it is generally unsable. A Canvas that is not showing on the screen will buffer commands indefinitely until the VM runs out of memory. Something as simple as a user switching to another tab or scrolling the Canvas out of view in a ScrollPane will lead to out of memory errors. It is unreasonable to put the burden of managing this on the application developer since there are so many ways that the Canvas might become "off screen". Also the application requirements in general may make it very difficult to suspend painting to the Canvas, since ultimately all subsequent drawing would need to assume that previous drawing has completed. This basically means that unless the commands are flushed to the Canvas regardless of if it is visible, somebody would have to do the buffering.
      Canvas simply must not buffer indefinitely, it needs to flush if some threshold is reached without the Canvas being visible.

      Test case attached.


          Issue Links



              • Assignee:
                flar Jim Graham
                swpalmer Scott Palmer
              • Votes:
                3 Vote for this issue
                14 Start watching this issue


                • Created: