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

java.lang.NullPointerException at com.sun.prism.impl.BaseResourceFactory.clearTextureCache(BaseResourceFactory.java:47)

XMLWordPrintable

      I'm working with big images (9683x5800) and get the following exception:

      java.lang.NullPointerException
              at com.sun.prism.impl.BaseResourceFactory.clearTextureCache(BaseResourceFactory.java:47)
              at com.sun.prism.impl.BaseResourceFactory.getCachedTexture(BaseResourceFactory.java:102)
              at com.sun.prism.image.CachingCompoundImage.getTile(CachingCompoundImage.java:27)
              at com.sun.prism.image.CompoundCoords.draw(CompoundCoords.java:74)
              at com.sun.javafx.sg.prism.NGImageView.renderContent(NGImageView.java:127)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:203)
              at com.sun.javafx.sg.prism.NGImageView.doRender(NGImageView.java:97)
              at com.sun.javafx.sg.prism.NGImageView.doRender(NGImageView.java:20)
              at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1164)
              at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:204)
              at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:420)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:203)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:39)
              at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1164)
              at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:204)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:203)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:39)
              at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1164)
              at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:204)
              at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:420)
              at com.sun.javafx.sg.prism.NGNode.renderForClip(NGNode.java:445)
              at com.sun.javafx.sg.prism.NGNode.renderRectClip(NGNode.java:336)
              at com.sun.javafx.sg.prism.NGNode.renderClip(NGNode.java:362)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:195)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:39)
              at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1164)
              at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:204)
              at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:420)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:203)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:39)
              at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1164)
              at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:204)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:203)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:39)
              at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1164)
              at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:204)
              at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:420)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:203)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:39)
              at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1164)
              at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:204)
              at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:420)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:203)
              at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:39)
              at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1164)
              at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:118)
              at com.sun.javafx.tk.quantum.AbstractPainter.paintImpl(AbstractPainter.java:184)
              at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:73)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
              at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
              at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
              at com.sun.prism.render.RenderJob.run(RenderJob.java:37)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
              at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:98)
              at java.lang.Thread.run(Thread.java:722)

      I take a look at the source code and noticed that

              Collection<Texture> texAll = texCache.values();

      can contain null values as per WeakHashMap definition. Moreover, they are added in getCachedTexture() method:

                  tex = createTexture(image, Usage.DEFAULT, allowPad);
                  if (tex == null) {
                      clearTextureCache();
                      tex = createTexture(image, Usage.DEFAULT, allowPad);
                  }
                  if (tex != null) {
                      tex.setLastImageSerial(serial);
                  }
                  
                  texCache.put(image, tex);

      so it is necessary to check for null as following:

              for (Texture i : texAll) {
                  if (i != null) {
                      i.dispose();
                  }
              }

            ckyang Chien Yang (Inactive)
            mrkam Alexander Kuznetcov (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: