Allow _UIPopupViewController to present itself in middleware scenarios.
A recent fix/change to UIViewController (75effb9) regressed one of our middleware scenarios. UIViewController now makes sure that one is presenting over a currently-visible ViewController. However, in middleware scenarios, that won't hold true, so we must loosen the check in such cases.
Fixes
#import <QuartzCore/CALayer.h>
#import <QuartzCore/CoreAnimationFunctions.h>
+#import "_UIPopupViewController.h"
+#import "CACompositor.h"
#import "UIApplicationInternal.h"
#import "UIEmptyView.h"
#import "UIViewInternal.h"
@@ -1167,10 +1169,17 @@ NSMutableDictionary* _pageMappings;
UIViewController* visibleParent = self;
bool shouldShow = false;
+
+ // We have a special case for our _UIPopupViewController in middleware scenarios; in such cases
+ // we won't have a visible parentViewController but we'll still want the present to succeed
+ if (GetCACompositor()->IsRunningAsFramework() && [self isKindOfClass:[_UIPopupViewController class]]) {
+ shouldShow = true;
+ } else {
do {
// Allow presentation only if an ancestor is not NotVisible.
shouldShow = visibleParent->priv->_visibility != controllerNotVisible;
} while (!shouldShow && (visibleParent = [visibleParent parentViewController]));
+ }
if (!shouldShow) {
TraceWarning(TAG, L"Controller is not visible!");
