iOS 15 replace rootViewController failed while applicationDidBecomeActive

I need change the rootViewController while applicationDidBecomeActive called. So I use this kind of code to do this work and it works well before.  

 [UIApplication sharedApplication].keyWindow.rootViewController = newViewController;

But after upgrade to iOS 15, this will make the keyWindow lose the rootViewController and get a blank page. After serval try, I found it could work after delay 0.1 seconds.

iOS 15 replace rootViewController failed while applicationDidBecomeActive
 
 
Q