UI bugs when running experimental_rerun


All my code is working as expected, with the only downside that when I experimental_rerun() this bug happens. idk if its a bug or what, but I guess it shouldnt be happening

[UPDATE]
I identified this bug happens the first time you run st.experimental_rerun(). Once it happens, if you refresh the website or F5, the site will continue to work but this bug wont happen again. But yeah you have to refresh it in order for that to disappear and thats something I need to solve.

I can only make some guesses since you haven’t shared any code, but Streamlit will “ghost” a previous page load while it is rerunning a page. If you have something like a while loop that is preventing Streamlit from getting to the end of you page script, you can end up with a persistent “ghost.” In this case, you have to manually wipe something clean to prevent Streamlit from holding on, waiting to see if it will be re-rendered before discarding it otherwise.

Try using an st.empty() container and manually emptying it before the rerun. You may need a small time.sleep(.5) after manually emptying and before the rerun as there is a little bug with st.empty().

I’ll try with st.empty, never used it but will give it a try

def ...
        ...

        with col2:
            self.separator(3)
            st.markdown(
                f"""markdown ...""",
                unsafe_allow_html = True        
            )

        while True:
            time.sleep(0.5)
            if self.data_handler.vars_changed:
                st.experimental_rerun()

Solved. Thanks!!!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.