簡體   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