Changeset 269279 in webkit


Ignore:
Timestamp:
Nov 2, 2020, 4:40:51 PM (5 years ago)
Author:
Devin Rousso
Message:

guard UIScribbleInteraction class property observing behind a LOA check
https://bugs.webkit.org/show_bug.cgi?id=218463
<rdar://problem/70747966>

Reviewed by Tim Horton.

Some apps appear to swizzle -[NSObject addObserver:forKeyPath:options:context:] without
support for the fact that the object can be a class rather than an instance and therefore
crash. Use a LOA check to guard observing +[UIScribbleInteraction isPencilInputExpected]
so that this doesn't happen, but only until the apps update, at which point they can fix it.

Source/WebCore:

  • platform/cocoa/VersionChecks.h:

This appears to be the first instance of observing a class property, so add a new version
value for FirstThatObservesClassProperty.

Source/WebKit:

  • UIProcess/ios/WKStylusDeviceObserver.mm:

(-[WKStylusDeviceObserver start]):
(-[WKStylusDeviceObserver stop]):

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r269275 r269279  
     12020-11-02  Devin Rousso  <drousso@apple.com>
     2
     3        guard UIScribbleInteraction class property observing behind a LOA check
     4        https://bugs.webkit.org/show_bug.cgi?id=218463
     5        <rdar://problem/70747966>
     6
     7        Reviewed by Tim Horton.
     8
     9        Some apps appear to swizzle `-[NSObject addObserver:forKeyPath:options:context:]` without
     10        support for the fact that the object can be a class rather than an instance and therefore
     11        crash. Use a LOA check to guard observing `+[UIScribbleInteraction isPencilInputExpected]`
     12        so that this doesn't happen, but only until the apps update, at which point they can fix it.
     13
     14        * platform/cocoa/VersionChecks.h:
     15        This appears to be the first instance of observing a class property, so add a new version
     16        value for `FirstThatObservesClassProperty`.
     17
    1182020-11-02  Chris Dumez  <cdumez@apple.com>
    219
  • trunk/Source/WebCore/platform/cocoa/VersionChecks.h

    r267995 r269279  
    6666    FirstVersionWithiOSAppsOnMacOS = DYLD_IOS_VERSION_FIRST_WITH_IOS_APPS_ON_MACOS,
    6767    FirstWithDataURLFragmentRemoval = DYLD_IOS_VERSION_14_5,
     68    FirstThatObservesClassProperty = DYLD_IOS_VERSION_14_5,
    6869#elif PLATFORM(MAC)
    6970    FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
  • trunk/Source/WebKit/ChangeLog

    r269273 r269279  
     12020-11-02  Devin Rousso  <drousso@apple.com>
     2
     3        guard UIScribbleInteraction class property observing behind a LOA check
     4        https://bugs.webkit.org/show_bug.cgi?id=218463
     5        <rdar://problem/70747966>
     6
     7        Reviewed by Tim Horton.
     8
     9        Some apps appear to swizzle `-[NSObject addObserver:forKeyPath:options:context:]` without
     10        support for the fact that the object can be a class rather than an instance and therefore
     11        crash. Use a LOA check to guard observing `+[UIScribbleInteraction isPencilInputExpected]`
     12        so that this doesn't happen, but only until the apps update, at which point they can fix it.
     13
     14        * UIProcess/ios/WKStylusDeviceObserver.mm:
     15        (-[WKStylusDeviceObserver start]):
     16        (-[WKStylusDeviceObserver stop]):
     17
    1182020-11-02  James Savage  <james.savage@apple.com>
    219
  • trunk/Source/WebKit/UIProcess/ios/WKStylusDeviceObserver.mm

    r268482 r269279  
    3131#import "WebProcessProxy.h"
    3232#import <UIKit/UIScribbleInteraction.h>
     33#import <WebCore/VersionChecks.h>
    3334#import <wtf/RetainPtr.h>
    3435#import <wtf/Seconds.h>
     
    8485        return;
    8586
    86     [[UIScribbleInteraction class] addObserver:self forKeyPath:@"isPencilInputExpected" options:NSKeyValueObservingOptionInitial context:nil];
     87    if (WebCore::linkedOnOrAfter(WebCore::SDKVersion::FirstThatObservesClassProperty))
     88        [[UIScribbleInteraction class] addObserver:self forKeyPath:@"isPencilInputExpected" options:NSKeyValueObservingOptionInitial context:nil];
    8789}
    8890
     
    9395        return;
    9496
    95     [[UIScribbleInteraction class] removeObserver:self forKeyPath:@"isPencilInputExpected"];
     97    if (WebCore::linkedOnOrAfter(WebCore::SDKVersion::FirstThatObservesClassProperty))
     98        [[UIScribbleInteraction class] removeObserver:self forKeyPath:@"isPencilInputExpected"];
    9699}
    97100
Note: See TracChangeset for help on using the changeset viewer.