marimo-team/marimo

Marimo is unable to save to PNG for some (not all) notebooks

Opened this issue · 4 comments

Describe the bug

Saving to PNG fails for some notebooks.

The toaster appears with the error message, but no information is logged to the browser console - no errors, warnings, etc are added.

Environment

{
  "marimo": "0.9.16",
  "OS": "Linux",
  "OS Version": "5.15.0-124-generic",
  "Processor": "x86_64",
  "Python Version": "3.10.13",
  "Binaries": {
    "Browser": "--",
    "Node": "--"
  },
  "Dependencies": {
    "click": "8.1.7",
    "docutils": "0.21.2",
    "itsdangerous": "2.2.0",
    "jedi": "0.19.1",
    "markdown": "3.7",
    "narwhals": "1.13.2",
    "packaging": "24.1",
    "psutil": "6.1.0",
    "pygments": "2.18.0",
    "pymdown-extensions": "10.11.2",
    "pyyaml": "6.0.2",
    "ruff": "0.7.1",
    "starlette": "0.41.0",
    "tomlkit": "0.13.2",
    "typing-extensions": "4.12.2",
    "uvicorn": "0.32.0",
    "websockets": "12.0"
  },
  "Optional Dependencies": {
    "altair": "5.4.1",
    "pandas": "2.2.3",
    "pyarrow": "17.0.0"
  }
}

Code to reproduce

My guess is there's a failure in downloadByUrl here:

downloadByURL(dataUrl, Filenames.toPNG(filename));

But because there's no JS error emitted, I don't know exactly how to reproduce.

I've got a notebook with 2 Pandas DataFrames displayed and 4 Altair charts.

The DataFrames are displayed by returning the DF at the end of the cell as per https://docs.marimo.io/guides/working_with_data/dataframes.html#displaying-dataframes - so I'm assuming they're using mo.ui.table.

When I comment out the DataFrames, then the download works. When I switch to mo.plain(...) to render the DataFrames, then download works.

I don't think there's anything special about the DataFrames apart from they have a "large" number of columns - the first one is 37 columns, but the second one is a limited subset of columns aggregated.

Thanks for reporting. Are you able to get it to consistently fail? Are you able to share the code? It looks like chrome has a 2mb limit for what we are doing, but Firefox does not. What browser are you using? Can you try safari or Firefox?

Thanks for reporting.

NP 🫡

Are you able to get it to consistently fail?

Yes I think so - I was on Friday and I can check again today.

Are you able to share the code?

Not the exact notebook I have now because it's full of financials, but maybe I can find a way to strip it down.

It looks like chrome has a 2mb limit for what we are doing, but Firefox does not. What browser are you using?

Am on Firefox 132.

Can you try safari or Firefox?

Not sure what other browsers I can try with.

I think there are two possible avenues:

  1. See if it works in another browser, or
  2. Create a shareable notebook that fails.

Not sure what's best to push on.

If you can share a similar notebook, I can try in other browsers for you, and it will help us debug the issue.

Just some small updates here:

  • Able to reproduce this with latest 0.9.27.
  • Have had two more notebooks fail to render PNG.
  • Notebooks seem to need to have a "large" DataFrame in them to cause the failure. Previously I had "wide" data (more than 30 cols). This time I've got only 8 cols, but 1.2M rows.
  • The most recent notebook had a single piece of information shown from its big DataFrame - a single column description: round(df['samples_count'].describe(), 0) 👈🏻 Once I comment this out, the notebook can be rendered to PNG.
  • PNG failure happens whether the download is triggered from the burger menu or the ctrl-K palette.