Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move some WebKit code to WebKit framework #21058

Conversation

pvollan
Copy link
Contributor

@pvollan pvollan commented Nov 29, 2023

c0b5c33

Move some WebKit code to WebKit framework
https://bugs.webkit.org/show_bug.cgi?id=265324
rdar://118776213

Reviewed by Brent Fulgham.

Move some WebKit code related to WebKit process extensions to WebKit framework. This change enables
us to use new assertion API to take out an assertion on the Networking process when holding locked
files, which is also included in this patch.

* Source/WebKit/NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::setIsHoldingLockedFiles):
* Source/WebKit/NetworkProcess/NetworkProcess.h:
* Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::aqcuireLockedFileGrant):
(WebKit::NetworkProcess::invalidateGrant):
(WebKit::NetworkProcess::hasAcquiredGrant const):
* Source/WebKit/Shared/AuxiliaryProcessExtensions/NetworkingProcessExtension.swift:
(NetworkingProcessExtension.handle(_:)):
* Source/WebKit/Shared/AuxiliaryProcessExtensions/WebKitProcessExtension.swift: Copied from Source/WebKit/Shared/AuxiliaryProcessExtensions/NetworkingProcessExtension.swift.
(WKProcessExtension.sharedInstance):
(WKNetworkingProcessExtension.handle(_:)):
(WKNetworkingProcessExtension.grant(_:name:)):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

Canonical link: https://commits.webkit.org/271326@main

aaecd27

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-wpe
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ›  gtk
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ gtk-wk2
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv-sim
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@pvollan pvollan requested a review from cdumez as a code owner November 29, 2023 19:17
@pvollan pvollan self-assigned this Nov 29, 2023
@pvollan pvollan added the WebKit Misc. For miscellaneous bugs in the WebKit framework (and not JavaScriptCore or WebCore). label Nov 29, 2023
@pvollan pvollan force-pushed the eng/Move-some-WebKit-code-to-WebKit-framework branch from ab980c1 to 7ace39f Compare November 29, 2023 19:40
Copy link
Contributor

@emw-apple emw-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not thrilled about adding Swift code into the main WebKit target at this time, for a couple of reasons:

  • There's a build time cost of turning WebKit into a three-stage compilation process. By adding Swift to the target, we have to, in sequence, compile the module interface; then the swift code; then the rest of the code.
  • This change is iOS only, so it would modify the build in a way that's not uniform across the Xcode-based platforms.

