RESOLVED FIXED 185257
A WKWebView in a UIViewController that is presented modally and uses a file picker will be incorrectly dismissed by the system
https://bugs.webkit.org/show_bug.cgi?id=185257
Summary A WKWebView in a UIViewController that is presented modally and uses a file p...
Zach Waugh
Reported 2018-05-03 10:00:19 PDT
Created attachment 339421 [details] Sample project that reproduces the bug This is similar to https://bugs.webkit.org/show_bug.cgi?id=165225. When a WKWebView is presented in a modal UIViewControlller and a file picker is displayed (from <input type="file">), taking any actions from within the file browser will result in the file browser modal being dismissed as well as the application modal. The expected result is only the file browser modal is dismissed and the application modal remains. To Reproduce: 1. Present a UIViewController containing a WKWebView modally 2. The WKWebView should have an <input type="file"> element. 3. Click the "Choose File" button 4. Choose "Browse" from the action sheet that is displayed 5. iOS will present the file browser modally 6. When the file browser modal is displayed, either choose "Cancel" in the top-right or select a file 7. Upon either of those actions, the file browser modal will be dismissed as well as this application modal that contains the web view 8. The expected behavior is only the file browser modal is dismissed and the application modal remains I've attached a sample project that reproduces this in iOS 11.3, which is also available on GitHub here with an example GIF: https://github.com/zachwaugh/wkwebview-bugs/tree/master/ModalFileDismissal
Attachments
Sample project that reproduces the bug (42.58 KB, application/zip)
2018-05-03 10:00 PDT, Zach Waugh
no flags
Patch (1.85 KB, patch)
2018-07-03 13:51 PDT, Olivia Barnett
no flags
Patch (1.96 KB, patch)
2018-07-03 13:53 PDT, Olivia Barnett
no flags
Patch (2.02 KB, patch)
2018-07-03 14:42 PDT, Olivia Barnett
no flags
Patch (2.04 KB, patch)
2018-07-03 14:58 PDT, Olivia Barnett
no flags
Radar WebKit Bug Importer
Comment 1 2018-06-05 12:47:42 PDT
Tim Horton
Comment 2 2018-06-05 15:41:06 PDT
*** This bug has been marked as a duplicate of bug 183549 ***
Zach Waugh
Comment 3 2018-06-06 07:35:36 PDT
I can't see the full details of the linked bug, but I don't believe they are the same issue. This bug report is concerning when the UIDocumentBrowserViewController is presented and subsequently dismissed. If you click through to this link (https://github.com/zachwaugh/wkwebview-bugs/tree/master/ModalFileDismissal), there is gif showing the full bug and it's unrelated to the action sheet. I've confirmed the bug is still present in iOS 12 beta 1 building against Xcode 10 beta 1.
Tim Horton
Comment 4 2018-06-06 07:53:54 PDT
Interesting! I bet it has a similar fix, then.
Tim Horton
Comment 5 2018-06-06 11:10:07 PDT
It does look like WKFileUploadPanel has the same bug.
Olivia Barnett
Comment 6 2018-07-03 13:51:23 PDT
Olivia Barnett
Comment 7 2018-07-03 13:53:45 PDT
Tim Horton
Comment 8 2018-07-03 13:57:44 PDT
Comment on attachment 344212 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=344212&action=review > Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm:288 > + [currentPresentedViewController dismissViewControllerAnimated:YES completion:nil]; I think you probably still want to clear _presentationViewController in the completion handler.
Tim Horton
Comment 9 2018-07-03 13:59:14 PDT
Comment on attachment 344212 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=344212&action=review >> Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm:288 >> + [currentPresentedViewController dismissViewControllerAnimated:YES completion:nil]; > > I think you probably still want to clear _presentationViewController in the completion handler. (Otherwise I think this is a leak?)
Olivia Barnett
Comment 10 2018-07-03 14:42:35 PDT
Tim Horton
Comment 11 2018-07-03 14:50:05 PDT
Comment on attachment 344222 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=344222&action=review > Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm:288 > + [currentPresentedViewController dismissViewControllerAnimated:YES completion:^{_presentationViewController = nil; The first statement inside the block should be on the next line.
Olivia Barnett
Comment 12 2018-07-03 14:58:37 PDT
WebKit Commit Bot
Comment 13 2018-07-04 02:43:15 PDT
Comment on attachment 344225 [details] Patch Clearing flags on attachment: 344225 Committed r233502: <https://trac.webkit.org/changeset/233502>
WebKit Commit Bot
Comment 14 2018-07-04 02:43:16 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.