Title: [261117] trunk/Source/WebKit
Revision
261117
Author
[email protected]
Date
2020-05-04 15:11:42 -0700 (Mon, 04 May 2020)

Log Message

Excessive error logging from daemons trying to use WebKit, under -[UIDevice currentDevice]
https://bugs.webkit.org/show_bug.cgi?id=211397
<rdar://problem/61635403>

Reviewed by Simon Fraser.

* Shared/UserInterfaceIdiom.mm:
(WebKit::userInterfaceIdiomIsPad):
Adjust userInterfaceIdiomIsPad so that in daemons, it consults only MobileGestalt,
which returns the actual hardware model, and does not try to use UIDevice.
UIDevice is more accurate for applications because it will report that
the device is an iPhone when called inside an iPhone app running on iPad,
but it cannot be used in daemons that do not have a UIApplication.

For the behaviors we gate on this bit, it makes sense to use iPhone
behaviors on iPad in the iPhone app jail, so we continue using
UIDevice if possible.

* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration init]):
Make use of the new mechanism instead of going straight to MobileGestalt,
for the aforementioned reasons.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (261116 => 261117)


--- trunk/Source/WebKit/ChangeLog	2020-05-04 22:08:46 UTC (rev 261116)
+++ trunk/Source/WebKit/ChangeLog	2020-05-04 22:11:42 UTC (rev 261117)
@@ -1,3 +1,28 @@
+2020-05-04  Tim Horton  <[email protected]>
+
+        Excessive error logging from daemons trying to use WebKit, under -[UIDevice currentDevice]
+        https://bugs.webkit.org/show_bug.cgi?id=211397
+        <rdar://problem/61635403>
+
+        Reviewed by Simon Fraser.
+
+        * Shared/UserInterfaceIdiom.mm:
+        (WebKit::userInterfaceIdiomIsPad):
+        Adjust userInterfaceIdiomIsPad so that in daemons, it consults only MobileGestalt,
+        which returns the actual hardware model, and does not try to use UIDevice.
+        UIDevice is more accurate for applications because it will report that
+        the device is an iPhone when called inside an iPhone app running on iPad,
+        but it cannot be used in daemons that do not have a UIApplication.
+        
+        For the behaviors we gate on this bit, it makes sense to use iPhone
+        behaviors on iPad in the iPhone app jail, so we continue using
+        UIDevice if possible.
+
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration init]):
+        Make use of the new mechanism instead of going straight to MobileGestalt,
+        for the aforementioned reasons.
+
 2020-05-04  Chris Dumez  <[email protected]>
 
         Stop hard-coding get-task-allow entitlement for simulator builds

Modified: trunk/Source/WebKit/Shared/UserInterfaceIdiom.mm (261116 => 261117)


--- trunk/Source/WebKit/Shared/UserInterfaceIdiom.mm	2020-05-04 22:08:46 UTC (rev 261116)
+++ trunk/Source/WebKit/Shared/UserInterfaceIdiom.mm	2020-05-04 22:11:42 UTC (rev 261117)
@@ -28,11 +28,8 @@
 
 #if PLATFORM(IOS_FAMILY)
 
-#if USE(APPLE_INTERNAL_SDK)
-#import <UIKit/UIDevice_Private.h>
-#else
-#import <UIKit/UIDevice.h>
-#endif
+#import "UIKitSPI.h"
+#import <WebCore/Device.h>
 
 namespace WebKit {
 
@@ -44,9 +41,14 @@
 
 static UserInterfaceIdiomState userInterfaceIdiomIsPadState = UserInterfaceIdiomState::Unknown;
 
-#if PLATFORM(IOS_FAMILY)
 static inline bool userInterfaceIdiomIsPad()
 {
+    // If we are in a dameon, we cannot use UIDevice. Fall back to checking the hardware itself.
+    // Since daemons don't ever run in an iPhone-app-on-iPad jail, this will be accurate in the daemon case,
+    // but is not sufficient in the application case.
+    if (![UIApplication sharedApplication])
+        return WebCore::deviceClass() == MGDeviceClassiPad;
+
     // This inline function exists to thwart unreachable code
     // detection on platforms where UICurrentUserInterfaceIdiomIsPad
     // is defined directly to false.
@@ -56,7 +58,6 @@
     return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad;
 #endif
 }
-#endif
 
 bool currentUserInterfaceIdiomIsPad()
 {

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (261116 => 261117)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2020-05-04 22:08:46 UTC (rev 261116)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm	2020-05-04 22:11:42 UTC (rev 261117)
@@ -27,6 +27,7 @@
 #import "WKWebViewConfigurationInternal.h"
 
 #import "APIPageConfiguration.h"
+#import "UserInterfaceIdiom.h"
 #import "VersionChecks.h"
 #import "WKPreferences.h"
 #import "WKProcessPool.h"
@@ -192,7 +193,7 @@
 #if !PLATFORM(WATCHOS)
     _allowsPictureInPictureMediaPlayback = YES;
 #endif
-    _allowsInlineMediaPlayback = WebCore::deviceClass() == MGDeviceClassiPad;
+    _allowsInlineMediaPlayback = WebKit::currentUserInterfaceIdiomIsPad();
     _inlineMediaPlaybackRequiresPlaysInlineAttribute = !_allowsInlineMediaPlayback;
     _allowsInlineMediaPlaybackAfterFullscreen = !_allowsInlineMediaPlayback;
     _mediaDataLoadsAutomatically = NO;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to