3

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)
4
  • Maybe using javafx is the wrong way to go here? Using shaders and textures implies it is engaging openGL, which is totally unnecessary to present png images. I believe the minimum GPU mem for OGL use is 128 MB, which might explain your problem. You should investigate this as a non pi specific javafx issue to confirm part of this.
    – goldilocks
    Commented Oct 28, 2015 at 14:13
  • Thanks, that's a good point about it pulling in OGL. I will investigate as a general javafx issue.
    – Autumn
    Commented Oct 28, 2015 at 15:02
  • Thanks @goldilocks. Crossposted to SO here. Interesting suggestions, however, using the SW rendering pipeline fails with the current Oracle JDK. The error message suggests making a bugreport at bugreport.sun.com. Is there a better way to get the news to Oracle?
    – Autumn
    Commented Oct 29, 2015 at 0:14
  • @DSJustice: I think writing a Bug-Report there is the best way to let them know, because it is well managed and way better than "writing them an E-Mail" or so.
    – Simulant
    Commented Dec 7, 2015 at 15:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.