White screen while switching to different tabs

Hi ,
I have a Streamlit app which displays white screen while switching between tabs. The problem is it doesn’t raise an error while this happens. The issue doesn’t occur every time but it does occur often.
When the white screen does occur ,many a times it doesn’t reoccur if i refresh the page and try to access the tab again.
The app is deployed in AWS ec2 instance and the issue does occur in local too.
The issue started only after we started using streamlit authenticator (streamlit-authenticator · PyPI) for authentication and even after updating the module the issue still occurs.
What could be the reason and has anyone else have faced the same after integrating streamlit authenticator in there project ?

1 Like

Hi @Sidharth_V,

Thanks for sharing this question!

Are you able to share your code or a boilerplate example to replicate the issue?

Also, if you remove the authenticator code, does the issue resolve or persist?

2 Likes

Hi @tonykip ,

Thanks for the reply,

I removed the authenticator code and as suspected, i couldn’t encounter a single white screen. This was tested for the last 2 days , hence it might be safe to say that this is what’s causing the issue.

The code for streamlit authenticator can be found below,

def authenticate():

    with open(get_path('config.yaml')) as file:
        config = yaml.load(file, Loader=SafeLoader)

    authenticator = stauth.Authenticate(
        config['credentials'],
        config['cookie']['name'],
        config['cookie']['key'],
        config['cookie']['expiry_days']
        )

    name, authentication_status, username = authenticator.login(fields={'Form name': 'Login'}, location='main')

    if authentication_status:
        authenticator.logout(button_name='Logout', location='sidebar')    
    elif authentication_status == False:
        st.error('Username/password is incorrect')
    elif authentication_status == None:
        st.warning('Please enter your username and password')

    return name, authentication_status, username

if __name__=="__main__":
    name, authentication_status, username = authenticate()

    if authentication_status:   
        data = read_data()
   
  #admin_users  contains list of usernames with admin access
  #admin_acces contains tabs in sidebar that can be accessed by admin users
   if username in admin_users:
            access = admin_access
   #According to the username access to each tab is given

PFB the config.yaml

credentials:
  usernames:
    test:
      name : Test
      password : $2b$12$42/9Q09mV/psvuDFPuO/SONrYtGtcMEw/v4KFgXWRYwitwYW1MN3q 
cookie:
  expiry_days: 30
  key: random_signature_key # Must be string
  name: random_cookie_name
# preauthorized:
#   emails:
#   - melsby@gmail.com