Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This override code may frozen screen in iOS 15+ when requestReview for Apple. #143

Open
doubleLLL3 opened this issue Mar 27, 2022 · 2 comments

Comments

@doubleLLL3
Copy link

This override code is in CocoaDebug+Extensions.swift:

open override var canBecomeFirstResponder: Bool { 
    return true 
}

When requestReview for Apple in iOS 15+, like this:

if (@available(iOS 14.0, *)) {
    UIWindowScene *activeScene;
    NSSet<UIScene *> *scenes = [[UIApplication sharedApplication] connectedScenes];
    for (UIScene *scene in scenes) {
        if ([scene activationState] == UISceneActivationStateForegroundActive) {
            activeScene = (UIWindowScene *)scene;
            break;
        }
    }
    if (activeScene != nil) {
      [SKStoreReviewController requestReviewInScene:activeScene];
    }
} else if (@available(iOS 10.3, *)) {
    [SKStoreReviewController requestReview];
}

For iOS 15+, App can perceive the user's interaction on the Review View and make its window (SkstoreReViewPresentationWindow) keyWindow, while App is not perceived before iOS 15.

So in iOS 15.0+, after Clicking on the Review View, the override code in CocoaDebug would make its Window the FIRST responder after becoming the keyWindow.

That causes the windows below never be a responder, so the screen freezes, because the size of SkstoreReViewPresentationWindow is FULL screen.


At last, I'm curious about the reason of the override code(maybe Prevent users from careless?), is this necessary?

@philosopherdog
Copy link
Contributor

This code is there to handle the shake gesture. So you're sure this is what's causing your app to freeze only in iOS 15? You might have to fork the project and put an exception for iOS 15 in that line when the SkstoreReViewPresentationWindow is on screen. The other option is you could only show the alert in production builds and since cocoadebug should not be included it won't cause an issue. That's all I can think of without running the code and trying some other things.

@doubleLLL3
Copy link
Author

Yes, it's only in iOS 15+.
Indeed, I changed the code like below:

// old
open override var canBecomeFirstResponder: Bool {
    return true
}

// new
open override var canBecomeFirstResponder: Bool {
    // Adapted to requestReview in iOS 15+
    if #available(iOS 15, *), NSStringFromClass(type(of: self)) == "SKStoreReviewPresentationWindow" {
        return false
    }
    return true
}

And also, it's ok in live production.

Thanks for your reminder~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants