How to kill UIKeyboradWindowScene after closing SFSafariViewController?

When I launched my application, in debug view hierarchy there was only UIWindowScene - (Foreground active).

I loaded a webpage using the following code:


    NSURL *url = [[NSURL alloc] initWithString: @"https://apple.com"];
    SFSafariViewController *view = [[SFSafariViewController alloc] initWithURL:url];

    [self presentViewController:view
                       animated:YES
                     completion:^{
        NSLog(@"Successfully opened web browser for %@ action.", @"sample");
    }];


Then closed the webpage using "Done" option. Now, in the debug view hierarchy there are two window scenes. They are

1. UIWindowScene - (Foreground active)

2. _UIKeyboardWindowScene- (Foreground active).

Is this a bug of SFSafariviewController? How to fix this problem, please? It is blocking our toaster view in the application.


P.S. If I use WKWebView, then the second window scene does not exist in the debug view hierarchy.

We have a similar problem.


We noticed because after our app shows the user content in SFSafariViewController and the user navigates back to the original scene, all user touches are ignored by the original scene even though it is visible.


I discovered that during this bad condition the view debugger shows 2 active windows: A UIWindowScene that contains the scene the user should be interacting with and _UIKeyboardWindowScene. Both of these top level objects in the view heirarchy are listed as "Foreground Active". When things are working only the main UIWindowScene is listed in the view debugger.


My guess is that _UIKeyboardWindowScene is stealing all user input even tho it is not visible.


How to trigger this condition:

  1. Top level scene A in our app
  2. User taps button
  3. A presents sheet modal scene B
  4. User taps button
  5. B presents SFSafariViewController
  6. SFSafariViewController page loads
  7. User taps compass icon
  8. SFSafariViewController opens page in Safari app
  9. Page loads in Safari app
  10. User taps navigate back button in upper left
  11. iOS navigated from Safari app back to our app
  12. User taps Done
  13. Dismiss SFSafariViewController
  14. User taps Done
  15. Dismiss sheet modal B
  16. User attempts to tap on buttons in A
  17. Scene A never receives user touches
How to kill UIKeyboradWindowScene after closing SFSafariViewController?
 
 
Q