繁体   English   中英

java.lang.IllegalArgumentException:纹理必须为非空(CanvasJs 和 JavaFX)

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

我目前正在使用 JavaFX 和 CanvasJS 来显示图形

我有几个显示点的图表

我有 JS 变量,其中包含每个图形的点(您可以通过在 HTML 输入中输入值和日期来逐个修改点)

当点在 JS 点列表中被修改时,我只更新我们已经进行点修改的 Canvas

(我还尝试通过在每个 CanvasJS.Chart 实例上调用 render () function 来刷新所有画布)(之前我只在 JS 中使用全局变量来包含点现在当我更新图表时,点位于局部变量中我测试是否未定义以尝试不再出现错误)

但是,当我修改图形上的点时,它可以工作,但是当滚动并将点放在其他图形上时,出现以下错误:

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)

我的客户在修改点后滚动时出现此错误:

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)

在我看来,这些是已知错误: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8092801

我不明白如何解决它

我使用的Java的版本是jdk1.8.0_202(网站上说是从JDK 8u20版本开始修复的)(我的客户用8u281测试过,还是报错)

我的代码如下:

(这是更新图表的JS代码,其他图表的功能也是修改一个点的值然后更新他们的图表)

$(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();
}

你有想法吗?

发生错误是因为我显示的图像宽度较大

通过减小宽度,我和客户都不会出错

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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