300 ms × 20 times = 6000 ms, which exceeds the default TWDT timeout of 5000 ms. This will trigger the panic handler and cause a restart. Please check the TWDT documentation in the ESP-IDF or simply increase the timeout value to 7000 ms.