Bug 218314 - [Cocoa] Remove soft linking of NetworkExtension.framework
Summary: [Cocoa] Remove soft linking of NetworkExtension.framework
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Aditya Keerthi
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-10-28 16:20 PDT by Ryan Haddad
Modified: 2020-10-29 16:53 PDT (History)
6 users (show)

See Also:


Attachments
Patch (17.52 KB, patch)
2020-10-28 19:14 PDT, Aditya Keerthi
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (18.01 KB, patch)
2020-10-28 19:31 PDT, Aditya Keerthi
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (17.79 KB, patch)
2020-10-28 19:38 PDT, Aditya Keerthi
no flags Details | Formatted Diff | Diff
Patch (20.77 KB, patch)
2020-10-29 09:06 PDT, Aditya Keerthi
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Haddad 2020-10-28 16:20:44 PDT
TestWebKitAPI.ContentFiltering.LazilyLoadPlatformFrameworks
        
        /Volumes/Data/slave/catalina-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContentFiltering.mm:374
        Expected equality of these values:
          static_cast<bool>(networkExtensionShouldBeLoaded)
            Which is: false
          static_cast<bool>(networkExtensionLoaded)
            Which is: true
        
        
        /Volumes/Data/slave/catalina-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContentFiltering.mm:374
        Expected equality of these values:
          static_cast<bool>(networkExtensionShouldBeLoaded)
            Which is: false
          static_cast<bool>(networkExtensionLoaded)
            Which is: true
        
        
        /Volumes/Data/slave/catalina-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContentFiltering.mm:374
        Expected equality of these values:
          static_cast<bool>(networkExtensionShouldBeLoaded)
            Which is: false
          static_cast<bool>(networkExtensionLoaded)
            Which is: true
        
        
        /Volumes/Data/slave/catalina-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContentFiltering.mm:374
        Expected equality of these values:
          static_cast<bool>(networkExtensionShouldBeLoaded)
            Which is: false
          static_cast<bool>(networkExtensionLoaded)
            Which is: true
        
        
        /Volumes/Data/slave/catalina-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/ContentFiltering.mm:374
        Expected equality of these values:
          static_cast<bool>(networkExtensionShouldBeLoaded)
            Which is: false
          static_cast<bool>(networkExtensionLoaded)
            Which is: true

https://results.webkit.org/?suite=api-tests&test=TestWebKitAPI.ContentFiltering.LazilyLoadPlatformFrameworks
Comment 1 Ryan Haddad 2020-10-28 16:21:34 PDT
Test history suggests this started with https://trac.webkit.org/changeset/269109/webkit
Comment 2 Radar WebKit Bug Importer 2020-10-28 16:21:50 PDT
<rdar://problem/70785239>
Comment 3 Aditya Keerthi 2020-10-28 19:14:39 PDT
Created attachment 412602 [details]
Patch
Comment 4 Aditya Keerthi 2020-10-28 19:31:09 PDT
Created attachment 412606 [details]
Patch
Comment 5 Aditya Keerthi 2020-10-28 19:38:56 PDT
Created attachment 412607 [details]
Patch
Comment 6 Aditya Keerthi 2020-10-28 20:45:06 PDT
Will need to add a HAVE macro to avoid compiling NetworkExtensionContentFilter on tvOS.
Comment 7 Andy Estes 2020-10-29 05:58:26 PDT
Comment on attachment 412607 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=412607&action=review

> Source/WebCore/Configurations/WebCore.xcconfig:114
> +WK_NETWORK_EXTENSION_LD_FLAGS = $(WK_NETWORK_EXTENSION_LD_FLAGS_$(WK_PLATFORM_NAME));
> +WK_NETWORK_EXTENSION_LD_FLAGS_iphoneos = -framework NetworkExtension;
> +WK_NETWORK_EXTENSION_LD_FLAGS_iphonesimulator = -framework NetworkExtension;
> +WK_NETWORK_EXTENSION_LD_FLAGS_watchos = -framework NetworkExtension;
> +WK_NETWORK_EXTENSION_LD_FLAGS_watchsimulator = -framework NetworkExtension;
> +WK_NETWORK_EXTENSION_LD_FLAGS_maccatalyst = -framework NetworkExtension;
> +WK_NETWORK_EXTENSION_LD_FLAGS_macosx = -weak_framework NetworkExtension;

A simplification of this would be:

    WK_NETWORK_EXTENSION_LD_FLAGS = $(WK_NETWORK_EXTENSION_LD_FLAGS_$(WK_COCOA_TOUCH));
    WK_NETWORK_EXTENSION_LD_FLAGS_cocoatouch = -framework NetworkExtension;
    WK_NETWORK_EXTENSION_LD_FLAGS_ = -weak_framework NetworkExtension;

