Bug 201371 - Provide a prototype for AR QuickLook to trigger processing in the originating page
Summary: Provide a prototype for AR QuickLook to trigger processing in the originating...
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: Dean Jackson
URL:
Keywords: InRadar
Depends on:
Blocks: 202103
  Show dependency treegraph
 
Reported: 2019-08-30 18:07 PDT by Dean Jackson
Modified: 2019-09-23 09:31 PDT (History)
14 users (show)

See Also:


Attachments
Patch (5.38 KB, patch)
2019-08-30 18:17 PDT, Dean Jackson
no flags Details | Formatted Diff | Diff
Patch (5.38 KB, patch)
2019-08-31 12:42 PDT, Dean Jackson
no flags Details | Formatted Diff | Diff
Patch (5.37 KB, patch)
2019-08-31 13:52 PDT, Dean Jackson
no flags Details | Formatted Diff | Diff
Patch (44.01 KB, patch)
2019-09-11 18:10 PDT, Dean Jackson
no flags Details | Formatted Diff | Diff
Patch (1.33 KB, patch)
2019-09-17 09:22 PDT, Jonathan Bedard
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dean Jackson 2019-08-30 18:07:31 PDT
Provide a prototype for AR QuickLook to trigger processing in the originating page
Comment 1 Dean Jackson 2019-08-30 18:16:13 PDT
<rdar://54904781>
Comment 2 Dean Jackson 2019-08-30 18:17:13 PDT
Created attachment 377776 [details]
Patch
Comment 3 Anders Carlsson 2019-08-31 09:51:29 PDT
(In reply to Dean Jackson from comment #2)
> Created attachment 377776 [details]
> Patch

Looks like iOS is broken.
Comment 4 Dean Jackson 2019-08-31 12:42:01 PDT
Created attachment 377804 [details]
Patch
Comment 5 Dean Jackson 2019-08-31 13:52:42 PDT
Created attachment 377806 [details]
Patch
Comment 6 Sam Weinig 2019-08-31 15:31:18 PDT
Comment on attachment 377806 [details]
Patch

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

> Source/WebKit/ChangeLog:12
> +        Provide a way for a Web page to know if a particular action in the AR scene
> +        was performed, if and only if the system AR library calls a delegate with
> +        particular parameters. Post a message to the window on the main frame
> +        to indicate the action was triggered.

Why the mainframe? Can a AR QuickLook be triggered only from a mainframe?

> Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:161
> +        NSString *javaScriptString = [NSString stringWithFormat:@"window.postMessage({_origin: '_apple_ar_quicklook' , action: 'buttonTapped'}, window.location.origin);"];
> +        _previewController->page().runJavaScriptInMainFrame(javaScriptString, true, [](API::SerializedScriptValue*, bool, const WebCore::ExceptionDetails&, WebKit::ScriptValueCallback::Error) { });
> +    }

Is there any chance the page has navigated since quicklook started? It would be good to either defend agains that or assert that it didn't happen.
Comment 7 Wenson Hsieh 2019-08-31 15:48:31 PDT
Comment on attachment 377806 [details]
Patch

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

> Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:73
> +- (instancetype)initWithSystemPreviewController:(WebKit::SystemPreviewController*)previewController MIMEType:(NSString*)mimeType originatingPageURL:(URL)url

Nit - do we ever expect the previewController to be null? If not, perhaps this should take a reference.
Comment 8 Simon Fraser (smfr) 2019-08-31 17:03:41 PDT
Comment on attachment 377806 [details]
Patch

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

> Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:158
> +    if ([[message[@"callToAction"] description] isEqualToString:@"buttonTapped"]) {

-description is generally used for debugging and might contain all kinds of junk (addresses, class names).
Comment 9 Dean Jackson 2019-09-11 18:10:55 PDT
Created attachment 378606 [details]
Patch
Comment 10 Simon Fraser (smfr) 2019-09-13 12:00:27 PDT
Comment on attachment 378606 [details]
Patch

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

> Source/WebCore/html/HTMLAnchorElement.cpp:489
> +        systemPreviewInfo.globalFrameID.frameID = document().frame()->loader().client().frameID().valueOr(FrameIdentifier { });
> +        systemPreviewInfo.globalFrameID.pageID = document().frame()->loader().client().pageID().valueOr(PageIdentifier { });

Weird flex but OK. Not sure why the PageIdentifier and FrameIdentifiers aren't on Page and Frame. Chris?

> Source/WebCore/loader/FrameLoaderTypes.h:185
> +    IntRect previewRect;

What coordinate system is this rect in?

> Source/WebKit/UIProcess/SystemPreviewController.h:65
> +    void triggerSystemPreviewActionWithTarget(uint64_t frameID, uint64_t pageID);

Maybe put "ForTesting" in the name
Comment 11 Dean Jackson 2019-09-13 14:43:42 PDT
Committed r249855: <https://trac.webkit.org/changeset/249855>
Comment 12 Ryan Haddad 2019-09-13 16:44:34 PDT
(In reply to Dean Jackson from comment #11)
> Committed r249855: <https://trac.webkit.org/changeset/249855>
TestWebKitAPI.WebKit.SystemPreviewTriggered (added with this change) is timing out on the iOS Simulator bots:
https://build.webkit.org/builders/Apple%20iOS%2012%20Simulator%20Release%20WK2%20(Tests)/builds/6364
Comment 13 Jonathan Bedard 2019-09-13 17:41:58 PDT
This breaks the iOS 13 OpenSource build...perhaps it needs <https://trac.webkit.org/changeset/249859/webkit>? Or an SPI declaration for ARQuickLookWebKitItemDelegate?
Comment 14 Jonathan Bedard 2019-09-17 09:22:38 PDT
Reopening to attach new patch.
Comment 15 Jonathan Bedard 2019-09-17 09:22:39 PDT
Created attachment 378969 [details]
Patch
Comment 16 Jonathan Bedard 2019-09-17 09:25:38 PDT
Committed r249958: <https://trac.webkit.org/changeset/249958>
Comment 17 Wenson Hsieh 2019-09-23 09:31:23 PDT
Comment on attachment 378606 [details]
Patch

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

> Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:508
> +- (void)_triggerSystemPreviewActionOnFrame:(uint64_t)frameID page:(uint64_t)pageID WK_API_AVAILABLE(ios(13.0));

Should this be WK_IOS_TBA?