Bug 231963 - WebAuthn Platform UI callbacks are not guaranteed to happen on the main thread
Summary: WebAuthn Platform UI callbacks are not guaranteed to happen on the main thread
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-10-19 10:00 PDT by Garrett Davidson
Modified: 2021-10-19 13:32 PDT (History)
5 users (show)

See Also:


Attachments
Patch (10.96 KB, patch)
2021-10-19 10:12 PDT, Garrett Davidson
no flags Details | Formatted Diff | Diff
Patch (10.94 KB, patch)
2021-10-19 11:27 PDT, Garrett Davidson
no flags Details | Formatted Diff | Diff
Patch (10.88 KB, patch)
2021-10-19 12:36 PDT, Garrett Davidson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Garrett Davidson 2021-10-19 10:00:27 PDT
WebAuthn Platform UI callbacks are not guaranteed to happen on the main thread
Comment 1 Garrett Davidson 2021-10-19 10:12:48 PDT
Created attachment 441748 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2021-10-19 10:14:22 PDT
<rdar://problem/84420452>
Comment 3 Brent Fulgham 2021-10-19 10:54:51 PDT
Comment on attachment 441748 [details]
Patch

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

> Source/WebKit/ChangeLog:4
> +        https://bugs.webkit.org/show_bug.cgi?id=231963

Please add: <rdar://84420452>

> Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm:268
> +        dispatch_async(dispatch_get_main_queue(), makeBlockPtr([weakThis, handler = WTFMove(handler), window = WTFMove(window), proxy = WTFMove(proxy), daemonEndpoint = retainPtr(daemonEndpoint), error = retainPtr(error)] () mutable {

This would be better as:

callOnMainThread([weakThis, handler = WTFMove(handler), window = WTFMove(window), proxy = WTFMove(proxy), daemonEndpoint = retainPtr(daemonEndpoint), error = retainPtr(error)] {
...
}
Comment 4 Garrett Davidson 2021-10-19 11:27:23 PDT
Created attachment 441763 [details]
Patch
Comment 5 Brent Fulgham 2021-10-19 12:02:34 PDT
Comment on attachment 441763 [details]
Patch

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

r=me, but please adjust the 'protectedThis' naming to reflect that this is a weak pointer, and does not hold the instance alive.

> Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm:270
> +            auto protectedThis = weakThis.get();

protectedThis is a bad name for a WeakPtr -- can we just use 'weakThis'? I don't think we need to pull a bare pointer out of the WeakPtr wrapper (it should cast properly). 'protectedThis' implies we have a RetainPtr that is holding the object alive -- which is misleading in this case.

> Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm:271
> +            if (!protectedThis || !daemonEndpoint) {

So this would just be "if (!weakThis || !daemonEndpoint) {"

> Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm:277
> +            protectedThis->m_presenter = adoptNS([allocASCAuthorizationRemotePresenterInstance() init]);

Then these could just be "weakThis->m_presenter", etc.
Comment 6 Garrett Davidson 2021-10-19 12:36:01 PDT
Created attachment 441770 [details]
Patch
Comment 7 Brent Fulgham 2021-10-19 12:43:23 PDT
Comment on attachment 441770 [details]
Patch

Looks great! Thanks.
Comment 8 EWS 2021-10-19 13:32:47 PDT
Committed r284489 (243243@main): <https://commits.webkit.org/243243@main>

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