Bug 236566 - Do preliminary work to pass domain names to CoreLocation
Summary: Do preliminary work to pass domain names to CoreLocation
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks: 236803
  Show dependency treegraph
 
Reported: 2022-02-13 11:05 PST by Chris Dumez
Modified: 2022-02-17 13:14 PST (History)
16 users (show)

See Also:


Attachments
Patch (99.96 KB, patch)
2022-02-13 11:24 PST, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (100.00 KB, patch)
2022-02-13 11:43 PST, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (100.01 KB, patch)
2022-02-13 12:33 PST, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (100.41 KB, patch)
2022-02-13 13:21 PST, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (100.40 KB, patch)
2022-02-13 14:21 PST, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (100.45 KB, patch)
2022-02-13 17:46 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (101.23 KB, patch)
2022-02-13 20:07 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (98.34 KB, patch)
2022-02-14 10:03 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (107.22 KB, patch)
2022-02-14 18:43 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (107.25 KB, patch)
2022-02-14 19:37 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (108.03 KB, patch)
2022-02-15 08:15 PST, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (107.87 KB, patch)
2022-02-15 08:46 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (107.87 KB, patch)
2022-02-15 09:53 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (107.94 KB, patch)
2022-02-15 10:54 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (107.20 KB, patch)
2022-02-15 11:20 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (107.57 KB, patch)
2022-02-15 13:11 PST, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (107.80 KB, patch)
2022-02-15 13:18 PST, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (109.01 KB, patch)
2022-02-15 15:42 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (108.58 KB, patch)
2022-02-15 15:51 PST, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (108.59 KB, patch)
2022-02-15 16:04 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (293.78 KB, patch)
2022-02-15 20:49 PST, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (293.78 KB, patch)
2022-02-15 20:54 PST, Myles C. Maxfield
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2022-02-13 11:05:52 PST
Do preliminary work to pass domain names to CoreLocation.
Comment 1 Chris Dumez 2022-02-13 11:06:06 PST
<rdar://88761413>
Comment 2 Chris Dumez 2022-02-13 11:24:14 PST
Created attachment 451829 [details]
Patch
Comment 3 Chris Dumez 2022-02-13 11:43:29 PST
Created attachment 451832 [details]
Patch
Comment 4 Chris Dumez 2022-02-13 12:33:16 PST
Created attachment 451838 [details]
Patch
Comment 5 Chris Dumez 2022-02-13 13:21:46 PST
Created attachment 451839 [details]
Patch
Comment 6 Chris Dumez 2022-02-13 14:21:51 PST
Created attachment 451844 [details]
Patch
Comment 7 Chris Dumez 2022-02-13 17:46:30 PST
Created attachment 451851 [details]
Patch
Comment 8 Chris Dumez 2022-02-13 20:07:57 PST
Created attachment 451853 [details]
Patch
Comment 9 Chris Dumez 2022-02-14 10:03:41 PST
Created attachment 451920 [details]
Patch
Comment 10 Chris Dumez 2022-02-14 18:43:59 PST
Created attachment 451976 [details]
Patch
Comment 11 Chris Dumez 2022-02-14 19:37:32 PST
Created attachment 451984 [details]
Patch
Comment 12 Darin Adler 2022-02-15 07:52:14 PST
Comment on attachment 451984 [details]
Patch

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

> Source/WebCore/Modules/geolocation/cocoa/GeolocationPositionDataCocoa.mm:33
> +GeolocationPositionData::GeolocationPositionData(CLLocation* location)

CLLocation * should have a space given our Objective-C class coding style.

> Source/WebCore/SourcesCocoa.txt:311
> +platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm @no-unify

I’d love to avoid adding new no-unify. Why were these required? Do you know any workaround?

> Source/WebCore/platform/cocoa/CoreLocationGeolocationProvider.h:46
> +        virtual void geolocationAuthorizationGranted(const String& /*websiteIdentifier*/) { }

Can any of these arguments be StringView instead of const String&?

> Source/WebCore/platform/cocoa/CoreLocationGeolocationProvider.mm:50
> +static bool isAuthorizationGranted(CLAuthorizationStatus authorizationStatus)

I’d name the argument just status.

> Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:245
> +    for (auto& perDomainData : m_perDomainData.values()) {

Same name for the loop variable as this function’s argument. Could sidestep this by using a shorter name for one or both. Just “data” will do give the scope of a short function or loop.

> Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:265
> +    if (!m_clientProvider)

This code should go into the #else, or we could move the #if so it’s only around the provider creation and start call.

> Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:280
> +    UNUSED_PARAM(perDomainData);

Same refactoring as above would be good. Put #if around the stop call.

> Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:293
> +    UNUSED_PARAM(perDomainData);

And here. Add the early return?

> Source/WebKit/UIProcess/WebGeolocationManagerProxy.h:104
> +    struct PerDomainData {

Should just name the struct here and define it inside the .cop file.

> Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.cpp:47
> +    return RegistrableDomain { document->url() };

Can probably use the braces without repeating the class name.

> Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.cpp:69
> +    auto& pageSets = m_pageSets.ensure(registrableDomain, [] {

This ensure should just be an add. It’s probably sufficiently efficient to make an empty PageSets; just two null pointers. Generally speaking new empty hash tables are just a null pointer, amd even though they sound expensive to allocate they’re not.
Comment 13 Chris Dumez 2022-02-15 08:05:37 PST
(In reply to Darin Adler from comment #12)
> Comment on attachment 451984 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=451984&action=review
> 
> > Source/WebCore/Modules/geolocation/cocoa/GeolocationPositionDataCocoa.mm:33
> > +GeolocationPositionData::GeolocationPositionData(CLLocation* location)
> 
> CLLocation * should have a space given our Objective-C class coding style.

OK.

> 
> > Source/WebCore/SourcesCocoa.txt:311
> > +platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm @no-unify
> 
> I’d love to avoid adding new no-unify. Why were these required? Do you know
> any workaround?

I consulted with Jer on this and this was his suggestion. This is happening because of unified build and soft-linking macros.
I'll double check to see if I still need both or if I can remove one.

> > Source/WebCore/platform/cocoa/CoreLocationGeolocationProvider.h:46
> > +        virtual void geolocationAuthorizationGranted(const String& /*websiteIdentifier*/) { }
> 
> Can any of these arguments be StringView instead of const String&?

What's the benefit here though. I am holding a String as a data member and passing it as parameter. I think it makes sense to use the same type.

> 
> > Source/WebCore/platform/cocoa/CoreLocationGeolocationProvider.mm:50
> > +static bool isAuthorizationGranted(CLAuthorizationStatus authorizationStatus)
> 
> I’d name the argument just status.

OK.

> 
> > Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:245
> > +    for (auto& perDomainData : m_perDomainData.values()) {
> 
> Same name for the loop variable as this function’s argument. Could sidestep
> this by using a shorter name for one or both. Just “data” will do give the
> scope of a short function or loop.

OK.

> 
> > Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:265
> > +    if (!m_clientProvider)
> 
> This code should go into the #else, or we could move the #if so it’s only
> around the provider creation and start call.

I think there is probably a misunderstanding here. The code cannot be in the #else because it is still useful on IOS_FAMILY in those 2 cases:
1. The client sets its own provider via the API to pass a dummy provider (for testing, used by WKTR and API tests for e.g.)
2. The client sets its own provider via the API and passes a provider which rejects all authorization as a way to disable the geolocation API (used on watchOS).

Eventually, we should be able to get rid of both cases but it will require some additional work for provide alternatives for these clients.

> 
> > Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:280
> > +    UNUSED_PARAM(perDomainData);
> 
> Same refactoring as above would be good. Put #if around the stop call.
> 
> > Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:293
> > +    UNUSED_PARAM(perDomainData);
> 
> And here. Add the early return?
> 
> > Source/WebKit/UIProcess/WebGeolocationManagerProxy.h:104
> > +    struct PerDomainData {
> 
> Should just name the struct here and define it inside the .cop file.

Oh, last time I tried that it didn't work because I was also using the struct from WebGeolocationManagerCocoa.cpp. However, in this latest iteration, it doesn't seem to be the case anymore so I should be able to do this indeed.

> 
> > Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.cpp:47
> > +    return RegistrableDomain { document->url() };
> 
> Can probably use the braces without repeating the class name.

OK, will try.

> 
> > Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.cpp:69
> > +    auto& pageSets = m_pageSets.ensure(registrableDomain, [] {
> 
> This ensure should just be an add. It’s probably sufficiently efficient to
> make an empty PageSets; just two null pointers. Generally speaking new empty
> hash tables are just a null pointer, amd even though they sound expensive to
> allocate they’re not.

Ok.
Comment 14 Chris Dumez 2022-02-15 08:15:14 PST
Created attachment 452026 [details]
Patch
Comment 15 Chris Dumez 2022-02-15 08:30:24 PST
(In reply to Chris Dumez from comment #13)
> (In reply to Darin Adler from comment #12)
> > Comment on attachment 451984 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=451984&action=review
> > 
> > > Source/WebCore/Modules/geolocation/cocoa/GeolocationPositionDataCocoa.mm:33
> > > +GeolocationPositionData::GeolocationPositionData(CLLocation* location)
> > 
> > CLLocation * should have a space given our Objective-C class coding style.
> 
> OK.
> 
> > 
> > > Source/WebCore/SourcesCocoa.txt:311
> > > +platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm @no-unify
> > 
> > I’d love to avoid adding new no-unify. Why were these required? Do you know
> > any workaround?
> 
> I consulted with Jer on this and this was his suggestion. This is happening
> because of unified build and soft-linking macros.
> I'll double check to see if I still need both or if I can remove one.
> 
> > > Source/WebCore/platform/cocoa/CoreLocationGeolocationProvider.h:46
> > > +        virtual void geolocationAuthorizationGranted(const String& /*websiteIdentifier*/) { }
> > 
> > Can any of these arguments be StringView instead of const String&?
> 
> What's the benefit here though. I am holding a String as a data member and
> passing it as parameter. I think it makes sense to use the same type.
> 
> > 
> > > Source/WebCore/platform/cocoa/CoreLocationGeolocationProvider.mm:50
> > > +static bool isAuthorizationGranted(CLAuthorizationStatus authorizationStatus)
> > 
> > I’d name the argument just status.
> 
> OK.
> 
> > 
> > > Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:245
> > > +    for (auto& perDomainData : m_perDomainData.values()) {
> > 
> > Same name for the loop variable as this function’s argument. Could sidestep
> > this by using a shorter name for one or both. Just “data” will do give the
> > scope of a short function or loop.
> 
> OK.
> 
> > 
> > > Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:265
> > > +    if (!m_clientProvider)
> > 
> > This code should go into the #else, or we could move the #if so it’s only
> > around the provider creation and start call.
> 
> I think there is probably a misunderstanding here. The code cannot be in the
> #else because it is still useful on IOS_FAMILY in those 2 cases:
> 1. The client sets its own provider via the API to pass a dummy provider
> (for testing, used by WKTR and API tests for e.g.)
> 2. The client sets its own provider via the API and passes a provider which
> rejects all authorization as a way to disable the geolocation API (used on
> watchOS).
> 
> Eventually, we should be able to get rid of both cases but it will require
> some additional work for provide alternatives for these clients.
> 
> > 
> > > Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:280
> > > +    UNUSED_PARAM(perDomainData);
> > 
> > Same refactoring as above would be good. Put #if around the stop call.
> > 
> > > Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:293
> > > +    UNUSED_PARAM(perDomainData);
> > 
> > And here. Add the early return?
> > 
> > > Source/WebKit/UIProcess/WebGeolocationManagerProxy.h:104
> > > +    struct PerDomainData {
> > 
> > Should just name the struct here and define it inside the .cop file.
> 
> Oh, last time I tried that it didn't work because I was also using the
> struct from WebGeolocationManagerCocoa.cpp. However, in this latest
> iteration, it doesn't seem to be the case anymore so I should be able to do
> this indeed.

No actually, WebGeolocationManagerCocoa.cpp still uses PerDomainData so I still cannot do what you suggested it seems.

> > 
> > > Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.cpp:47
> > > +    return RegistrableDomain { document->url() };
> > 
> > Can probably use the braces without repeating the class name.
> 
> OK, will try.
> 
> > 
> > > Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.cpp:69
> > > +    auto& pageSets = m_pageSets.ensure(registrableDomain, [] {
> > 
> > This ensure should just be an add. It’s probably sufficiently efficient to
> > make an empty PageSets; just two null pointers. Generally speaking new empty
> > hash tables are just a null pointer, amd even though they sound expensive to
> > allocate they’re not.
> 
> Ok.
Comment 16 Chris Dumez 2022-02-15 08:34:20 PST
(In reply to Darin Adler from comment #12)
> Comment on attachment 451984 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=451984&action=review
> 
> > Source/WebCore/Modules/geolocation/cocoa/GeolocationPositionDataCocoa.mm:33
> > +GeolocationPositionData::GeolocationPositionData(CLLocation* location)
> 
> CLLocation * should have a space given our Objective-C class coding style.
> 
> > Source/WebCore/SourcesCocoa.txt:311
> > +platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm @no-unify
> 
> I’d love to avoid adding new no-unify. Why were these required? Do you know
> any workaround?
> 
> > Source/WebCore/platform/cocoa/CoreLocationGeolocationProvider.h:46
> > +        virtual void geolocationAuthorizationGranted(const String& /*websiteIdentifier*/) { }
> 
> Can any of these arguments be StringView instead of const String&?
> 
> > Source/WebCore/platform/cocoa/CoreLocationGeolocationProvider.mm:50
> > +static bool isAuthorizationGranted(CLAuthorizationStatus authorizationStatus)
> 
> I’d name the argument just status.
> 
> > Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:245
> > +    for (auto& perDomainData : m_perDomainData.values()) {
> 
> Same name for the loop variable as this function’s argument. Could sidestep
> this by using a shorter name for one or both. Just “data” will do give the
> scope of a short function or loop.
> 
> > Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:265
> > +    if (!m_clientProvider)
> 
> This code should go into the #else, or we could move the #if so it’s only
> around the provider creation and start call.
> 
> > Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:280
> > +    UNUSED_PARAM(perDomainData);
> 
> Same refactoring as above would be good. Put #if around the stop call.
> 
> > Source/WebKit/UIProcess/WebGeolocationManagerProxy.cpp:293
> > +    UNUSED_PARAM(perDomainData);
> 
> And here. Add the early return?
> 
> > Source/WebKit/UIProcess/WebGeolocationManagerProxy.h:104
> > +    struct PerDomainData {
> 
> Should just name the struct here and define it inside the .cop file.
> 
> > Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.cpp:47
> > +    return RegistrableDomain { document->url() };
> 
> Can probably use the braces without repeating the class name.

Hmm, this didn't work:
/Volumes/Data/WebKit/OpenSource/Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.cpp:47:12: error: chosen constructor is explicit in copy-initialization
    return { document->url() };
Comment 17 Chris Dumez 2022-02-15 08:46:34 PST
Created attachment 452028 [details]
Patch
Comment 18 EWS 2022-02-15 09:47:18 PST
ChangeLog entry in Source/WTF/ChangeLog contains OOPS!.
Comment 19 Chris Dumez 2022-02-15 09:53:28 PST
Created attachment 452044 [details]
Patch
Comment 20 EWS 2022-02-15 10:47:41 PST
Patch 452044 does not build
Comment 21 Chris Dumez 2022-02-15 10:54:22 PST
Created attachment 452055 [details]
Patch
Comment 22 Chris Dumez 2022-02-15 11:20:05 PST
Created attachment 452062 [details]
Patch
Comment 23 EWS 2022-02-15 12:22:52 PST
Patch 452062 does not build
Comment 24 Chris Dumez 2022-02-15 13:11:58 PST
Created attachment 452079 [details]
Patch
Comment 25 Chris Dumez 2022-02-15 13:18:36 PST
Created attachment 452081 [details]
Patch
Comment 26 Chris Dumez 2022-02-15 15:42:15 PST
Created attachment 452104 [details]
Patch
Comment 27 Chris Dumez 2022-02-15 15:51:50 PST
Created attachment 452105 [details]
Patch
Comment 28 EWS 2022-02-15 16:02:02 PST
Patch 452081 does not build
Comment 29 Chris Dumez 2022-02-15 16:04:14 PST
Created attachment 452106 [details]
Patch
Comment 30 EWS 2022-02-15 20:06:37 PST
Committed r289872 (247312@main): <https://commits.webkit.org/247312@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 452106 [details].
Comment 31 Myles C. Maxfield 2022-02-15 20:49:48 PST
Reopening to attach new patch.
Comment 32 Myles C. Maxfield 2022-02-15 20:49:50 PST
Created attachment 452135 [details]
Patch
Comment 33 Myles C. Maxfield 2022-02-15 20:54:55 PST
Created attachment 452136 [details]
Patch
Comment 34 Myles C. Maxfield 2022-02-15 20:56:24 PST
Whoops, sorry, webkit-patch upload messed up