<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - UIViewController with WKWebView presented modally causes the presented UIViewController to be dismissed."
   href="https://bugs.webkit.org/show_bug.cgi?id=165225#c26">Comment # 26</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - UIViewController with WKWebView presented modally causes the presented UIViewController to be dismissed."
   href="https://bugs.webkit.org/show_bug.cgi?id=165225">bug 165225</a>
              from <span class="vcard"><a class="email" href="mailto:bwright2&#64;apple.com" title="Brad Wright &lt;bwright2&#64;apple.com&gt;"> <span class="fn">Brad Wright</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=165225#c25">comment #25</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=303130&amp;action=diff" name="attach_303130" title="Patch">attachment 303130</a> <a href="attachment.cgi?id=303130&amp;action=edit" title="Patch">[details]</a></span>
&gt; Patch
&gt; 
&gt; View in context:
&gt; <a href="https://bugs.webkit.org/attachment.cgi?id=303130&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=303130&amp;action=review</a>
&gt; 
&gt; &gt; Source/WebKit2/UIProcess/ios/forms/WKFileUploadPanel.mm:391
&gt; &gt; +    // dismiss any viewController that is being presented. This is works all VC, popovers, etc.</span >

This is works for all VC.  Missed the for, in the comment.
<span class="quote">&gt; 
&gt; Normally we would want to use a capital D in this kind of sentence-style
&gt; comment.
&gt; 
&gt; VC is not normally an abbreviation we use for view controller in WebKit code.
&gt; 
&gt; &quot;This is works all&quot;, is not grammatically correct.
&gt; 
&gt; &gt; Source/WebKit2/UIProcess/ios/forms/WKFileUploadPanel.mm:394
&gt; &gt; +    UIViewController *presentedViewController = [UIViewController _viewControllerForFullScreenPresentationFromView:_view];
&gt; &gt; +    if (presentedViewController)
&gt; &gt; +        [presentedViewController dismissViewControllerAnimated:NO completion:nil];
&gt; 
&gt; Would be nice to define the variable inside the &quot;if&quot; since this is C++ code.
&gt; In fact, I personally would use auto instead of writing out UIViewController
&gt; * for the type of the variable.
&gt; 
&gt; &gt; Source/WebKit2/UIProcess/ios/forms/WKFileUploadPanel.mm:508
&gt; &gt; +    // Clear out any previous view controller reference, to prevent calling dismiss on a view controller that
&gt; &gt; +    // was no longer being presented. Don't save a reference to the UIDocumentMenuViewController as it is self dismissing.
&gt; &gt; +    _presentationViewController = nil;
&gt; 
&gt; I don’t understand this comment and therefore don’t understand the code.</span >

So what happening is that the _presentationViewController is used to called in:

- (void)_dismissDisplayAnimated:(BOOL)animated
{
    if (_presentationPopover) {
        [_presentationPopover dismissPopoverAnimated:animated];
        [_presentationPopover setDelegate:nil];
        _presentationPopover = nil;
    }

    if (_presentationViewController) {
        [_presentationViewController dismissViewControllerAnimated:animated completion:^{
            _presentationViewController = nil;
        }];
    }
}


The UIDocumentMenuViewController dismisses itself, so when _presentationViewController dismissViewControllerAnimated:animated is called in this function, it dismisses the WKWebView when is presented modally.  That's why it's set to nil in this function, so that the errant code path is never executed.
<span class="quote">&gt; 
&gt; On iPhone, the method called just before this will call
&gt; _presentFullscreenViewController. Then this line of code will clear out the
&gt; reference to that just-presented view controller. Given that, why does this
&gt; comment talk about clearing out a &quot;previous view controller reference&quot;?</span ></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>