Title: [235793] branches/safari-606-branch/Source/WebKit
Revision
235793
Author
[email protected]
Date
2018-09-07 13:07:42 -0700 (Fri, 07 Sep 2018)

Log Message

Cherry-pick r234719. rdar://problem/44169456

    Yet more crashes in MobileSafari under -[WKFormInputSession setSuggestions:]
    https://bugs.webkit.org/show_bug.cgi?id=188427
    <rdar://problem/43064672>

    Reviewed by Wenson Hsieh.

    Speculatively fix more crashes seen under setSuggestions.

    * UIProcess/ios/WKContentViewInteraction.mm:
    (-[WKFormInputSession isValid]):
    (-[WKFormInputSession setSuggestions:]):
    (-[WKFormInputSession invalidate]):
    Belt-and-suspenders fix: use WeakObjCPtr for WKFormInputSession's WKContentView reference.

    (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
    Invalidate the WKFormInputSession before replacing it; we theorize that
    there is a path in which we get here without having previously called stopAssistingNode.
    Most of the code is OK with this, but this leaves WKFormInputSession
    with a raw reference to WKContentView which can later become stale.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234719 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-606-branch/Source/WebKit/ChangeLog (235792 => 235793)


--- branches/safari-606-branch/Source/WebKit/ChangeLog	2018-09-07 20:07:39 UTC (rev 235792)
+++ branches/safari-606-branch/Source/WebKit/ChangeLog	2018-09-07 20:07:42 UTC (rev 235793)
@@ -1,5 +1,54 @@
 2018-09-06  Babak Shafiei  <[email protected]>
 
+        Cherry-pick r234719. rdar://problem/44169456
+
+    Yet more crashes in MobileSafari under -[WKFormInputSession setSuggestions:]
+    https://bugs.webkit.org/show_bug.cgi?id=188427
+    <rdar://problem/43064672>
+    
+    Reviewed by Wenson Hsieh.
+    
+    Speculatively fix more crashes seen under setSuggestions.
+    
+    * UIProcess/ios/WKContentViewInteraction.mm:
+    (-[WKFormInputSession isValid]):
+    (-[WKFormInputSession setSuggestions:]):
+    (-[WKFormInputSession invalidate]):
+    Belt-and-suspenders fix: use WeakObjCPtr for WKFormInputSession's WKContentView reference.
+    
+    (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
+    Invalidate the WKFormInputSession before replacing it; we theorize that
+    there is a path in which we get here without having previously called stopAssistingNode.
+    Most of the code is OK with this, but this leaves WKFormInputSession
+    with a raw reference to WKContentView which can later become stale.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234719 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-08-08  Tim Horton  <[email protected]>
+
+            Yet more crashes in MobileSafari under -[WKFormInputSession setSuggestions:]
+            https://bugs.webkit.org/show_bug.cgi?id=188427
+            <rdar://problem/43064672>
+
+            Reviewed by Wenson Hsieh.
+
+            Speculatively fix more crashes seen under setSuggestions.
+
+            * UIProcess/ios/WKContentViewInteraction.mm:
+            (-[WKFormInputSession isValid]):
+            (-[WKFormInputSession setSuggestions:]):
+            (-[WKFormInputSession invalidate]):
+            Belt-and-suspenders fix: use WeakObjCPtr for WKFormInputSession's WKContentView reference.
+
+            (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
+            Invalidate the WKFormInputSession before replacing it; we theorize that
+            there is a path in which we get here without having previously called stopAssistingNode.
+            Most of the code is OK with this, but this leaves WKFormInputSession
+            with a raw reference to WKContentView which can later become stale.
+
+2018-09-06  Babak Shafiei  <[email protected]>
+
         Cherry-pick r234504. rdar://problem/44209851
 
     [iOS] Keyboard becomes unresponsive after pressing delete while pressing down on a character key with accents

Modified: branches/safari-606-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (235792 => 235793)


--- branches/safari-606-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-09-07 20:07:39 UTC (rev 235792)
+++ branches/safari-606-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-09-07 20:07:42 UTC (rev 235793)
@@ -287,7 +287,7 @@
 @end
 
 @implementation WKFormInputSession {
-    WKContentView *_contentView;
+    WeakObjCPtr<WKContentView> _contentView;
     RetainPtr<WKFocusedElementInfo> _focusedElementInfo;
     RetainPtr<UIView> _customInputView;
     RetainPtr<NSArray<UITextSuggestion *>> _suggestions;
@@ -320,7 +320,7 @@
 
 - (BOOL)isValid
 {
-    return _contentView != nil;
+    return !!_contentView;
 }
 
 - (NSString *)accessoryViewCustomButtonTitle
@@ -387,7 +387,7 @@
 
 - (void)setSuggestions:(NSArray<UITextSuggestion *> *)suggestions
 {
-    id <UITextInputSuggestionDelegate> suggestionDelegate = (id <UITextInputSuggestionDelegate>)_contentView.inputDelegate;
+    id <UITextInputSuggestionDelegate> suggestionDelegate = (id <UITextInputSuggestionDelegate>)[_contentView inputDelegate];
     _suggestions = adoptNS([suggestions copy]);
     [suggestionDelegate setSuggestions:suggestions];
 }
@@ -399,7 +399,7 @@
 
 - (void)invalidate
 {
-    id <UITextInputSuggestionDelegate> suggestionDelegate = (id <UITextInputSuggestionDelegate>)_contentView.inputDelegate;
+    id <UITextInputSuggestionDelegate> suggestionDelegate = (id <UITextInputSuggestionDelegate>)[_contentView inputDelegate];
     [suggestionDelegate setSuggestions:nil];
     _contentView = nil;
 }
@@ -4110,8 +4110,10 @@
     bool delegateImplementsWillStartInputSession = [inputDelegate respondsToSelector:@selector(_webView:willStartInputSession:)];
     bool delegateImplementsDidStartInputSession = [inputDelegate respondsToSelector:@selector(_webView:didStartInputSession:)];
 
-    if (delegateImplementsWillStartInputSession || delegateImplementsDidStartInputSession)
+    if (delegateImplementsWillStartInputSession || delegateImplementsDidStartInputSession) {
+        [_formInputSession invalidate];
         _formInputSession = adoptNS([[WKFormInputSession alloc] initWithContentView:self focusedElementInfo:focusedElementInfo.get() requiresStrongPasswordAssistance:_focusRequiresStrongPasswordAssistance]);
+    }
 
     if (delegateImplementsWillStartInputSession)
         [inputDelegate _webView:_webView willStartInputSession:_formInputSession.get()];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to