Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.

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

@TGiebel

Description

@TGiebel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions