Skip to content

Commit b6073a3

Browse files
committed
[Cocoa] Push applicationSDKVersion() down from WebCore into WTF
https://bugs.webkit.org/show_bug.cgi?id=209030 Reviewed by Simon Fraser. Source/JavaScriptCore: dyld_get_program_sdk_version() gives you the wrong answer in the Web Process (or at least not the answer you actually want). There are already facilities for the UI Process to tell the Web Process what the real value is, but those functions are currently in WebCore, which is inaccessible to WTF. This patch is in preparation for https://bugs.webkit.org/show_bug.cgi?id=208969 which needs to know this information in WTF. I also found a few places which were calling dyld_get_program_sdk_version() in JavaScriptCore and WebCore (which is wrong because those libraries exist in the Web Process), and have fixed them up to use applicationSDKVersion() instead. * API/JSWrapperMap.mm: (supportsInitMethodConstructors): Source/WebCore: * html/HTMLObjectElement.cpp: * html/MediaElementSession.cpp: (WebCore::MediaElementSession::requiresFullscreenForVideoPlayback const): * loader/DocumentThreadableLoader.cpp: (WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequest): * platform/RuntimeApplicationChecks.h: * platform/Timer.cpp: (WebCore::shouldSuppressThreadSafetyCheck): * platform/cocoa/RuntimeApplicationChecksCocoa.mm: (WebCore::applicationSDKVersionOverride): Deleted. (WebCore::setApplicationSDKVersion): Deleted. (WebCore::applicationSDKVersion): Deleted. Source/WebKit: * NetworkProcess/cocoa/NetworkProcessCocoa.mm: (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa): * Shared/WebPreferencesDefaultValues.cpp: (WebKit::defaultCSSOMViewScrollingAPIEnabled): * WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::WebProcess::platformInitializeWebProcess): Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/PlatformMac.cmake: * wtf/cocoa/RuntimeApplicationChecksCocoa.cpp: Added. * wtf/cocoa/RuntimeApplicationChecksCocoa.h: Added. (WTF::applicationSDKVersionOverride): (WTF::setApplicationSDKVersion): (WTF::applicationSDKVersion): Canonical link: https://commits.webkit.org/221992@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258447 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 0ea0d01 commit b6073a3

18 files changed

Lines changed: 188 additions & 36 deletions

Source/JavaScriptCore/API/JSWrapperMap.mm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
#import "WeakGCMap.h"
4141
#import "WeakGCMapInlines.h"
4242
#import <wtf/Vector.h>
43-
#import <wtf/spi/darwin/dyldSPI.h>
43+
44+
#if PLATFORM(COCOA)
45+
#import <wtf/cocoa/RuntimeApplicationChecksCocoa.h>
46+
#endif
4447

4548
#include <mach-o/dyld.h>
4649

@@ -720,7 +723,7 @@ bool supportsInitMethodConstructors()
720723
// base our check on what SDK was used to build the application.
721724
static uint32_t programSDKVersion = 0;
722725
if (!programSDKVersion)
723-
programSDKVersion = dyld_get_program_sdk_version();
726+
programSDKVersion = applicationSDKVersion();
724727

725728
return programSDKVersion >= firstSDKVersionWithInitConstructorSupport;
726729
#endif

Source/JavaScriptCore/ChangeLog

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
2020-03-13 Myles C. Maxfield <[email protected]>
2+
3+
[Cocoa] Push applicationSDKVersion() down from WebCore into WTF
4+
https://bugs.webkit.org/show_bug.cgi?id=209030
5+
6+
Reviewed by Simon Fraser.
7+
8+
dyld_get_program_sdk_version() gives you the wrong answer in the Web Process (or at least
9+
not the answer you actually want). There are already facilities for the UI Process to tell
10+
the Web Process what the real value is, but those functions are currently in WebCore,
11+
which is inaccessible to WTF. This patch is in preparation for
12+
https://bugs.webkit.org/show_bug.cgi?id=208969 which needs to know this information in WTF.
13+
14+
I also found a few places which were calling dyld_get_program_sdk_version() in JavaScriptCore
15+
and WebCore (which is wrong because those libraries exist in the Web Process), and have fixed
16+
them up to use applicationSDKVersion() instead.
17+
18+
* API/JSWrapperMap.mm:
19+
(supportsInitMethodConstructors):
20+
121
2020-03-13 Yusuke Suzuki <[email protected]>
222

323
[JSC] Reload CodeBlock or suppress GC while setting up calls

Source/WTF/ChangeLog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
2020-03-13 Myles C. Maxfield <[email protected]>
2+
3+
[Cocoa] Push applicationSDKVersion() down from WebCore into WTF
4+
https://bugs.webkit.org/show_bug.cgi?id=209030
5+
6+
Reviewed by Simon Fraser.
7+
8+
* WTF.xcodeproj/project.pbxproj:
9+
* wtf/PlatformMac.cmake:
10+
* wtf/cocoa/RuntimeApplicationChecksCocoa.cpp: Added.
11+
* wtf/cocoa/RuntimeApplicationChecksCocoa.h: Added.
12+
(WTF::applicationSDKVersionOverride):
13+
(WTF::setApplicationSDKVersion):
14+
(WTF::applicationSDKVersion):
15+
116
2020-03-11 Jer Noble <[email protected]>
217

