Bug 225004

Summary: [iOS] [GPU] The UI process should issue the mach sandbox extension to 'com.apple.AGXCompilerService'
Product: WebKit Reporter: Brent Fulgham <bfulgham>
Component: WebKit Misc.Assignee: Brent Fulgham <bfulgham>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, darin, pvollan, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=203915
https://bugs.webkit.org/show_bug.cgi?id=210616
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
none
Patch
none
Patch
none
Patch for landing none

Description Brent Fulgham 2021-04-23 15:45:42 PDT
In Bug 203915 and Bug 210616 we did work to only extend access to AGX-related graphics facilities on relevant hardware. This was lost in the transition to the GPU Process and should be added back.

<rdar://problem/68362930>
Comment 1 Brent Fulgham 2021-04-23 15:59:03 PDT
Created attachment 426959 [details]
Patch
Comment 2 Per Arne Vollan 2021-04-23 16:13:07 PDT
Comment on attachment 426959 [details]
Patch

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

Great! R=me.

> Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.GPU.sb:975
> +        (xpc-service-name-prefix "com.apple.AGXCompilerService")))

Is the prefix part needed?
Comment 3 Brent Fulgham 2021-04-23 16:49:30 PDT
Created attachment 426965 [details]
Patch
Comment 4 Brent Fulgham 2021-04-23 16:50:09 PDT
(In reply to Per Arne Vollan from comment #2)
> Comment on attachment 426959 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=426959&action=review
> 
> Great! R=me.
> 
> > Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.GPU.sb:975
> > +        (xpc-service-name-prefix "com.apple.AGXCompilerService")))
> 
> Is the prefix part needed?

Yes. This is right out of the WCP rules. There are two flavors of AGXCompilerService (one has a postfix).
Comment 5 Brent Fulgham 2021-04-23 17:01:58 PDT
Created attachment 426967 [details]
Patch
Comment 6 Darin Adler 2021-04-25 12:41:40 PDT
Comment on attachment 426967 [details]
Patch

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

> Source/WebCore/platform/cocoa/AGXCompilerService.h:36
> +namespace WTF {
> +
> +class ASCIILiteral;
> +
> +}

This isn’t needed or helpful. If we include <wtf/Forward.h>, then this is taken care of. If we don’t, then we have to write WTF::ASCIILiteral below.

> Source/WebCore/platform/cocoa/AGXCompilerService.h:43
> +WEBCORE_EXPORT const Vector<ASCIILiteral>& agxCompilerServices();
> +WEBCORE_EXPORT const Vector<ASCIILiteral>& agxCompilerClasses();

Would be slightly more efficient to move to something that doesn’t require any memory allocation. To cite one example, maybe not the most elegant, these could return std::initializer_list<ASCIILiteral>, if all we need to do is iterate them. No reason to keep a Vector around in memory forever just because we need to call createHandlesForMachLookup.

Sadly, right now SandboxExtension is specifically tied to Vector. So doing this might require a bit of refactoring, and is not urgent. Just slightly better memory use and I suppose a better idiom.
Comment 7 Darin Adler 2021-04-25 12:42:12 PDT
Comment on attachment 426967 [details]
Patch

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

> Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp:48
> +#include <WebCore/AGXCompilerService.h>

Adding this broke the WinCairo build.
Comment 8 Brent Fulgham 2021-04-26 09:55:30 PDT
Created attachment 427061 [details]
Patch
Comment 9 Brent Fulgham 2021-04-26 10:02:26 PDT
Comment on attachment 426967 [details]
Patch

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

>> Source/WebCore/platform/cocoa/AGXCompilerService.h:36
>> +}
> 
> This isn’t needed or helpful. If we include <wtf/Forward.h>, then this is taken care of. If we don’t, then we have to write WTF::ASCIILiteral below.

Ah, will fix.

>> Source/WebCore/platform/cocoa/AGXCompilerService.h:43
>> +WEBCORE_EXPORT const Vector<ASCIILiteral>& agxCompilerClasses();
> 
> Would be slightly more efficient to move to something that doesn’t require any memory allocation. To cite one example, maybe not the most elegant, these could return std::initializer_list<ASCIILiteral>, if all we need to do is iterate them. No reason to keep a Vector around in memory forever just because we need to call createHandlesForMachLookup.
> 
> Sadly, right now SandboxExtension is specifically tied to Vector. So doing this might require a bit of refactoring, and is not urgent. Just slightly better memory use and I suppose a better idiom.

I filed Bug 225059 to remember to do this.
Comment 10 Darin Adler 2021-04-26 11:04:40 PDT
Comment on attachment 427061 [details]
Patch

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

> Source/WebCore/platform/cocoa/AGXCompilerService.h:31
> +#include <wtf/Forward.h>
> +#include <wtf/Vector.h>

Probably not worth another round of patch revision, but Vector.h already includes Forward.h so an explicit include of Forward.h probably is not needed. I should have made that clear in my earlier comment.

Oh, and now,. on reflection, only Forward.h needs to be included here.
Comment 11 Brent Fulgham 2021-04-26 17:54:08 PDT
Created attachment 427111 [details]
Patch
Comment 12 Brent Fulgham 2021-04-26 17:55:04 PDT
Comment on attachment 427061 [details]
Patch

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

>> Source/WebCore/platform/cocoa/AGXCompilerService.h:31
>> +#include <wtf/Vector.h>
> 
> Probably not worth another round of patch revision, but Vector.h already includes Forward.h so an explicit include of Forward.h probably is not needed. I should have made that clear in my earlier comment.
> 
> Oh, and now,. on reflection, only Forward.h needs to be included here.

I'll fix it -- fewer includes are better!
Comment 13 Brent Fulgham 2021-04-26 17:56:25 PDT
Created attachment 427112 [details]
Patch for landing
Comment 14 EWS 2021-04-27 10:08:32 PDT
Committed r276644 (237071@main): <https://commits.webkit.org/237071@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 427112 [details].