Title: [246664] trunk/Source
- Revision
- 246664
- Author
- dba...@webkit.org
- Date
- 2019-06-20 17:49:14 -0700 (Thu, 20 Jun 2019)
Log 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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (246663 => 246664)
--- trunk/Source/WebCore/ChangeLog 2019-06-20 23:53:22 UTC (rev 246663)
+++ trunk/Source/WebCore/ChangeLog 2019-06-21 00:49:14 UTC (rev 246664)
@@ -1,3 +1,18 @@
+2019-06-20 Daniel Bates <daba...@apple.com>
+
+ [iOS] Evernote crashes when creating a note
+ https://bugs.webkit.org/show_bug.cgi?id=199083
+ <rdar://problem/51759247>
+
+ Reviewed by Brent Fulgham.
+
+ 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.
+
2019-06-20 Greg Doolittle <g...@apple.com>
Web Inspector: AXI: Audit: image label test is throwing spurious errors on elements with existing alt attr, but no value: <img alt>
Modified: trunk/Source/WebCore/platform/RuntimeApplicationChecks.h (246663 => 246664)
--- trunk/Source/WebCore/platform/RuntimeApplicationChecks.h 2019-06-20 23:53:22 UTC (rev 246663)
+++ trunk/Source/WebCore/platform/RuntimeApplicationChecks.h 2019-06-21 00:49:14 UTC (rev 246664)
@@ -92,6 +92,7 @@
bool isMoviStarPlus();
WEBCORE_EXPORT bool isFirefox();
WEBCORE_EXPORT bool isAppleApplication();
+WEBCORE_EXPORT bool isEvernote();
} // IOSApplication
Modified: trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm (246663 => 246664)
--- trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm 2019-06-20 23:53:22 UTC (rev 246663)
+++ trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm 2019-06-21 00:49:14 UTC (rev 246664)
@@ -294,6 +294,12 @@
return isAppleApplication;
}
+bool IOSApplication::isEvernote()
+{
+ static bool isEvernote = applicationBundleIsEqualTo("com.evernote.iPhone.Evernote"_s);
+ return isEvernote;
+}
+
#endif
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (246663 => 246664)
--- trunk/Source/WebKit/ChangeLog 2019-06-20 23:53:22 UTC (rev 246663)
+++ trunk/Source/WebKit/ChangeLog 2019-06-21 00:49:14 UTC (rev 246664)
@@ -1,3 +1,22 @@
+2019-06-20 Daniel Bates <daba...@apple.com>
+
+ [iOS] Evernote crashes when creating a note
+ https://bugs.webkit.org/show_bug.cgi?id=199083
+ <rdar://problem/51759247>
+
+ Reviewed by Brent Fulgham.
+
+ 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.
+
2019-06-20 Brady Eidson <beid...@apple.com>
WebURLSchemeHandlerProxy::loadSynchronously crash with sync request.
Modified: trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h (246663 => 246664)
--- trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h 2019-06-20 23:53:22 UTC (rev 246663)
+++ trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h 2019-06-21 00:49:14 UTC (rev 246664)
@@ -73,6 +73,7 @@
FirstWithExceptionsForRelatedWebViewsUsingDifferentDataStores = DYLD_IOS_VERSION_FIRST_WITH_EXCEPTIONS_FOR_RELATED_WEBVIEWS_USING_DIFFERENT_DATA_STORES,
FirstWithModernCompabilityModeByDefault = DYLD_IOS_VERSION_FIRST_WITH_MODERN_COMPATIBILITY_MODE_BY_DEFAULT,
FirstThatHasUIContextMenuInteraction = DYLD_IOS_VERSION_13_0,
+ FirstWhereWKContentViewDoesNotOverrideKeyCommands = DYLD_IOS_VERSION_13_0,
#elif PLATFORM(MAC)
FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
FirstWithExceptionsForDuplicateCompletionHandlerCalls = DYLD_MACOSX_VERSION_10_13,
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentView.mm (246663 => 246664)
--- trunk/Source/WebKit/UIProcess/ios/WKContentView.mm 2019-06-20 23:53:22 UTC (rev 246663)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentView.mm 2019-06-21 00:49:14 UTC (rev 246664)
@@ -60,7 +60,9 @@
#import <WebCore/NotImplemented.h>
#import <WebCore/PlatformScreen.h>
#import <WebCore/Quirks.h>
+#import <WebCore/RuntimeApplicationChecks.h>
#import <WebCore/VelocityData.h>
+#import <objc/message.h>
#import <pal/spi/cocoa/QuartzCoreSPI.h>
#import <wtf/RetainPtr.h>
#import <wtf/text/TextStream.h>
@@ -141,6 +143,22 @@
RetainPtr<CGPDFDocumentRef> _printedDocument;
}
+#if USE(UIKIT_KEYBOARD_ADDITIONS)
+
+// Evernote expects to swizzle -keyCommands on WKContentView or they crash. Remove this hack
+// as soon as reasonably possible. See <rdar://problem/51759247>.
+static NSArray *keyCommandsPlaceholderHackForEvernote(id self, SEL _cmd)
+{
+ struct objc_super super { 0 };
+ super.receiver = self;
+ super.super_class = class_getSuperclass(object_getClass(self));
+
+ using SuperKeyCommandsFunction = NSArray *(*)(struct objc_super*, SEL);
+ return reinterpret_cast<SuperKeyCommandsFunction>(&objc_msgSendSuper)(&super, @selector(keyCommands));
+}
+
+#endif
+
- (instancetype)_commonInitializationWithProcessPool:(WebKit::WebProcessPool&)processPool configuration:(Ref<API::PageConfiguration>&&)configuration
{
ASSERT(_pageClient);
@@ -187,6 +205,11 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:[UIApplication sharedApplication]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:[UIApplication sharedApplication]];
+#if USE(UIKIT_KEYBOARD_ADDITIONS)
+ if (WebCore::IOSApplication::isEvernote() && !linkedOnOrAfter(WebKit::SDKVersion::FirstWhereWKContentViewDoesNotOverrideKeyCommands))
+ class_addMethod(self.class, @selector(keyCommands), reinterpret_cast<IMP>(&keyCommandsPlaceholderHackForEvernote), method_getTypeEncoding(class_getInstanceMethod(self.class, @selector(keyCommands))));
+#endif
+
return self;
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes