Changeset 170988 in webkit


Ignore:
Timestamp:
Jul 10, 2014, 7:29:33 PM (11 years ago)
Author:
benjamin@webkit.org
Message:

[iOS][WK2] It should be safe to call WKContentViewInteraction's cleanupInteraction multiple times
https://bugs.webkit.org/show_bug.cgi?id=134820

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-07-10
Reviewed by Andreas Kling.

If a view is destroyed just after a crash, "cleanupInteraction" is called twice: once on crash,
once on dealloc.

The code handling _interactionViewsContainerView is using KVO to monitor transform changes. It is not safe
to remove the observer if we are not already observing on that view.

To solve the problem, this patch makes the cleanup actually remove the view so that setup and cleanup
are completely symmetrical. If cleanup is called twice, the second time would not enter the branch because
the view is already nil.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView setupInteraction]):
(-[WKContentView cleanupInteraction]):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r170987 r170988  
     12014-07-10  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [iOS][WK2] It should be safe to call WKContentViewInteraction's cleanupInteraction multiple times
     4        https://bugs.webkit.org/show_bug.cgi?id=134820
     5
     6        Reviewed by Andreas Kling.
     7
     8        If a view is destroyed just after a crash, "cleanupInteraction" is called twice: once on crash,
     9        once on dealloc.
     10
     11        The code handling _interactionViewsContainerView is using KVO to monitor transform changes. It is not safe
     12        to remove the observer if we are not already observing on that view.
     13
     14        To solve the problem, this patch makes the cleanup actually remove the view so that setup and cleanup
     15        are completely symmetrical. If cleanup is called twice, the second time would not enter the branch because
     16        the view is already nil.
     17
     18        * UIProcess/ios/WKContentViewInteraction.mm:
     19        (-[WKContentView setupInteraction]):
     20        (-[WKContentView cleanupInteraction]):
     21
    1222014-07-10  Simon Fraser  <simon.fraser@apple.com>
    223
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r170981 r170988  
    221221        [_interactionViewsContainerView setOpaque:NO];
    222222        [_interactionViewsContainerView layer].anchorPoint = CGPointZero;
    223     }
    224     [_interactionViewsContainerView setHidden:NO];
     223        [self.superview addSubview:_interactionViewsContainerView.get()];
     224    }
     225
    225226    [self.layer addObserver:self forKeyPath:@"transform" options:NSKeyValueObservingOptionInitial context:nil];
    226227
     
    277278    _formInputSession = nil;
    278279    [_highlightView removeFromSuperview];
    279     [self.layer removeObserver:self forKeyPath:@"transform"];
    280     [_interactionViewsContainerView setHidden:YES];
     280
     281    if (_interactionViewsContainerView) {
     282        [self.layer removeObserver:self forKeyPath:@"transform"];
     283        [_interactionViewsContainerView removeFromSuperview];
     284        _interactionViewsContainerView = nil;
     285    }
     286
    281287    [_touchEventGestureRecognizer setDelegate:nil];
    282288    [self removeGestureRecognizer:_touchEventGestureRecognizer.get()];
Note: See TracChangeset for help on using the changeset viewer.