JDK-8129058 : Textures leak when window is resized
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: fx2.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2011-08-15
  • Updated: 2022-10-21
  • Resolved: 2011-10-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
fx2.0.2Fixed
Related Reports
Blocks :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
The test below, when left running for some time (several minutes on my machine) starts to throw exceptions:

import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.util.Duration;

public class Test extends Application {
    @Override public void start(final Stage stage) {
        stage.setScene(new Scene(new Group()));
        stage.setWidth(400);
        stage.setHeight(400);
        stage.show();

        Timeline anim = new Timeline(new KeyFrame(Duration.millis(10),
            new EventHandler<ActionEvent>() {
                public void handle(ActionEvent ev) {
                    stage.setWidth(1000 - stage.getWidth());
                }
            }));
        anim.setCycleCount(Timeline.INDEFINITE);
        anim.play();
    }

    public static void main(String[] args){
        launch(args);
    }
}

The exception is
java.lang.NullPointerException
	at com.sun.prism.impl.BaseGraphics.drawTextureVO(BaseGraphics.java:362)
	at com.sun.prism.impl.BaseGraphics.drawTexture(BaseGraphics.java:331)
	at com.sun.prism.impl.ps.BaseShaderGraphics.drawTexture(BaseShaderGraphics.java:100)
	at com.sun.prism.impl.BaseGraphics.drawTexture(BaseGraphics.java:322)
	at com.sun.prism.d3d.D3DSwapChain.present(D3DSwapChain.java:32)
	at com.sun.javafx.tk.quantum.PaintRunnable.run(PaintRunnable.java:328)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
	at com.sun.prism.render.RenderJob.run(RenderJob.java:29)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at com.sun.javafx.tk.quantum.QuantumRenderer$ObservedRunnable.run(QuantumRenderer.java:67)
	at java.lang.Thread.run(Thread.java:662)

I've found something suspicious in PaintRunnable.run():
311                        disposePresentable();
312                        presentable = factory.createPresentable(scene.getPlatformView());
createPresentable() creates a SwapChain and a RTTexture, but disposePresentable() disposes SwapChain only.
Comments
Verified on 2.0.2b08.
16-11-2011

Changeset: 14621 (328a024ab99d) fix : RT-14739, RT-14430, RT-15961 - NPE in com.sun.prism.d3d.D3DSwapChain.prese
10-10-2011

This is very likely a related issue based on the stack trace. It might make sense to fix RT-15961 first since RT-14739 is extremely hard to reproduce.
13-09-2011

Targeting this for 2.0.2 and assigning it to Kirill for investigate.
13-09-2011

SQE - ok to defer. Please target to lombard, not update
26-08-2011

Pls target it to Lombard
25-08-2011

As this is no doubt an issue and should be fixed, the only way this will leak and be a problem is if the window is constantly resized. This is a perfect candidate for a presidio update imo.
24-08-2011

Joe added the texBackBuffer to D3DSwapChain, but did not override the dispose method to free it when the swap chain goes away. I'm reassigning to him for further evaluation...
16-08-2011

Updated the description -- sorry, lost it somehow while filing the issue.
15-08-2011

Is there a test case? Which resources leak? Is there any substance to this bug?
15-08-2011