gradio-app / gradio

Build and share delightful machine learning apps, all in Python. ๐ŸŒŸ Star to support our work!
http://www.gradio.app
Apache License 2.0
34.22k stars 2.6k forks source link

FrontEnd error when creating a Plot inside gr.render #9330

Open oscaracena opened 2 months ago

oscaracena commented 2 months ago

Describe the bug

There is an uncaught exception in the front end (JavaScript) when a plot is created inside a gr.render decorated function. After that, the whole interface becomes unresponsive.

Have you searched existing issues? ๐Ÿ”Ž

Reproduction

import pandas as pd
import gradio as gr

with gr.Blocks() as demo:
    btn = gr.Button("Press Me")

    @gr.render(triggers=[btn.click])
    def create_plot():
        gr.LinePlot(pd.DataFrame(
            {"x": [1, 2, 3], "y": [1, 2, 3]}), x="x", y="y")

demo.launch()

Screenshot

No response

Logs

This is the stacktrace of the JavaScript console:

Index.svelte:136 Uncaught (in promise) TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.
    at r.$$.update (Index.svelte:136:33)
    at update (svelte.js:2157:6)
    at flush (svelte.js:2121:5)

System Info

Gradio Environment Information:
------------------------------
Operating System: Linux
gradio version: 4.43.0
gradio_client version: 1.3.0

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
anyio: 3.7.1
fastapi: 0.112.4
ffmpy: 0.4.0
gradio-client==1.3.0 is not installed.
httpx: 0.24.1
huggingface-hub: 0.24.6
importlib-resources: 6.4.5
jinja2: 3.1.3
markupsafe: 2.1.3
matplotlib: 3.5.1
numpy: 1.23.5
orjson: 3.10.7
packaging: 23.1
pandas: 2.1.1
pillow: 9.0.1
pydantic: 2.5.3
pydub: 0.25.1
python-multipart: 0.0.9
pyyaml: 5.4.1
ruff: 0.6.4
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.12.5
typing-extensions: 4.9.0
urllib3: 2.1.0
uvicorn: 0.30.6
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.

gradio_client dependencies in your environment:

fsspec: 2023.6.0
httpx: 0.24.1
huggingface-hub: 0.24.6
packaging: 23.1
typing-extensions: 4.9.0
websockets: 11.0.3

Severity

Blocking usage of gradio

zhuchaokn commented 2 months ago

Also met this problem in gradio 4.44.0.

Atlas8008 commented 1 month ago

I also noticed something similar. While I'm not using the render decorator, I also have the same problem (unresponsive interface) when using any kind of plot (BarPlot and LinePlot in my case) in a gr.Blocks-setup.

The error occurs from 4.43 onwards and even on 5.0.1, but did not occur in version 4.42.

justintemps commented 4 weeks ago

I have the same issue as @Atlas8008 with gradio@5.4.0