queryverse / VegaLite.jl

Julia bindings to Vega-Lite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CanvasRenderer is missing a valid canvas or context

asbisen opened this issue · comments

I have been encountering the following error on JupyterLab.

Error: CanvasRenderer is missing a valid canvas or context
    at Object.error (/Users/abisen/.julia/artifacts/203c668d73758a923ae6d97087db83ab1938bea8/node_modules/vega-util/build/vega-util.js:36:11)
    at CanvasRenderer.resize (/Users/abisen/.julia/artifacts/203c668d73758a923ae6d97087db83ab1938bea8/node_modules/vega-scenegraph/build/vega-scenegraph.js:4842:28)
    at CanvasRenderer.initialize (/Users/abisen/.julia/artifacts/203c668d73758a923ae6d97087db83ab1938bea8/node_modules/vega-scenegraph/build/vega-scenegraph.js:4450:19)
    at CanvasRenderer.initialize (/Users/abisen/.julia/artifacts/203c668d73758a923ae6d97087db83ab1938bea8/node_modules/vega-scenegraph/build/vega-scenegraph.js:4832:32)
    at initializeRenderer (/Users/abisen/.julia/artifacts/203c668d73758a923ae6d97087db83ab1938bea8/node_modules/vega-view/build/vega-view.js:646:14)
    at renderHeadless (/Users/abisen/.julia/artifacts/203c668d73758a923ae6d97087db83ab1938bea8/node_modules/vega-view/build/vega-view.js:760:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async View.renderToCanvas [as toCanvas] (/Users/abisen/.julia/artifacts/203c668d73758a923ae6d97087db83ab1938bea8/node_modules/vega-view/build/vega-view.js:792:15)

Encountering this on 1.8.4 and 1.9.0 on Safari & FireFox (macOS). Below is the MWE that throws this error

using VegaLite
using DataFrames

df = DataFrame(x=rand(10), y=rand(10))
df |> @vlplot(:point, x="x", y="y")

JupyterLab is installed via pyenv (python version 3.11.3)

Are you on an Mac M1/2 system?

If so, I think I know what is actually happening: previously I used Node 12, and on M Macs it used the x86 version of it. Now I updated to Node 18, where it is using the M1/2 build of Node. One thing we need for all of this to work is the node-canvas package, which has binary dependencies. As it turns out, they don't provide prebuilt binaries for Mac M systems yet... So right now we are not shipping a working version of node-canvas for M Macs, and so all the PNG and PDF exports can't work.

For now I'm trying to fix this by reverting back to Node 12. Medium term plan is to try to get node-canvas to ship prebuilt binaries for the new Macs. I think primarily we need to find some M1 machine that can be added as a GitHub runner, until GitHub provides hosted M1 runners...

I tagged new versions for VegaLite.jl and Vega.jl, can you try with them? I think this should be fixed now, hopefully.

Correct I am using M1/M2 on Mac. And just tried the new update and it seems to have fixed the issue.

Great! And just for completeness: I’m using Node 18 now, but the x64 build on all Macs.