简体   繁体   中英

java.lang.IllegalArgumentException: Texture must be non-null (CanvasJs and JavaFX)

I am currently using JavaFX and CanvasJS to display graphics

I have several charts that show dots

I have JS variables which contain the points of each graph (you can modify a point one by one by entering a value and a date in an HTML input)

When the point is modified in the list of JS points I update only the Canvas on which we have made a point modification

(I also tried refreshing all the Canvases by calling the render () function on each of the CanvasJS.Chart instances) (Before I only used global variables in JS to contain the points Now when I update a graph the points are in a local variable that I test if undefined to try not to have the error anymore)

However when I modify the points on a graph it works but when scrolling and putting the dots on other graphics I have the following error:

java.lang.NullPointerException
    at com.sun.prism.d3d.D3DTexture.getContext(D3DTexture.java:84)
    at com.sun.prism.d3d.D3DTexture.update(D3DTexture.java:207)
    at com.sun.prism.d3d.D3DTexture.update(D3DTexture.java:151)
    at com.sun.prism.impl.BaseContext.flushMask(BaseContext.java:112)
    at com.sun.prism.impl.BaseContext.drawQuads(BaseContext.java:121)
    at com.sun.prism.impl.VertexBuffer.flush(VertexBuffer.java:98)
    at com.sun.prism.impl.BaseContext.flushVertexBuffer(BaseContext.java:104)
    at com.sun.prism.impl.ps.BaseShaderContext.setRenderTarget(BaseShaderContext.java:753)
    at com.sun.prism.impl.BaseContext.setRenderTarget(BaseContext.java:146)
    at com.sun.prism.impl.BaseGraphics.<init>(BaseGraphics.java:106)
    at com.sun.prism.impl.ps.BaseShaderGraphics.<init>(BaseShaderGraphics.java:86)
    at com.sun.prism.d3d.D3DGraphics.<init>(D3DGraphics.java:42)
    at com.sun.prism.d3d.D3DGraphics.create(D3DGraphics.java:65)
    at com.sun.prism.d3d.D3DRTTexture.createGraphics(D3DRTTexture.java:77)
    at com.sun.prism.d3d.D3DResourceFactory.createRTTexture(D3DResourceFactory.java:316)
    at com.sun.prism.d3d.D3DResourceFactory.createRTTexture(D3DResourceFactory.java:270)
    at com.sun.prism.d3d.D3DResourceFactory.createRTTexture(D3DResourceFactory.java:63)
    at com.sun.javafx.webkit.prism.WCGraphicsPrismContext$Layer.<init>(WCGraphicsPrismContext.java:1367)
    at com.sun.javafx.webkit.prism.WCGraphicsPrismContext$ClipLayer.<init>(WCGraphicsPrismContext.java:1442)
    at com.sun.javafx.webkit.prism.WCGraphicsPrismContext$ClipLayer.<init>(WCGraphicsPrismContext.java:1435)
    at com.sun.javafx.webkit.prism.WCGraphicsPrismContext.setClip(WCGraphicsPrismContext.java:328)
    at com.sun.webkit.graphics.GraphicsDecoder.decode(GraphicsDecoder.java:224)
    at com.sun.webkit.graphics.WCRenderQueue.decode(WCRenderQueue.java:92)
    at com.sun.webkit.graphics.WCRenderQueue.decode(WCRenderQueue.java:103)
    at com.sun.webkit.graphics.WCRenderQueue.decode(WCRenderQueue.java:110)
    at com.sun.webkit.graphics.GraphicsDecoder.decode(GraphicsDecoder.java:348)
    at com.sun.webkit.graphics.WCRenderQueue.decode(WCRenderQueue.java:92)
    at com.sun.webkit.WebPage.paint2GC(WebPage.java:741)
    at com.sun.webkit.WebPage.paint(WebPage.java:708)
    at com.sun.javafx.sg.prism.web.NGWebView.renderContent(NGWebView.java:96)
    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2053)
    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1945)
    at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:235)
    at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:577)
    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2053)
    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1945)
    at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:477)
    at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:330)
    at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
    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:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
    at java.lang.Thread.run(Thread.java:748)

My client has this error when scrolling after modifying points:

java.lang.IllegalArgumentException: Texture must be non-null
    at com.sun.scenario.effect.impl.prism.PrTexture.<init>(PrTexture.java:38)
    at com.sun.scenario.effect.impl.prism.PrDrawable.<init>(PrDrawable.java:44)
    at com.sun.scenario.effect.impl.prism.ps.PPSDrawable.<init>(PPSDrawable.java:39)
    at com.sun.scenario.effect.impl.prism.ps.PPSDrawable.create(PPSDrawable.java:60)
    at com.sun.scenario.effect.impl.prism.ps.PPSRenderer.createCompatibleImage(PPSRenderer.java:163)
    at com.sun.scenario.effect.impl.prism.ps.PPSRenderer.createCompatibleImage(PPSRenderer.java:67)
    at com.sun.scenario.effect.impl.ImagePool.checkOut(ImagePool.java:183)
    at com.sun.scenario.effect.impl.Renderer.getCompatibleImage(Renderer.java:116)
    at com.sun.scenario.effect.impl.prism.ps.PPSRenderer.getCompatibleImage(PPSRenderer.java:168)
    at com.sun.scenario.effect.impl.prism.ps.PPSRenderer.getCompatibleImage(PPSRenderer.java:67)
    at com.sun.scenario.effect.Effect.getCompatibleImage(Effect.java:479)
    at com.sun.javafx.webkit.prism.WCGraphicsPrismContext$ClipLayer.render(WCGraphicsPrismContext.java:1466)
    at com.sun.javafx.webkit.prism.WCGraphicsPrismContext.renderLayer(WCGraphicsPrismContext.java:203)
    at com.sun.javafx.webkit.prism.WCGraphicsPrismContext.restoreStateInternal(WCGraphicsPrismContext.java:220)
    at com.sun.javafx.webkit.prism.WCGraphicsPrismContext.restoreState(WCGraphicsPrismContext.java:234)
    at com.sun.webkit.graphics.GraphicsDecoder.decode(GraphicsDecoder.java:221)
    at com.sun.webkit.graphics.WCRenderQueue.decode(WCRenderQueue.java:92)
    at com.sun.webkit.graphics.WCRenderQueue.decode(WCRenderQueue.java:103)
    at com.sun.webkit.graphics.WCRenderQueue.decode(WCRenderQueue.java:110)
    at com.sun.webkit.graphics.GraphicsDecoder.decode(GraphicsDecoder.java:348)
    at com.sun.webkit.graphics.WCRenderQueue.decode(WCRenderQueue.java:92)
    at com.sun.webkit.WebPage.paint2GC(WebPage.java:741)
    at com.sun.webkit.WebPage.paint(WebPage.java:708)
    at com.sun.javafx.sg.prism.web.NGWebView.renderContent(NGWebView.java:96)
    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2053)
    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1945)
    at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:235)
    at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:577)
    at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2053)
    at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1945)
    at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:477)
    at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:330)
    at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
    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:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
    at java.lang.Thread.run(Thread.java:748)
java.lang.AssertionError: java.util.concurrent.ExecutionException: java.lang.NullPointerException
    at com.sun.javafx.webkit.prism.PrismInvoker.runOnRenderThread(PrismInvoker.java:91)
    at com.sun.javafx.webkit.prism.RTImage.getPixelBuffer(RTImage.java:162)
    at com.sun.webkit.WebPage.twkProcessMouseEvent(Native Method)
    at com.sun.webkit.WebPage.dispatchMouseEvent(WebPage.java:814)
    at javafx.scene.web.WebView.processMouseEvent(WebView.java:1045)
    at javafx.scene.web.WebView.lambda$registerEventHandlers$32(WebView.java:1168)
    at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
    at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
    at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
    at javafx.event.Event.fireEvent(Event.java:198)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
    at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
    at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:394)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$358(GlassViewEventHandler.java:432)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:431)
    at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
    at com.sun.glass.ui.View.notifyMouse(View.java:937)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$152(WinApplication.java:177)
    at java.lang.Thread.run(Thread.java:748)

It seems to me these are known errors: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8092801

I don't understand how to fix it though

The version of Java I am using is jdk1.8.0_202 (it is indicated on the site that it is fixed from version JDK 8u20) (My client tested with the 8u281 and he still had the error)

My code is the following:

(This is the JS code for Updating a chart, The functions of the other graphs also modify the value of a point then update their graph)

$(document).on('click','.modifValue1', function()
{
    var dateValue1 = $('input[name="dateValue1"]').val();
    var value1 = parseFloat($('input[name="value1"]').val().replace(",", "."));

    // Dans modifyValue1, on parcoure la liste de points
    // et on modifie le point à la date
    dataValue1Json = modifyValue1(valueGlobalAllPointGraph1, dateValue1, value1);

    displayValue1Json(dataValue1Json);
});

// To update graphe 1
function displayValue1Json(value1){

// As there is a NullPointer error
if(value1 === undefined){
    return;
}

   var chartValue1 = new CanvasJS.Chart("chartContainerValue1",
        {
            zoomEnabled: true,
            legend:
            {
                verticalAlign : 'top',
                horizontalAlign : 'right',
            },
            axisX:{
                valueFormatString: "MM-YYYY" ,
                labelAngle: -50,
                labelFontColor: "black",
                title: "temps",
                gridColor: "#d2d2d2",
                gridThickness: 1
            },
            axisY: {
                labelFontColor: "#328fe1",
                title: "valeur",
                titleFontColor: "#328fe1",
                lineColor: "#328fe1",
                valueFormatString: "####",
                gridColor: "#d2d2d2",
                includeZero: false,
                valueFormatString: "0.00",
            },
            data: [
            {
                type: "line",
                click: onClickPointNullGraph,
                connectNullData: false,
                legendText: "value1",
                    showInLegend: true,
                color: "#328fe1",
                markerSize:3,
                dataPoints:value1
            }
            ]
        });

    chartValue1.render();

    $('div#chargementPage').fadeOut();
}

Do you have an idea?

The error occurred because the images I displayed had a large width

By reducing the width, neither I nor the customer have an error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM