Problems with interface after connecting to network

As suggested by @amirgon :

I’m trying to understand if this is related to rendering / screen refresh or to input device handling.
Please try to add some animation which is not triggered by an input device.
Then try to see if the animation behaves differently when WiFi is on/off.
If animation works fine with WiFi, that would narrow the problem to your input device (buttons/encoder)

I have done the following:

import gc
import lvgl as lv
from ili9341 import ili9341
import micropython

import network

disp = ili9341() # Create a display driver

def connect():
    ssid = "xxx"
    password =  "xxx"

    station = network.WLAN(network.STA_IF)

    if station.isconnected() == True:
        print("Already connected")
    station.connect(ssid, password)

    while station.isconnected() == False:

    print("Connection successful")


screen = lv.obj()

# Create a style for the Preloader
style = lv.style_t()
lv.style_copy(style, lv.style_plain)
style.line.width = 10                          # 10 px thick arc
style.line.color = lv.color_hex3(0x258)        # Blueish arc color

style.body.border.color = lv.color_hex3(0xBBB) # Gray background color
style.body.border.width = 10
style.body.padding.left = 0

# Create a Preloader object
preload = lv.preload(screen)
preload.set_size(100, 100)
preload.align(None, lv.ALIGN.CENTER, 0, 0)
preload.set_style(lv.preload.STYLE.MAIN, style)


At first look it is completely fine. I manage to connect to my wifi and then the preload ring refreshes as expected.

So I guess the problem is related with the input device handling…

Also I know I am connected to Wifi because I am using my phone as an hotspot and it says that the esp is connected. If I turn off my hotspot the ring keeps working. If I connect my hotspot again the esp connects to my network again (I can see that it is connected on my phone)