WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
159980
[iOS] Apps using WKWebView will crash if they set the scroll view's delegate and don't nil it out later
https://bugs.webkit.org/show_bug.cgi?id=159980
Summary
[iOS] Apps using WKWebView will crash if they set the scroll view's delegate ...
Chelsea Pugh
Reported
2016-07-20 11:39:47 PDT
Apps using WKWebView will crash if they set the scroll view's delegate and don't nil it out later. Patch forthcoming.
Attachments
Patch for [iOS] Apps using WKWebView will crash if they set the scroll views
(2.80 KB, patch)
2016-07-20 11:45 PDT
,
Chelsea Pugh
no flags
Details
Formatted Diff
Diff
v2 patch for [iOS] Apps using WKWebView will crash
(14.57 KB, patch)
2016-07-21 14:31 PDT
,
Chelsea Pugh
mitz: review+
cpugh
: commit-queue-
Details
Formatted Diff
Diff
v3 patch for [iOS] Apps using WKWebView will crash if they set the scroll view's delegate and don't nil it out later
(12.15 KB, patch)
2016-07-21 15:24 PDT
,
Chelsea Pugh
no flags
Details
Formatted Diff
Diff
v3 patch for [iOS] Apps using WKWebView will crash if they set the scroll view's delegate and don't nil it out later
(14.68 KB, patch)
2016-07-21 15:30 PDT
,
Chelsea Pugh
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Chelsea Pugh
Comment 1
2016-07-20 11:45:39 PDT
Created
attachment 284134
[details]
Patch for [iOS] Apps using WKWebView will crash if they set the scroll views
mitz
Comment 2
2016-07-20 11:52:09 PDT
Comment on
attachment 284134
[details]
Patch for [iOS] Apps using WKWebView will crash if they set the scroll views I believe that the fundamental problem is that WKScrollView is subclassing UIScrollView and violating its API contract that states that the delegate property is weak. Your patch prevents this from causing a crash in one specific scenario, but I don’t understand why we can’t just fix WKScrollView. It may be as simple as using a WeakObjCPtr for the external delegate (making sure to take a strong reference any time we use it in a method). Am I missing anything?
mitz
Comment 3
2016-07-20 11:53:01 PDT
It also seems like either way you choose to fix it, you should be able to create an API test.
Chelsea Pugh
Comment 4
2016-07-21 14:31:12 PDT
Created
attachment 284260
[details]
v2 patch for [iOS] Apps using WKWebView will crash
WebKit Commit Bot
Comment 5
2016-07-21 14:32:12 PDT
Attachment 284260
[details]
did not pass style-queue: ERROR: Source/WebKit2/UIProcess/ios/WKScrollView.mm:31: Alphabetical sorting problem. [build/include_order] [4] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
mitz
Comment 6
2016-07-21 14:45:39 PDT
Comment on
attachment 284260
[details]
v2 patch for [iOS] Apps using WKWebView will crash View in context:
https://bugs.webkit.org/attachment.cgi?id=284260&action=review
> Source/WebKit2/UIProcess/ios/WKScrollView.mm:47 > + WebKit::WeakObjCPtr<id <UIScrollViewDelegate>> _externalDelegate;
I think you can add “using namespace WebKit” to this file and avoid the WebKit:: qualifier here and elsewhere.
> Source/WebKit2/UIProcess/ios/WKScrollView.mm:74 > + auto externalDelegate = _externalDelegate.get(); > + return [super respondsToSelector:aSelector] || [_internalDelegate respondsToSelector:aSelector] || [externalDelegate.get() respondsToSelector:aSelector];
Since you’re only using the external delegate once you don’t really have to have this local.
> Source/WebKit2/UIProcess/ios/WKScrollView.mm:140 > + if (_externalDelegate.get().get() == delegate)
Yikes! I wonder if we should add a == override to WeakObjCPtr.
Chelsea Pugh
Comment 7
2016-07-21 14:56:05 PDT
(In reply to
comment #6
)
> Comment on
attachment 284260
[details]
> v2 patch for [iOS] Apps using WKWebView will crash > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=284260&action=review
> > > Source/WebKit2/UIProcess/ios/WKScrollView.mm:47 > > + WebKit::WeakObjCPtr<id <UIScrollViewDelegate>> _externalDelegate; > > I think you can add “using namespace WebKit” to this file and avoid the > WebKit:: qualifier here and elsewhere.
Will do
> > > Source/WebKit2/UIProcess/ios/WKScrollView.mm:74 > > + auto externalDelegate = _externalDelegate.get(); > > + return [super respondsToSelector:aSelector] || [_internalDelegate respondsToSelector:aSelector] || [externalDelegate.get() respondsToSelector:aSelector]; > > Since you’re only using the external delegate once you don’t really have to > have this local.
Okay
> > > Source/WebKit2/UIProcess/ios/WKScrollView.mm:140 > > + if (_externalDelegate.get().get() == delegate) > > Yikes! I wonder if we should add a == override to WeakObjCPtr.
Maybe, but likely out of scope for this patch
Chelsea Pugh
Comment 8
2016-07-21 15:24:35 PDT
Created
attachment 284267
[details]
v3 patch for [iOS] Apps using WKWebView will crash if they set the scroll view's delegate and don't nil it out later
Chelsea Pugh
Comment 9
2016-07-21 15:30:09 PDT
Created
attachment 284270
[details]
v3 patch for [iOS] Apps using WKWebView will crash if they set the scroll view's delegate and don't nil it out later
WebKit Commit Bot
Comment 10
2016-07-21 16:55:45 PDT
Comment on
attachment 284270
[details]
v3 patch for [iOS] Apps using WKWebView will crash if they set the scroll view's delegate and don't nil it out later Rejecting
attachment 284270
[details]
from commit-queue.
cpugh@apple.com
does not have committer permissions according to
http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/common/config/contributors.json
. - If you do not have committer rights please read
http://webkit.org/coding/contributing.html
for instructions on how to use bugzilla flags. - If you have committer rights please correct the error in Tools/Scripts/webkitpy/common/config/contributors.json by adding yourself to the file (no review needed). The commit-queue restarts itself every 2 hours. After restart the commit-queue will correctly respect your committer rights.
WebKit Commit Bot
Comment 11
2016-07-21 17:12:13 PDT
Comment on
attachment 284270
[details]
v3 patch for [iOS] Apps using WKWebView will crash if they set the scroll view's delegate and don't nil it out later Clearing flags on attachment: 284270 Committed
r203541
: <
http://trac.webkit.org/changeset/203541
>
WebKit Commit Bot
Comment 12
2016-07-21 17:12:17 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.
Top of Page
Format For Printing
XML
Clone This Bug