Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: clearing st.session_state when height of canvas < 300 #141

Open
TGiebel opened this issue Oct 12, 2023 · 0 comments
Open

Bug: clearing st.session_state when height of canvas < 300 #141

TGiebel opened this issue Oct 12, 2023 · 0 comments

Comments

@TGiebel
Copy link

TGiebel commented Oct 12, 2023

There seems to be a a weired bug when using the st_canvas:
Minimal example:

import streamlit as st
from streamlit_drawable_canvas import st_canvas

if "Foo" not in st.session_state:
    st.session_state["Foo"] = "Value"

ResCanvas = st_canvas(height=299)

print(st.session_state["Foo"])

Behavior:

When running the above code using streamlit run xxx.py it raises an KeyError: 'Foo'.
This only happens for height values below 300.
The code is run 4 times by streamlit and in one of the 4 runs the st.session state is empty when printed after the canvas initialization while it is not empty right before calling it.
However this does not occure every time you run it but in about 3/4 of the time.

Expected behavior:

It should print the value "Value" of Foo each time with no errors.

Environment:

It can be observed on both, Ubuntu 20.04 LTS and Windows 11
Python: 3.9.17
streamlit==1.27.2
streamlit-drawable-canvas==0.9.3

If more information is needed hit me up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant