Why does the app always show that the device is offline, and how does it automatically recover in a second or two?

It may be resulted from your phone performance. Generally, phones running on iOS are not likely to have such an issue, while some low-performance Android phones may have. If the app has not been launched for a long time, it needs to connect with the cloud when you log in again, so the device is displayed as offline. As the app is temporarily not connected with the device, it is not actually offline. It is a normal phenomenon, and you don't have to worry about it. Just like many apps require to buffer for a few seconds before displaying content, which is actually a process of connecting to the cloud. This may be also resulted from your phone performance and Internet connection.