318
Adopt AVSampleBufferVideoOutput

Source/WTF/WTF.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
1C181C931D307AB800F5FA16 /* UTextProviderUTF16.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C181C8D1D307AB800F5FA16 /* UTextProviderUTF16.cpp */; };
6262
1C181C961D30800A00F5FA16 /* TextBreakIteratorInternalICUCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C181C951D30800A00F5FA16 /* TextBreakIteratorInternalICUCocoa.cpp */; };
6363
1C503BE623AAE0AE0072E66B /* LanguageCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C503BE523AAE0AE0072E66B /* LanguageCocoa.mm */; };
64+
1CA85CA9241B0B260071C2F5 /* RuntimeApplicationChecksCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CA85CA8241B0B260071C2F5 /* RuntimeApplicationChecksCocoa.cpp */; };
6465
1FA47C8A152502DA00568D1B /* WebCoreThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1FA47C88152502DA00568D1B /* WebCoreThread.cpp */; };
6566
2CCD892A15C0390200285083 /* GregorianDateTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CCD892915C0390200285083 /* GregorianDateTime.cpp */; };
6667
2CDED0EF18115C38004DBA70 /* RunLoopCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CDED0EE18115C38004DBA70 /* RunLoopCF.cpp */; };
@@ -344,6 +345,8 @@
344345
1C181C951D30800A00F5FA16 /* TextBreakIteratorInternalICUCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextBreakIteratorInternalICUCocoa.cpp; sourceTree = "<group>"; };
345346
1C503BE423AADEEA0072E66B /* NSLocaleSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSLocaleSPI.h; sourceTree = "<group>"; };
346347
1C503BE523AAE0AE0072E66B /* LanguageCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LanguageCocoa.mm; sourceTree = "<group>"; };
348+
1CA85CA7241B0B110071C2F5 /* RuntimeApplicationChecksCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RuntimeApplicationChecksCocoa.h; sourceTree = "<group>"; };
349+
1CA85CA8241B0B260071C2F5 /* RuntimeApplicationChecksCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RuntimeApplicationChecksCocoa.cpp; sourceTree = "<group>"; };
347350
1CCDB1491E566626006C73C0 /* TextBreakIteratorCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextBreakIteratorCF.h; sourceTree = "<group>"; };
348351
1CCDB14D1E566898006C73C0 /* TextBreakIteratorICU.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextBreakIteratorICU.h; sourceTree = "<group>"; };
349352
1CCDB1511E566BC5006C73C0 /* CFStringSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFStringSPI.h; sourceTree = "<group>"; };
@@ -1516,6 +1519,8 @@
15161519
5CC0EE872162BC2200A1A842 /* NSURLExtras.h */,
15171520
5CC0EE882162BC2200A1A842 /* NSURLExtras.mm */,
15181521
E392FA2622E92BFF00ECDC73 /* ResourceUsageCocoa.cpp */,
1522+
1CA85CA8241B0B260071C2F5 /* RuntimeApplicationChecksCocoa.cpp */,
1523+
1CA85CA7241B0B110071C2F5 /* RuntimeApplicationChecksCocoa.h */,
15191524
A30D412C1F0DE0BA00B71954 /* SoftLinking.h */,
15201525
EB61EDC62409CCC0001EFE36 /* SystemTracingCocoa.cpp */,
15211526
5CC0EE862162BC2200A1A842 /* URLCocoa.mm */,
@@ -1699,6 +1704,7 @@
16991704
2CDED0F318115C85004DBA70 /* RunLoop.cpp in Sources */,
17001705
2CDED0EF18115C38004DBA70 /* RunLoopCF.cpp in Sources */,
17011706
A3EE5C3E21FFAC7D00FABD61 /* RunLoopTimerCF.cpp in Sources */,
1707+
1CA85CA9241B0B260071C2F5 /* RuntimeApplicationChecksCocoa.cpp in Sources */,
17021708
A3EE5C3D21FFAC7D00FABD61 /* SchedulePairCF.cpp in Sources */,
17031709
A3EE5C4021FFACA200FABD61 /* SchedulePairMac.mm in Sources */,
17041710
0F66B28E1DC97BAB004A1D3F /* Seconds.cpp in Sources */,

Source/WTF/wtf/PlatformMac.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ list(APPEND WTF_PUBLIC_HEADERS
1616
cocoa/CrashReporter.h
1717
cocoa/Entitlements.h
1818
cocoa/NSURLExtras.h
19+
cocoa/RuntimeApplicationChecksCocoa.h
1920
cocoa/SoftLinking.h
2021

2122
darwin/WeakLinking.h
@@ -65,6 +66,7 @@ list(APPEND WTF_SOURCES
6566
cocoa/MemoryPressureHandlerCocoa.mm
6667
cocoa/NSURLExtras.mm
6768
cocoa/ResourceUsageCocoa.cpp
69+
cocoa/RuntimeApplicationChecksCocoa.cpp
6870
cocoa/SystemTracingCocoa.cpp
6971
cocoa/URLCocoa.mm
7072
cocoa/WorkQueueCocoa.cpp
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (C) 2011-2020 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "config.h"
27+
#include <wtf/cocoa/RuntimeApplicationChecksCocoa.h>
28+
29+
#include <wtf/NeverDestroyed.h>
30+
#include <wtf/Optional.h>
31+
32+
namespace WTF {
33+
34+
static Optional<uint32_t>& applicationSDKVersionOverride()
35+
{
36+
static NeverDestroyed<Optional<uint32_t>> version;
37+
return version;
38+
}
39+
40+
void setApplicationSDKVersion(uint32_t version)
41+
{
42+
applicationSDKVersionOverride() = version;
43+
}
44+
45+
uint32_t applicationSDKVersion()
46+
{
47+
if (applicationSDKVersionOverride())
48+
return *applicationSDKVersionOverride();
49+
return dyld_get_program_sdk_version();
50+
}
51+
52+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (C) 2009-2020 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the
12+
* documentation and/or other materials provided with the distribution.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17+
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#pragma once
27+
28+
#include <wtf/Forward.h>
29+
30+
// This contains the values with which to compare the return value of applicationSDKVersion().
31+
#include <wtf/spi/darwin/dyldSPI.h>
32+
33+
namespace WTF {
34+
35+
// dyld_get_program_sdk_version() gives you the wrong answer in any process other than the UI process.
36+
// These functions are hooked up to give you the right answer.
37+
WTF_EXPORT_PRIVATE void setApplicationSDKVersion(uint32_t);
38+
WTF_EXPORT_PRIVATE uint32_t applicationSDKVersion();
39+
40+
}
41+
42+
using WTF::setApplicationSDKVersion;
43+
using WTF::applicationSDKVersion;

Source/WebCore/ChangeLog

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
2020-03-13 Myles C. Maxfield <[email protected]>
2+
3+
[Cocoa] Push applicationSDKVersion() down from WebCore into WTF
4+
https://bugs.webkit.org/show_bug.cgi?id=209030
5+
6+
Reviewed by Simon Fraser.
7+
8+
* html/HTMLObjectElement.cpp:
9+
* html/MediaElementSession.cpp:
10+
(WebCore::MediaElementSession::requiresFullscreenForVideoPlayback const):
11+
* loader/DocumentThreadableLoader.cpp:
12+
(WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequest):
13+
* platform/RuntimeApplicationChecks.h:
14+
* platform/Timer.cpp:
15+
(WebCore::shouldSuppressThreadSafetyCheck):
16+
* platform/cocoa/RuntimeApplicationChecksCocoa.mm:
17+
(WebCore::applicationSDKVersionOverride): Deleted.
18+
(WebCore::setApplicationSDKVersion): Deleted.
19+
(WebCore::applicationSDKVersion): Deleted.
20+
121
2020-03-13 Jiewen Tan <[email protected]>
222

323
[WebAuthn] Customize a bit more on the macOS LocalAuthentication prompt

Source/WebCore/html/HTMLObjectElement.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454

5555
#if PLATFORM(IOS_FAMILY)
5656
#include "RuntimeApplicationChecks.h"
57-
#include <wtf/spi/darwin/dyldSPI.h>
5857
#endif
5958

6059
namespace WebCore {

Source/WebCore/html/MediaElementSession.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#if PLATFORM(IOS_FAMILY)
5555
#include "AudioSession.h"
5656
#include "RuntimeApplicationChecks.h"
57-
#include <wtf/spi/darwin/dyldSPI.h>
57+
#include <wtf/cocoa/RuntimeApplicationChecksCocoa.h>
5858
#endif
5959

6060
namespace WebCore {
@@ -738,7 +738,7 @@ bool MediaElementSession::requiresFullscreenForVideoPlayback() const
738738
#if PLATFORM(IOS_FAMILY)
739739
if (IOSApplication::isIBooks())
740740
return !m_element.hasAttributeWithoutSynchronization(HTMLNames::webkit_playsinlineAttr) && !m_element.hasAttributeWithoutSynchronization(HTMLNames::playsinlineAttr);
741-
if (dyld_get_program_sdk_version() < DYLD_IOS_VERSION_10_0)
741+
if (applicationSDKVersion() < DYLD_IOS_VERSION_10_0)
742742
return !m_element.hasAttributeWithoutSynchronization(HTMLNames::webkit_playsinlineAttr);
743743
#endif
744744

0 commit comments

Comments
 (0)