Fig.write_image not waiting for map to render completely

Hey guys when I am using this code, the annotated text is not able to be completely rendered before the image is generated by plotly.

fig.write_image(f'ethnicity_distribution.svg',width=1200, height=800)

These are my annotations that are on the map. Doing a custom screenshot using a headless browser works but it’s random and I have to add my own await time in it. Is there an inbuilt way?

#Annotations for pie % 
for index, row in full_df.iterrows():
    text_pos = row.orientation

    # Create a scattermapbox trace for each point
    pie_slice_text = go.Scattermapbox(
        #lat=[row.pie_slice.centroid.y],
        #lon=[row.pie_slice.centroid.x],
        lat=[row.annotation_point.y],
        lon=[row.annotation_point.x],
        mode='markers+text',
        text=[f"{row['value']:.0%}"],
        textposition=text_pos,
        textfont=dict(color='black'),
        #textfont=dict(color=category_colors.get(row.region, 'black')),
        marker=dict(size=0),
        showlegend=False,
    )
    
    # Add the trace to the figure
    fig.add_trace(pie_slice_text)

hi @Sim
Can you please share a minimal reproducible example (MRE) so we can run it on our computer and reproduce the error you’re getting?