question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

st_folium keeps reloading Streamlit page till page crashes

See original GitHub issue

Streamlit page keeps reloading every 3 seconds till it crashes. Now I use st_static that is not recommended ?

st_data = st_folium(m, key='map',width = 650, height = 600)

Any idea what is happening ?

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
blackarycommented, Jul 19, 2022

@PaulShin83 I don’t see that issue when I fun the following script with streamlit==1.11.0 and streamlit-folium==0.6.13

import streamlit as st
from streamlit_folium import st_folium
import folium

def draw_folium_map():
    center = [39.5, -98.5]
    tiles = ["cartodbpositron", "Stamen Toner", "OpenStreetMap"]
    map = folium.Map(
        location=[center[0], center[1]],
        zoom_start=10,
        zoom_control=True,
        scrollWheelZoom=False,
        tiles=tiles[0],
    )

    folium.Marker(
        location=[39.5, -98.5],
        popup=f"A location!",
        icon=folium.Icon(color="blue", icon="star"),
    ).add_to(map)

    return map


m = draw_folium_map()

output = st_folium(m, key="map", width=650, height=600)

st.write(output)

I know this isn’t exactly the same as your script, but I’m unable to run your exact example without the full script. It’s possible that the issue you’re encountering is related to something happening with session state (e.g. perhaps rendering the map -> updates session state -> rerendering the map -> …). Would you be able to share the full script, or a complete subset of it that shows the infinite-reload issue?

0reactions
blackarycommented, Dec 21, 2022

@tonkolviktor Thanks for sharing that example code! In this case, it seems to be behaving as expected – I don’t see it reloading over and over again. The “running guy” does trigger, but that is because the map is returning different values. If you want to avoid this, you can pass returned_objects=[] to st_folium, to make it return nothing (and essentially behave like folium_static. But, you can also still have it return some data if you want it to. If you want to avoid the “running guy”, the returned_objects=[] will always be available. I may even keep folium_static and simply make it call st_folium with that argument passed in. But, if there are cases where st_folium produces an infinite-rerun, I definitely want to fix those before changing folium_static to work that way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · randyzwitch/streamlit-folium - GitHub
Contribute to randyzwitch/streamlit-folium development by creating an account ... st_folium keeps reloading Streamlit page till page crashes.
Read more >
How to prevent the reloading of the whole page when I let the ...
Hello everyone, I am building a page which let the user to run a query against my database, once I have the data...
Read more >
Strange and Subtle Refresh Streamlit Bugs
Sometimes an entire streamlit app crashes unexpectedly and the page needs to be refreshed. This can happen either when entering input or ...
Read more >
Streamlit App Crashes Unexpectedly After First Successful ...
When I reload/rerun the webpage still does not fixes the issue. Moreover, when the application crashes it is unable to be recovered unless ......
Read more >
Avoiding refreshing the entire page when clicking a button
My issue right now is that when the user presses the button, the entire page reloads. I understand why this is the case...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found