Changeset 261157 in webkit


Ignore:
Timestamp:
May 5, 2020 2:03:21 AM (4 years ago)
Author:
timothy_horton@apple.com
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.

Source/WebKit:

  • 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.

Tools:

  • TestWebKitAPI/ios/UserInterfaceSwizzler.h:

We need a UIApplication or WebKit won't look at UIDevice.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r261155 r261157  
     12020-05-05  Tim Horton  <timothy_horton@apple.com>
     2
     3        Excessive error logging from daemons trying to use WebKit, under -[UIDevice currentDevice]
     4        https://bugs.webkit.org/show_bug.cgi?id=211397
     5        <rdar://problem/61635403>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * Shared/UserInterfaceIdiom.mm:
     10        (WebKit::userInterfaceIdiomIsPad):
     11        Adjust userInterfaceIdiomIsPad so that in daemons, it consults only MobileGestalt,
     12        which returns the actual hardware model, and does not try to use UIDevice.
     13        UIDevice is more accurate for applications because it will report that
     14        the device is an iPhone when called inside an iPhone app running on iPad,
     15        but it cannot be used in daemons that do not have a UIApplication.
     16       
     17        For the behaviors we gate on this bit, it makes sense to use iPhone
     18        behaviors on iPad in the iPhone app jail, so we continue using
     19        UIDevice if possible.
     20
     21        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
     22        (-[WKWebViewConfiguration init]):
     23        Make use of the new mechanism instead of going straight to MobileGestalt,
     24        for the aforementioned reasons.
     25
    1262020-05-04  Tim Horton  <timothy_horton@apple.com>
    227
  • trunk/Source/WebKit/Shared/UserInterfaceIdiom.mm

    r261135 r261157  
    2929#if PLATFORM(IOS_FAMILY)
    3030
    31 #if USE(APPLE_INTERNAL_SDK)
    32 #import <UIKit/UIDevice_Private.h>
    33 #else
    34 #import <UIKit/UIDevice.h>
    35 #endif
     31#import "UIKitSPI.h"
     32#import <WebCore/Device.h>
    3633
    3734namespace WebKit {
     
    4542static UserInterfaceIdiomState userInterfaceIdiomIsPadState = UserInterfaceIdiomState::Unknown;
    4643
    47 #if PLATFORM(IOS_FAMILY)
    4844static inline bool userInterfaceIdiomIsPad()
    4945{
     46    // If we are in a daemon, we cannot use UIDevice. Fall back to checking the hardware itself.
     47    // Since daemons don't ever run in an iPhone-app-on-iPad jail, this will be accurate in the daemon case,
     48    // but is not sufficient in the application case.
     49    if (![UIApplication sharedApplication])
     50        return WebCore::deviceClass() == MGDeviceClassiPad;
     51
    5052    // This inline function exists to thwart unreachable code
    5153    // detection on platforms where UICurrentUserInterfaceIdiomIsPad
     
    5759#endif
    5860}
    59 #endif
    6061
    6162bool currentUserInterfaceIdiomIsPad()
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm

    r261135 r261157  
    2828
    2929#import "APIPageConfiguration.h"
     30#import "UserInterfaceIdiom.h"
    3031#import "VersionChecks.h"
    3132#import "WKPreferences.h"
     
    193194    _allowsPictureInPictureMediaPlayback = YES;
    194195#endif
    195     _allowsInlineMediaPlayback = WebCore::deviceClass() == MGDeviceClassiPad;
     196    _allowsInlineMediaPlayback = WebKit::currentUserInterfaceIdiomIsPad();
    196197    _inlineMediaPlaybackRequiresPlaysInlineAttribute = !_allowsInlineMediaPlayback;
    197198    _allowsInlineMediaPlaybackAfterFullscreen = !_allowsInlineMediaPlayback;
  • trunk/Tools/ChangeLog

    r261153 r261157  
     12020-05-05  Tim Horton  <timothy_horton@apple.com>
     2
     3        Excessive error logging from daemons trying to use WebKit, under -[UIDevice currentDevice]
     4        https://bugs.webkit.org/show_bug.cgi?id=211397
     5        <rdar://problem/61635403>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * TestWebKitAPI/ios/UserInterfaceSwizzler.h:
     10        We need a UIApplication or WebKit won't look at UIDevice.
     11
    1122020-05-04  Darin Adler  <darin@apple.com>
    213
  • trunk/Tools/TestWebKitAPI/ios/UserInterfaceSwizzler.h

    r260449 r261157  
    2929
    3030#import "InstanceMethodSwizzler.h"
     31#import "UIKitSPI.h"
    3132#import <UIKit/UIKit.h>
    3233
     
    3940        : InstanceMethodSwizzler { UIDevice.class, @selector(userInterfaceIdiom), reinterpret_cast<IMP>(effectiveUserInterfaceIdiom) }
    4041    {
     42        if (!UIApplication.sharedApplication) {
     43            UIApplicationInitialize();
     44            UIApplicationInstantiateSingleton(UIApplication.class);
     45        }
    4146    }
    4247
Note: See TracChangeset for help on using the changeset viewer.