Changeset 246664 in webkit


Ignore:
Timestamp:
Jun 20, 2019 5:49:14 PM (5 years ago)
Author:
dbates@webkit.org
Message:

[iOS] Evernote crashes when creating a note
https://bugs.webkit.org/show_bug.cgi?id=199083
<rdar://problem/51759247>

Reviewed by Brent Fulgham.

Source/WebCore:

Add runtime check whether WebKit is being used in Evernote. Evernote's bundle ID
references iPhone, but they use the same ID for their iPad app as well.

  • platform/RuntimeApplicationChecks.h:
  • platform/cocoa/RuntimeApplicationChecksCocoa.mm:

(WebCore::IOSApplication::isEvernote): Added.

Source/WebKit:

Add a hack just for Evernote linked before iOS 13 that dynamically adds a placeholder -[WKContentView keyCommands]
method (it just calls super). Evernote swizzles the IPI -[WKContentView keyCommands], but this
method may not always be present in the WebKit binary following r240514. So, Evernote may end
up swizzling -[UIResponder keyCommands], but their implementation doesn't account for this
scenario and they end up crashing because they call an unrecognized selector.

  • UIProcess/Cocoa/VersionChecks.h: Add version check.
  • UIProcess/ios/WKContentView.mm:

(keyCommandsPlaceholderHackForEvernote): Added.
(-[WKContentView _commonInitializationWithProcessPool:configuration:]): Install the hack.

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r246655 r246664  
     12019-06-20  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] Evernote crashes when creating a note
     4        https://bugs.webkit.org/show_bug.cgi?id=199083
     5        <rdar://problem/51759247>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Add runtime check whether WebKit is being used in Evernote. Evernote's bundle ID
     10        references iPhone, but they use the same ID for their iPad app as well.
     11
     12        * platform/RuntimeApplicationChecks.h:
     13        * platform/cocoa/RuntimeApplicationChecksCocoa.mm:
     14        (WebCore::IOSApplication::isEvernote): Added.
     15
    1162019-06-20  Greg Doolittle  <gr3g@apple.com>
    217
  • trunk/Source/WebCore/platform/RuntimeApplicationChecks.h

    r244239 r246664  
    9393WEBCORE_EXPORT bool isFirefox();
    9494WEBCORE_EXPORT bool isAppleApplication();
     95WEBCORE_EXPORT bool isEvernote();
    9596
    9697} // IOSApplication
  • trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm

    r244239 r246664  
    295295}
    296296
     297bool IOSApplication::isEvernote()
     298{
     299    static bool isEvernote = applicationBundleIsEqualTo("com.evernote.iPhone.Evernote"_s);
     300    return isEvernote;
     301}
     302
    297303#endif
    298304
  • trunk/Source/WebKit/ChangeLog

    r246660 r246664  
     12019-06-20  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] Evernote crashes when creating a note
     4        https://bugs.webkit.org/show_bug.cgi?id=199083
     5        <rdar://problem/51759247>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Add a hack just for Evernote linked before iOS 13 that dynamically adds a placeholder -[WKContentView keyCommands]
     10        method (it just calls super). Evernote swizzles the IPI -[WKContentView keyCommands], but this
     11        method may not always be present in the WebKit binary following r240514. So, Evernote may end
     12        up swizzling -[UIResponder keyCommands], but their implementation doesn't account for this
     13        scenario and they end up crashing because they call an unrecognized selector.
     14
     15        * UIProcess/Cocoa/VersionChecks.h: Add version check.
     16        * UIProcess/ios/WKContentView.mm:
     17        (keyCommandsPlaceholderHackForEvernote): Added.
     18        (-[WKContentView _commonInitializationWithProcessPool:configuration:]): Install the hack.
     19
    1202019-06-20  Brady Eidson  <beidson@apple.com>
    221
  • trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h

    r246626 r246664  
    7474    FirstWithModernCompabilityModeByDefault = DYLD_IOS_VERSION_FIRST_WITH_MODERN_COMPATIBILITY_MODE_BY_DEFAULT,
    7575    FirstThatHasUIContextMenuInteraction = DYLD_IOS_VERSION_13_0,
     76    FirstWhereWKContentViewDoesNotOverrideKeyCommands = DYLD_IOS_VERSION_13_0,
    7677#elif PLATFORM(MAC)
    7778    FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
  • trunk/Source/WebKit/UIProcess/ios/WKContentView.mm

    r246413 r246664  
    6161#import <WebCore/PlatformScreen.h>
    6262#import <WebCore/Quirks.h>
     63#import <WebCore/RuntimeApplicationChecks.h>
    6364#import <WebCore/VelocityData.h>
     65#import <objc/message.h>
    6466#import <pal/spi/cocoa/QuartzCoreSPI.h>
    6567#import <wtf/RetainPtr.h>
     
    142144}
    143145
     146#if USE(UIKIT_KEYBOARD_ADDITIONS)
     147
     148// Evernote expects to swizzle -keyCommands on WKContentView or they crash. Remove this hack
     149// as soon as reasonably possible. See <rdar://problem/51759247>.
     150static NSArray *keyCommandsPlaceholderHackForEvernote(id self, SEL _cmd)
     151{
     152    struct objc_super super { 0 };
     153    super.receiver = self;
     154    super.super_class = class_getSuperclass(object_getClass(self));
     155
     156    using SuperKeyCommandsFunction = NSArray *(*)(struct objc_super*, SEL);
     157    return reinterpret_cast<SuperKeyCommandsFunction>(&objc_msgSendSuper)(&super, @selector(keyCommands));
     158}
     159
     160#endif
     161
    144162- (instancetype)_commonInitializationWithProcessPool:(WebKit::WebProcessPool&)processPool configuration:(Ref<API::PageConfiguration>&&)configuration
    145163{
     
    187205    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:[UIApplication sharedApplication]];
    188206    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:[UIApplication sharedApplication]];
     207
     208#if USE(UIKIT_KEYBOARD_ADDITIONS)
     209    if (WebCore::IOSApplication::isEvernote() && !linkedOnOrAfter(WebKit::SDKVersion::FirstWhereWKContentViewDoesNotOverrideKeyCommands))
     210        class_addMethod(self.class, @selector(keyCommands), reinterpret_cast<IMP>(&keyCommandsPlaceholderHackForEvernote), method_getTypeEncoding(class_getInstanceMethod(self.class, @selector(keyCommands))));
     211#endif
    189212
    190213    return self;
Note: See TracChangeset for help on using the changeset viewer.