Comment on lines 239 to 241
EXCLUDED_EXTENSION_SOURCE_FILE_NAMES = Shared/AuxiliaryProcessExtensions/*;
EXCLUDED_EXTENSION_SOURCE_FILE_NAMES[sdk=iphoneos17.4.internal] = ;
EXCLUDED_EXTENSION_SOURCE_FILE_NAMES[sdk=iphonesimulator17.4.internal] = ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend inverting this and adding some extra boilerplate to prevent this from being immediately out of date in future iOS versions.

Suggested change
EXCLUDED_EXTENSION_SOURCE_FILE_NAMES = Shared/AuxiliaryProcessExtensions/*;
EXCLUDED_EXTENSION_SOURCE_FILE_NAMES[sdk=iphoneos17.4.internal] = ;
EXCLUDED_EXTENSION_SOURCE_FILE_NAMES[sdk=iphonesimulator17.4.internal] = ;
EXCLUDED_EXTENSION_SOURCE_FILE_NAMES = Shared/AuxiliaryProcessExtensions/*;
// already defined further down…
INCLUDED_SOURCE_FILE_NAMES = $(INCLUDED_EXTENSION_SOURCE_FILE_NAMES_$(USE_INTERNAL_SDK));
INCLUDED_EXTENSION_SOURCE_FILE_NAMES_YES[sdk=iphone*] = Shared/AuxiliaryProcessExtensions/*;
INCLUDED_EXTENSION_SOURCE_FILE_NAMES_YES[sdk=iphone*17.0.internal] = ;
INCLUDED_EXTENSION_SOURCE_FILE_NAMES_YES[sdk=iphone*17.1.internal] = ;
INCLUDED_EXTENSION_SOURCE_FILE_NAMES_YES[sdk=iphone*17.2.internal] = ;
INCLUDED_EXTENSION_SOURCE_FILE_NAMES_YES[sdk=iphone*17.3.internal] = ;```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's a good point. I have updated the patch with this change.

Thanks for reviewing!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't mean for you to write "already defined further down…" literally. There is already a INCLUDED_SOURCE_FILE_NAMES definition in the file, so this change needs to be incorporated to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I realized that when I built locally :)

Thanks for reviewing!

@@ -54,6 +54,11 @@
#import <pal/spi/cocoa/NEFilterSourceSPI.h>
#endif

#if USE(EXTENSIONKIT) && __has_include(<WebKit-Swift.h>)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? It seems like USE(EXTENSIONKIT) implies that we're compiling swift code and generating the Swift header.

#if USE(RUNNINGBOARD) && USE(EXTENSIONKIT)
bool NetworkProcess::aqcuireLockedFileGrant()
{
#if __has_include(<WebKit-Swift.h>)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was resolved by your request to invert the logic above.

@pvollan pvollan force-pushed the eng/Move-some-WebKit-code-to-WebKit-framework branch from 7ace39f to 92cb264 Compare November 29, 2023 20:15
@pvollan pvollan force-pushed the eng/Move-some-WebKit-code-to-WebKit-framework branch from 92cb264 to 8e040af Compare November 29, 2023 21:40
Comment on lines 30 to 31
SWIFT_OBJC_BRIDGING_HEADER[sdk=iphoneos17.4.internal] = Shared/AuxiliaryProcessExtensions/AuxiliaryProcessExtensionBridge.h;
SWIFT_OBJC_BRIDGING_HEADER[sdk=iphonesimulator17.4.internal] = Shared/AuxiliaryProcessExtensions/AuxiliaryProcessExtensionBridge.h;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to do a similar dance here: make this setting the default, and then override it to empty on 17.0-17.3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

Comment on lines 39 to 41
EXCLUDED_SOURCE_FILE_NAMES = *;
EXCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos17.4.internal] = ;
EXCLUDED_SOURCE_FILE_NAMES[sdk=iphonesimulator17.4.internal] = ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto. Here, it's may be to do something like:

Suggested change
EXCLUDED_SOURCE_FILE_NAMES = *;
EXCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos17.4.internal] = ;
EXCLUDED_SOURCE_FILE_NAMES[sdk=iphonesimulator17.4.internal] = ;
EXCLUDED_SOURCE_FILE_NAMES = $(EXCLUDED_SOURCE_FILE_NAMES_$(USE_INTERNAL_SDK));;
EXCLUDED_SOURCE_FILE_NAMES_ = *;
EXCLUDED_SOURCE_FILE_NAMES_YES = *;
EXCLUDED_SOURCE_FILE_NAMES_YES[sdk=iphone*] = ;
EXCLUDED_SOURCE_FILE_NAMES_YES[sdk=iphone*17.0*] = *;
EXCLUDED_SOURCE_FILE_NAMES_YES[sdk=iphone*17.1*] = *;
EXCLUDED_SOURCE_FILE_NAMES_YES[sdk=iphone*17.2*] = *;
EXCLUDED_SOURCE_FILE_NAMES_YES[sdk=iphone*17.3*] = *;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch, will fix!

@pvollan pvollan force-pushed the eng/Move-some-WebKit-code-to-WebKit-framework branch from 8e040af to aaecd27 Compare November 29, 2023 22:41
Copy link
Contributor

@emw-apple emw-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per Arne and I talked and we're going to land this as-is, with a plan to remove the Swift code from the WebKit target as a follow-up.

One benefit of this is that it'll help quantify the cost of introducing Swift to the main target.

@pvollan pvollan added the merge-queue Applied to send a pull request to merge-queue label Nov 30, 2023
https://bugs.webkit.org/show_bug.cgi?id=265324
rdar://118776213

Reviewed by Brent Fulgham.

Move some WebKit code related to WebKit process extensions to WebKit framework. This change enables
us to use new assertion API to take out an assertion on the Networking process when holding locked
files, which is also included in this patch.

* Source/WebKit/NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::setIsHoldingLockedFiles):
* Source/WebKit/NetworkProcess/NetworkProcess.h:
* Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::aqcuireLockedFileGrant):
(WebKit::NetworkProcess::invalidateGrant):
(WebKit::NetworkProcess::hasAcquiredGrant const):
* Source/WebKit/Shared/AuxiliaryProcessExtensions/NetworkingProcessExtension.swift:
(NetworkingProcessExtension.handle(_:)):
* Source/WebKit/Shared/AuxiliaryProcessExtensions/WebKitProcessExtension.swift: Copied from Source/WebKit/Shared/AuxiliaryProcessExtensions/NetworkingProcessExtension.swift.
(WKProcessExtension.sharedInstance):
(WKNetworkingProcessExtension.handle(_:)):
(WKNetworkingProcessExtension.grant(_:name:)):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

Canonical link: https://commits.webkit.org/271326@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Move-some-WebKit-code-to-WebKit-framework branch from aaecd27 to c0b5c33 Compare November 30, 2023 04:48
@webkit-commit-queue
Copy link
Collaborator

Committed 271326@main (c0b5c33): https://commits.webkit.org/271326@main

Reviewed commits have been landed. Closing PR #21058 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit c0b5c33 into WebKit:main Nov 30, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit Misc. For miscellaneous bugs in the WebKit framework (and not JavaScriptCore or WebCore).
Projects
None yet
4 participants