When a view controller is presented modally on top of a WKWebView, the web view is removed from the view hierarchy. This causes it to resign first responder status, and to signal the DOM that it is no longer in an active, focused window. In particular, this will cause any focused input element to lose focus. The result is that, for example, when focusing a credit card number field on a webpage and using Safari to capture credit card information from the camera, which involves a modal sheet, the field is no longer focused after dismissing the sheet.
Created attachment 248658 [details] Add -[WKWebView _retainActiveFocusedState]
Comment on attachment 248658 [details] Add -[WKWebView _retainActiveFocusedState] View in context: https://bugs.webkit.org/attachment.cgi?id=248658&action=review > Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm:1779 > +- (void (^)(void))_retainActiveFocusedState I really think we need a name here that indicates that this returns a block. I can't think of a name though :(
Fixed in <http://trac.webkit.org/r181511>.
(In reply to comment #3) > Fixed in <http://trac.webkit.org/r181511>. Many (most?) iOS layout tests crash here with a NULL deref after this change: Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 com.apple.WebKit 0x0000000106c22231 WebKit::PageClientImpl::isViewWindowActive() + 37 1 com.apple.WebKit 0x0000000106c2224f WebKit::PageClientImpl::isViewFocused() + 15 2 com.apple.WebKit 0x0000000106d3128e WebKit::WebPageProxy::updateViewState(unsigned int) + 38 3 com.apple.WebKit 0x0000000106d30909 WebKit::WebPageProxy::WebPageProxy(WebKit::PageClient&, WebKit::WebProcessProxy&, unsigned long long, WebKit::WebPageConfiguration const&) + 2195 4 com.apple.WebKit 0x0000000106d3004b WebKit::WebPageProxy::create(WebKit::PageClient&, WebKit::WebProcessProxy&, unsigned long long, WebKit::WebPageConfiguration const&) + 69 5 com.apple.WebKit 0x0000000106d929cb WebKit::WebProcessProxy::createWebPage(WebKit::PageClient&, WebKit::WebPageConfiguration const&) + 55 6 com.apple.WebKit 0x0000000106d888fb WebKit::WebProcessPool::createWebPage(WebKit::PageClient&, WebKit::WebPageConfiguration) + 239 7 com.apple.WebKit 0x0000000106dc2a6d -[WKContentView _commonInitializationWithProcessPool:configuration:] + 160 8 com.apple.WebKit 0x0000000106dc307d -[WKContentView initWithFrame:processPool:configuration:wkView:] + 280 9 com.apple.WebKit 0x0000000106e04925 -[WKView _commonInitializationWithContextRef:pageGroupRef:relatedToPage:] + 620 10 com.apple.WebKit 0x0000000106e05212 -[WKView(Private) initWithFrame:contextRef:pageGroupRef:relatedToPage:] + 125 11 com.apple.WebKit 0x0000000106e0518f -[WKView(Private) initWithFrame:contextRef:pageGroupRef:] + 59 12 org.webkit.WebKitTestRunnerApp0 0x00000001041d7d5b -[TestRunnerWKView initWithFrame:contextRef:pageGroupRef:relatedToPage:useTiledDrawing:] + 85 (PlatformWebViewIOS.mm:59) 13 org.webkit.WebKitTestRunnerApp0 0x00000001041d80ba WTR::PlatformWebView::PlatformWebView(OpaqueWKContext const*, OpaqueWKPageGroup const*, OpaqueWKPage const*, OpaqueWKDictionary const*) + 268 (PlatformWebViewIOS.mm:133) 14 org.webkit.WebKitTestRunnerApp0 0x00000001041cc64a WTR::TestController::createWebViewWithOptions(OpaqueWKDictionary const*) + 68 (memory:2627) 15 org.webkit.WebKitTestRunnerApp0 0x00000001041cafdc WTR::TestController::initialize(int, char const**) + 3242 (TestController.cpp:437) 16 org.webkit.WebKitTestRunnerApp0 0x00000001041ca1a0 WTR::TestController::TestController(int, char const**) + 306 (TestController.cpp:128) 17 org.webkit.WebKitTestRunnerApp0 0x00000001041c99c8 -[WebKitTestRunnerApp _runTestController] + 40 (mainIOS.mm:44) 18 com.apple.Foundation 0x0000000106477d06 __NSThreadPerformPerform + 283 19 com.apple.CoreFoundation 0x00000001079f4701 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 20 com.apple.CoreFoundation 0x00000001079ea29c __CFRunLoopDoSources0 + 476 21 com.apple.CoreFoundation 0x00000001079e97b8 __CFRunLoopRun + 856 22 com.apple.CoreFoundation 0x00000001079e91d8 CFRunLoopRunSpecific + 488 23 com.apple.GraphicsServices 0x00000001081abbb1 GSEventRunModal + 161 24 com.apple.UIKit 0x00000001052f13a7 UIApplicationMain + 1215 25 org.webkit.WebKitTestRunnerApp0 0x00000001041c9c89 main + 32 (mainIOS.mm:81) 26 libdyld.dylib 0x000000010b8d0a05 start + 1 Attempted a follow-up fix by adding a NULL check in r181548: <http://trac.webkit.org/r181548>