Hi,
Immediately after integrating interstitials using the Google-Mobile-Ads-SDK (7.31.0), we have started seeing similar crashes in our iOS app. Similar to the original poster, we cannot reproduce this issue ourselves. However, I might be able to provide some additional information that could prove useful. Crashlytics is reporting the following:
[UIViewController __supportedInterfaceOrientations]
Fatal Exception: UIApplicationInvalidInterfaceOrientation
Supported orientations has no common orientation with the application, and [GADInterstitialViewController shouldAutorotate] is returning YES
This is indeed true, because we do the following in our AppDelegate.swift:
var allowLandscape = false
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
// In the target configuration of this project, only portrait is selected.
// This ensures that the app can only launch into portrait. From there, this method is used.
if allowLandscape {
return .allButUpsideDown
}
return .portrait
}
func applicationWillResignActive(_ application: UIApplication) {
allowLandscape = false
}
func applicationDidBecomeActive(_ application: UIApplication) {
allowLandscape = true
}
The reasoning is that the app should never be allowed to enter the foreground in landscape mode. Once the app is running, there are situations in which the app will allow landscape mode (e.g. when an AVPlayer tries to go full screen). Due to a complex view controller hierarchy, there appears to be no way for us to avoid this approach.
Furthermore, our crash logs tell us two things:
1) Crashlytics puts 75% of these crashes in the background state of the app (so likely, these crashes happen shortly before or shortly after entering foreground)
2) In each case, the OS orientation is listed as landscape when the crash happens
Putting all of this together, it seems like the issue is occuring when entering the foreground of an app in landscape mode after having launched it previously. In our case, it seems like Admob is trying to show an interstitial BEFORE `applicationDidBecomeActive` is called, which means our AppDelegate will only support the portrait orientation, which conflicts with Admob's intention of showing a landscape interstitial (because that's the OS orientation).