streamlit: `st.dataframe` crashes with maximum update depth exceeded

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

Updating tables on the sidebar makes the browser go crazy and eventually crash due to maximum update depth exceeded.

  • Browser is unresponsive
  • Adjusting the width of the sidebar makes the problem go away (sometimes)
  • Some tables just crash before even the first render
  • This has been happening for a while (min 3 months)

Screencast from 2024-01-12 11-38-00.webm

image

Reproducible Code Example

with st.sidebar:
  container = st.empty()

while True:
  container.dataframe(...)
  time.sleep(1)

Steps To Reproduce

No response

Expected Behavior

No response

Current Behavior

No response

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.2x
  • Python version: irrelevant
  • Operating System: irrelevant
  • Browser: blink

Additional Information

Error: Minified React error #185; visit https://reactjs.org/docs/error-decoder.html?invariant=185 for the full message or use the non-minified dev environment for full errors and additional helpful warnings. at fl (http://192.168.1.42:8501/static/js/main.3ab8e8d9.js:2:2251371) at xa (http://192.168.1.42:8501/static/js/main.3ab8e8d9.js:2:2223133) at http://192.168.1.42:8501/static/js/7673.0828a05e.chunk.js:2:334183 at http://192.168.1.42:8501/static/js/7673.0828a05e.chunk.js:2:349353 at http://192.168.1.42:8501/static/js/7673.0828a05e.chunk.js:2:293066 at http://192.168.1.42:8501/static/js/7673.0828a05e.chunk.js:2:293268 at http://192.168.1.42:8501/static/js/7673.0828a05e.chunk.js:2:289446 at http://192.168.1.42:8501/static/js/7673.0828a05e.chunk.js:2:289688 at Dl (http://192.168.1.42:8501/static/js/main.3ab8e8d9.js:2:2263107) at t.unstable_runWithPriority (http://192.168.1.42:8501/static/js/main.3ab8e8d9.js:2:3040959)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 39
  • Comments: 39

Commits related to this issue

Most upvoted comments

If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.

Your feedback helps us prioritize which bugs to investigate and address first.

Visits

Good news 🙌: After many hours of trying various things to reproduce this issue, I finally got to a setup that allows me to reproduce it in almost every rerun with a very specific setup: an old monitor set to a 1280 x 720 resolution, with the tab being zoomed out to 75%, and a script containing lots of dataframes with use_container_width=True & vertical scrolling in different containers (sidebar, columns, popover, tabs) 😅 Finally, there is some hope to fully fixing this soon 🙏

Thanks to everyone here for all the input! Especially to @ChojnackiKRZ & @oasalonen for the hints on the resolution.

Same issue, but I noticed one potential triggering condition that I didn’t see mentioned here yet:

The problem only occurs for me when I load the page on my external display. I don’t have access to my external monitor at the moment, and now I cannot reproduce the issue at all when loading it on my primary display (MacBook). Some weird interaction with primary/secondary display or different resolutions + use_container_width=True?

Specs:

  1. 14" MacBook Pro 2023
  2. External display: 27" 2560 x 1440 (iirc)
  3. Chrome browser

In my case this error was related to:

  • using st.container to store other objects like st.dataframe
  • having zoomed out browser window (80%) (user’s resolution 1366x768)
  • Chrome/Edge (did not check other browsers)
  • streamlit 1.38 Having those conditions in check I encountered error in code below if I refreshed app.
  1. Error generating app
import pandas as pd
import numpy as np
import streamlit as st
def load_data():
    df = pd.DataFrame(np.random.rand(100, 5), columns=[f'col_{i}' for i in range(1, 6)])
    
    # Add a categorical column with two categories 'A' and 'B'
    df['category'] = np.random.choice(['Category A', 'Category B'], size=len(df))
    
    # Add a date column with random dates between a given range
    date_range = pd.date_range(start='2023-01-01', end='2024-01-01', periods=len(df))
    df['random_dates'] = np.random.choice(date_range, size=len(df))
    return df

if __name__ == "__main__":
    df = load_data()
    container = st.container()
    container.dataframe(
        df,
        use_container_width=True
        )
  1. Slightly changed app without errors
import pandas as pd
import numpy as np
import streamlit as st

def load_data():
    df = pd.DataFrame(np.random.rand(100, 5), columns=[f'col_{i}' for i in range(1, 6)])
    
    # Add a categorical column with two categories 'A' and 'B'
    df['category'] = np.random.choice(['Category A', 'Category B'], size=len(df))
    
    # Add a date column with random dates between a given range
    date_range = pd.date_range(start='2023-01-01', end='2024-01-01', periods=len(df))
    df['random_dates'] = np.random.choice(date_range, size=len(df))
    return df

if __name__ == "__main__":
    df = load_data()
    st.dataframe(
        df,
        use_container_width=True
        )
  1. Pip list:
pip list
Package                    Version
-------------------------- -----------
altair                     5.4.0
asn1crypto                 1.5.1
asttokens                  2.4.1
attrs                      24.2.0
blinker                    1.8.2
cachetools                 5.5.0
certifi                    2024.7.4
cffi                       1.17.0
charset-normalizer         3.3.2
click                      8.1.7
cloudpickle                2.2.1
colorama                   0.4.6
comm                       0.2.2
cryptography               43.0.0
debugpy                    1.8.5
decorator                  5.1.1
exceptiongroup             1.2.2
executing                  2.0.1
filelock                   3.15.4
gitdb                      4.0.11
GitPython                  3.1.43
idna                       3.7
ipykernel                  6.29.5
ipython                    8.26.0
jedi                       0.19.1
Jinja2                     3.1.4
jsonschema                 4.23.0
jsonschema-specifications  2023.12.1
jupyter_client             8.6.2
jupyter_core               5.7.2
markdown-it-py             3.0.0
MarkupSafe                 2.1.5
matplotlib-inline          0.1.7
mdurl                      0.1.2
narwhals                   1.5.3
nest-asyncio               1.6.0
numpy                      2.1.0
packaging                  24.1
pandas                     2.2.2
parso                      0.8.4
pillow                     10.4.0
pip                        22.0.4
platformdirs               4.2.2
prompt_toolkit             3.0.47
protobuf                   5.27.3
psutil                     6.0.0
pure_eval                  0.2.3
pyarrow                    17.0.0
pycparser                  2.22
pydeck                     0.9.1
Pygments                   2.18.0
PyJWT                      2.9.0
pyOpenSSL                  24.2.1
python-dateutil            2.9.0.post0
pytz                       2024.1
pywin32                    306
PyYAML                     6.0.2
pyzmq                      26.2.0
referencing                0.35.1
requests                   2.32.3
rich                       13.7.1
rpds-py                    0.20.0
setuptools                 58.1.0
six                        1.16.0
smmap                      5.0.1
snowflake-connector-python 3.12.1
snowflake-snowpark-python  1.21.0
sortedcontainers           2.4.0
spyder-kernels             2.5.2
stack-data                 0.6.3
streamlit                  1.38.0
streamlit-sortables        0.2.0
tenacity                   8.5.0
toml                       0.10.2
tomlkit                    0.13.2
tornado                    6.4.1
traitlets                  5.14.3
typing_extensions          4.12.2
tzdata                     2024.1
urllib3                    2.2.2
watchdog                   4.0.2
wcwidth                    0.2.13
wheel                      0.44.0
  1. Python 3.10.5
  2. App behaviour

https://github.com/user-attachments/assets/4fd745bf-8d76-4089-bbc2-959bb3176d29

getting this error in version 1.37

df_error I also experience the error in version 1.33 when I display a dataframe and use st.columns(). I randomly get the error message. When rerunning it sometimes disappears and sometimes not. I have experienced this error in 1.31 1.32 versions but not in 1.30.

I have the same problem on streamlit version 1.36.0

I can’t share my actual code, but it is a dataframe displayed in a container, in a tab, in a column, something like this:

column_1, column_2 = st.columns(2)
tab_a, tab_b, tab_c, tab_d = column_2.tabs("a", "b", "c", "d")
for df in dfs:  # dfs are different columns of a much wider dataframe
  styled_df = df.style.apply(style, axis=1)  # applying a style by row
  container = tab_a.container
  # table_height is calculated from a select_box shown below the table, which is why the dataframe is in a container
  container.dataframe(styled_df, use_container_width=True, hide_index=True, height=table_height)

The error only occurs for the dataframe in tab_a. The error only occurs when the site is deployed, ie not when running locally. The error only occurs when an option to hide a few other arbitrary containers (st.markdown and st.tabs) is checked, i.e. the dataframe displays correctly when the site launches, but breaks after a user interaction with another element.

The dataframes are similar, but not exactly the same. The dataframes all have 59 rows. The dataframe in tab_a and tab_d has 6 columns. The dataframe in tab_b has 1 column, and the dataframe in tab_c has 3 columns. They all contain variants of the same or related data, i.e. the first column (a pseudo index column) is the same in all four dataframes. The dataframe in tab_a has one styling component (a few values in one column can be colored) that is not applied to the other three dataframes.

It is difficult to troubleshoot the issue because it doesn’t occur locally, and I have no access to the server it is deployed on at the moment.

@aYoHoldings Do you have more information on what kind of custom CSS styling you applied?

@LukasMasuch Unfortunately this problem still occurs randomly. So I guess it has nothing to do with CSS Styling

@nemeskolos Thanks for reporting this. We have seen this issue appear by one other user with the current version and I created an issue on that yesterday in the upstream library here: glideapps/glide-data-grid#941

Unfortunately, we don’t have an example yet that allows us to reproduce this issue consistently. Would it be possible for you to share your code?

Do you use use_container_width=True with those dataframes? We believe the issue is connected to this feature; turning it to False might resolve it. Can you check this in your app? And you are using the normal layout or? not the wide layout?

Yes I use wide layout and I use “use_container_width=True” too. I met this problem if I use: st.dataframe, st.write(a dataframe) or st.data_editor.

@LukasMasuch yes, Wide layout:

st.set_page_config(
    layout="wide"
)

Dataframe is not in a st.column, but within an an st.tabs.

I’m on Chrome Version 123.0.6312.105 (Official Build) (32-bit)

Hey @knoopx and @stefano-brambilla-853558,

Just wanted to follow up that the updates are live as of the latest release 1.32.2. 🥳

Thanks for your valuable input and feedback!

hi, I’m still getting this error with streamlit=1.31.0 Any suggestion on how to proceed?