Changeset 195982 in webkit


Ignore:
Timestamp:
Feb 1, 2016 3:31:30 PM (8 years ago)
Author:
timothy_horton@apple.com
Message:

Crash using WKPDFView, in -[UIPDFPageView showContent]
https://bugs.webkit.org/show_bug.cgi?id=153770
<rdar://problem/20157864>

Reviewed by Anders Carlsson.

When scrolling, we throw away UIPDFPageViews, but forget to unhook their delegates.
In some cases (also because their delegate is a raw pointer, not weak), they can call
back into a deleted WKPDFView, causing a crash.

  • UIProcess/ios/WKPDFView.mm:

(detachViewForPage):
Add a helper to detach a page view, and unhook its delegates.

(-[WKPDFView _clearPages]):
(-[WKPDFView _revalidateViews]):
Make use of the new helper.

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r195971 r195982  
     12016-02-01  Tim Horton  <timothy_horton@apple.com>
     2
     3        Crash using WKPDFView, in -[UIPDFPageView showContent]
     4        https://bugs.webkit.org/show_bug.cgi?id=153770
     5        <rdar://problem/20157864>
     6
     7        Reviewed by Anders Carlsson.
     8
     9        When scrolling, we throw away UIPDFPageViews, but forget to unhook their delegates.
     10        In some cases (also because their delegate is a raw pointer, not weak), they can call
     11        back into a deleted WKPDFView, causing a crash.
     12
     13        * UIProcess/ios/WKPDFView.mm:
     14        (detachViewForPage):
     15        Add a helper to detach a page view, and unhook its delegates.
     16
     17        (-[WKPDFView _clearPages]):
     18        (-[WKPDFView _revalidateViews]):
     19        Make use of the new helper.
     20
    1212016-02-01  Dan Bernstein  <mitz@apple.com>
    222
  • trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm

    r194496 r195982  
    157157}
    158158
     159static void detachViewForPage(PDFPageInfo& page)
     160{
     161    [page.view removeFromSuperview];
     162    [page.view setDelegate:nil];
     163    [[page.view annotationController] setDelegate:nil];
     164    page.view = nil;
     165}
     166
    159167- (void)_clearPages
    160168{
    161     for (auto& page : _pages) {
    162         [page.view removeFromSuperview];
    163         [page.view setDelegate:nil];
    164         [[page.view annotationController] setDelegate:nil];
    165     }
     169    for (auto& page : _pages)
     170        detachViewForPage(page);
    166171   
    167172    _pages.clear();
     
    269274    for (auto& pageInfo : _pages) {
    270275        if (!CGRectIntersectsRect(pageInfo.frame, targetRectWithOverdraw) && pageInfo.index != _currentFindPageIndex) {
    271             [pageInfo.view removeFromSuperview];
    272             pageInfo.view = nullptr;
     276            detachViewForPage(pageInfo);
    273277            continue;
    274278        }
Note: See TracChangeset for help on using the changeset viewer.