This would also fix the tvOS build.

> Source/WebCore/platform/cocoa/NetworkExtensionContentFilter.h:57
> +    WEBCORE_EXPORT static bool filterSourceRequiresFilter();

Nit: I think `filterSourceRequired` or `isRequired` would say enough.
Comment 8 Andy Estes 2020-10-29 05:59:55 PDT
(In reply to Aditya Keerthi from comment #6)
> Will need to add a HAVE macro to avoid compiling
> NetworkExtensionContentFilter on tvOS.

I think the problem is just that you aren't linking the framework on tvOS.
Comment 9 Aditya Keerthi 2020-10-29 08:25:17 PDT
(In reply to Andy Estes from comment #8)
> (In reply to Aditya Keerthi from comment #6)
> > Will need to add a HAVE macro to avoid compiling
> > NetworkExtensionContentFilter on tvOS.
> 
> I think the problem is just that you aren't linking the framework on tvOS.

The framework is not available on tvOS (https://developer.apple.com/documentation/networkextension).
Comment 10 Aditya Keerthi 2020-10-29 09:06:39 PDT
Created attachment 412656 [details]
Patch
Comment 11 EWS 2020-10-29 15:26:54 PDT
Committed r269173: <https://trac.webkit.org/changeset/269173>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 412656 [details].
Comment 12 mitz 2020-10-29 15:34:35 PDT
Comment on attachment 412656 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=412656&action=review

> Source/WebCore/Configurations/WebCore.xcconfig:114
> +WK_NETWORK_EXTENSION_LD_FLAGS = $(WK_NETWORK_EXTENSION_LD_FLAGS_$(WK_PLATFORM_NAME));
> +WK_NETWORK_EXTENSION_LD_FLAGS_iphoneos = -framework NetworkExtension;
> +WK_NETWORK_EXTENSION_LD_FLAGS_iphonesimulator = -framework NetworkExtension;
> +WK_NETWORK_EXTENSION_LD_FLAGS_watchos = -framework NetworkExtension;
> +WK_NETWORK_EXTENSION_LD_FLAGS_watchsimulator = -framework NetworkExtension;
> +WK_NETWORK_EXTENSION_LD_FLAGS_maccatalyst = -framework NetworkExtension;
> +WK_NETWORK_EXTENSION_LD_FLAGS_macosx = -weak_framework NetworkExtension;

If this is going to be a recurring pattern, you should consider instead introducing something like

WK_MACOS_WEAK_FRAMEWORK = -framework;
WK_MACOS_WEAK_FRAMEWORK[sdk=macosx*] = -weak_framework;

in Base.xcconfig and then just adding “$(WK_MACOS_WEAK_FRAMEWORK) NetworkExtension” to OTHER_LDFLAGS.
Comment 13 Aditya Keerthi 2020-10-29 16:53:45 PDT
(In reply to mitz from comment #12)
> Comment on attachment 412656 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=412656&action=review
> 
> > Source/WebCore/Configurations/WebCore.xcconfig:114
> > +WK_NETWORK_EXTENSION_LD_FLAGS = $(WK_NETWORK_EXTENSION_LD_FLAGS_$(WK_PLATFORM_NAME));
> > +WK_NETWORK_EXTENSION_LD_FLAGS_iphoneos = -framework NetworkExtension;
> > +WK_NETWORK_EXTENSION_LD_FLAGS_iphonesimulator = -framework NetworkExtension;
> > +WK_NETWORK_EXTENSION_LD_FLAGS_watchos = -framework NetworkExtension;
> > +WK_NETWORK_EXTENSION_LD_FLAGS_watchsimulator = -framework NetworkExtension;
> > +WK_NETWORK_EXTENSION_LD_FLAGS_maccatalyst = -framework NetworkExtension;
> > +WK_NETWORK_EXTENSION_LD_FLAGS_macosx = -weak_framework NetworkExtension;
> 
> If this is going to be a recurring pattern, you should consider instead
> introducing something like
> 
> WK_MACOS_WEAK_FRAMEWORK = -framework;
> WK_MACOS_WEAK_FRAMEWORK[sdk=macosx*] = -weak_framework;
> 
> in Base.xcconfig and then just adding “$(WK_MACOS_WEAK_FRAMEWORK)
> NetworkExtension” to OTHER_LDFLAGS.

Thanks! Will keep that in mind for future changes in this area.

Though in this case we cannot unconditionally add “$(WK_MACOS_WEAK_FRAMEWORK) NetworkExtension” to OTHER_LDFLAGS, due to the exclusion of tvOS.