Perhaps I found a solution for this.
I had the exact same problem and couldn’t understand what was going on for my life until:
I suggested that perhaps it was only the window screen that was frozen (visual rendering of the Android Studio program itself), and suggested that it might have used the DirectX device to render the Android UI.
My computer runs another application that uses a DirectX device for rendering (SimpleJungleTimer, the application I programmed with DirectX overlay for League of Legends jungle timers). After I turned off this application, Android Studio works fine (without freezing when working with the user interface)
In the end, it seems like this is a bug with Android studio itself, where they incorrectly kill / reboot the DirectX rendering device when it conflicts with another active DirectX device (which probably should be fixed by Android studio developers), however before as long as Android developers studio does not fix it, you can work around this problem by making sure that any other applications that can use DirectX for rendering, closed when encoding in Android studio, that they render the device does not conflict with DirectX Arrange Twomey Android Studio DirectX.
source share