I'm trying to write a simple FX8 image display program on the Raspberry Pi2 without increasing the GPU memory beyond the default 64MB. I seem to get me a NullPointer Exception at com.sun.prism.impl.BaseGraphics.drawTexture attempting to render the ImageView. This is with the packaged Oracle JDK8 (build 1.8.0-b132).
The image is about as small as I can make it without sacrificing quality. Is there anything I can do to reduce the amount of GPU memory required to render this simple image?
MCVE:
My minimum demonstration is very straightforward: an AnchorView holding an ImageView, displaying a 29kB PNG (1847x1080).
package sample;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception
{
Image image = new Image("/Sponsor.png");
ImageView imageview = new ImageView(image);
AnchorPane root = new AnchorPane(imageview);
Scene scene = new Scene(root, 400, 275);
primaryStage.setScene(scene);
imageview.setFitHeight(scene.getHeight());
imageview.setFitWidth(scene.getWidth());
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Stack trace
glGetError 0x505
java.lang.NullPointerException
at com.sun.prism.impl.BaseGraphics.drawTexture(BaseGraphics.java:389)
at com.sun.prism.impl.ps.BaseShaderGraphics.drawTexture(BaseShaderGraphics.java:139)
at com.sun.prism.image.Coords.draw(Coords.java:46)
at com.sun.prism.image.CompoundCoords.draw(CompoundCoords.java:94)
at com.sun.javafx.sg.prism.NGImageView.renderContent(NGImageView.java:134)
at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2043)
at com.sun.javafx.sg.prism.NGImageView.doRender(NGImageView.java:103)
at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1951)
at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:225)
at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:575)
at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2043)
at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1951)
at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:469)
at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:324)
at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:89)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:129)
at java.lang.Thread.run(Thread.java:744)