Title: [269279] trunk/Source
Revision
269279
Author
[email protected]
Date
2020-11-02 16:40:51 -0800 (Mon, 02 Nov 2020)

Log 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]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (269278 => 269279)


--- trunk/Source/WebCore/ChangeLog	2020-11-03 00:05:20 UTC (rev 269278)
+++ trunk/Source/WebCore/ChangeLog	2020-11-03 00:40:51 UTC (rev 269279)
@@ -1,3 +1,20 @@
+2020-11-02  Devin Rousso  <[email protected]>
+
+        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.
+
+        * platform/cocoa/VersionChecks.h:
+        This appears to be the first instance of observing a class property, so add a new version
+        value for `FirstThatObservesClassProperty`.
+
 2020-11-02  Chris Dumez  <[email protected]>
 
         REGRESSION (r269227): Crash in WebCore::WorkerOrWorkletGlobalScope::prepareForDestruction

Modified: trunk/Source/WebCore/platform/cocoa/VersionChecks.h (269278 => 269279)


--- trunk/Source/WebCore/platform/cocoa/VersionChecks.h	2020-11-03 00:05:20 UTC (rev 269278)
+++ trunk/Source/WebCore/platform/cocoa/VersionChecks.h	2020-11-03 00:40:51 UTC (rev 269279)
@@ -65,6 +65,7 @@
     FirstWithWKWebsiteDataStoreInitReturningNil = DYLD_IOS_VERSION_14_0,
     FirstVersionWithiOSAppsOnMacOS = DYLD_IOS_VERSION_FIRST_WITH_IOS_APPS_ON_MACOS,
     FirstWithDataURLFragmentRemoval = DYLD_IOS_VERSION_14_5,
+    FirstThatObservesClassProperty = DYLD_IOS_VERSION_14_5,
 #elif PLATFORM(MAC)
     FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11,
     FirstWithExceptionsForDuplicateCompletionHandlerCalls = DYLD_MACOSX_VERSION_10_13,

Modified: trunk/Source/WebKit/ChangeLog (269278 => 269279)


--- trunk/Source/WebKit/ChangeLog	2020-11-03 00:05:20 UTC (rev 269278)
+++ trunk/Source/WebKit/ChangeLog	2020-11-03 00:40:51 UTC (rev 269279)
@@ -1,3 +1,20 @@
+2020-11-02  Devin Rousso  <[email protected]>
+
+        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.
+
+        * UIProcess/ios/WKStylusDeviceObserver.mm:
+        (-[WKStylusDeviceObserver start]):
+        (-[WKStylusDeviceObserver stop]):
+
 2020-11-02  James Savage  <[email protected]>
 
         Changes to SWIFT_MODULE_ONLY_ARCHS

Modified: trunk/Source/WebKit/UIProcess/ios/WKStylusDeviceObserver.mm (269278 => 269279)


--- trunk/Source/WebKit/UIProcess/ios/WKStylusDeviceObserver.mm	2020-11-03 00:05:20 UTC (rev 269278)
+++ trunk/Source/WebKit/UIProcess/ios/WKStylusDeviceObserver.mm	2020-11-03 00:40:51 UTC (rev 269279)
@@ -30,6 +30,7 @@
 
 #import "WebProcessProxy.h"
 #import <UIKit/UIScribbleInteraction.h>
+#import <WebCore/VersionChecks.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/Seconds.h>
 
@@ -83,7 +84,8 @@
     if (++_startCount > 1)
         return;
 
-    [[UIScribbleInteraction class] addObserver:self forKeyPath:@"isPencilInputExpected" options:NSKeyValueObservingOptionInitial context:nil];
+    if (WebCore::linkedOnOrAfter(WebCore::SDKVersion::FirstThatObservesClassProperty))
+        [[UIScribbleInteraction class] addObserver:self forKeyPath:@"isPencilInputExpected" options:NSKeyValueObservingOptionInitial context:nil];
 }
 
 - (void)stop
@@ -92,7 +94,8 @@
     if (!_startCount || --_startCount)
         return;
 
-    [[UIScribbleInteraction class] removeObserver:self forKeyPath:@"isPencilInputExpected"];
+    if (WebCore::linkedOnOrAfter(WebCore::SDKVersion::FirstThatObservesClassProperty))
+        [[UIScribbleInteraction class] removeObserver:self forKeyPath:@"isPencilInputExpected"];
 }
 
 #pragma mark - isPencilInputExpected KVO
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to