There is an "android app not responding timeout" of 5 seconds.
https://developer.android.com/training/articles/perf-anr.html
This is also a problem of coding, if you run timeexpensive code inside codeareas handling the gfx, like building a window and so on. The whole window build process is waiting for this timeexpensive code and the system reacts at some point. This problem could be fixed if you separate the "build windows process" from the "timeexpensive code" using different threads (multithreading) and then let the window wait till the timeexpensive code is finished. Normaly you do something like "please wait ...". This is a problem of the modern programming. You can't put long running code in objects like a window without "separating" it.
Looks like your cpu is to slow to handle this problem fast enough? Can you stop some other running apps to give your cpu some help?