I am observing a strange behavior with the multiselect widget and multipage apps, above a certain size of the list of options, the multiselect widget fails to restore saved values from the session state when switching pages.
I am including a full example illustrating this below (it’s a minimal example based on numbers requiring a fairly large list to cause the issue, but the limit I am hitting in real-life with text is around just 500 values).
Does anyone know what this is caused by and how to fix it? I tried enabling debug logging but couldn’t see any warnings / errors related to this.
Thanks!
home.py:
import streamlit as st
# restore widget state
st.session_state.update({k: st.session_state[k] for k in st.session_state})
st.write('# Home page')
# debug
st.write(st.session_state)
pages/page.py:
import streamlit as st
# restore widget state
st.session_state.update({k: st.session_state[k] for k in st.session_state})
st.write('# Second page')
# multiselect that fails to restore
st.multiselect('Choose some numbers and lose them when switching pages back and forth', list(range(50000)), key='some_key')
# multiselect that works
st.multiselect('Choose some numbers that get persisted properly', list(range(100)), key='some_key2')
# debug
st.write(st.session_state)
Here is a screenshot illustrating the first widget being out of sync with the session state: