Bug 59035 - WebKit2: Need a way to get a snapshot of the visible contents of a page from the UI Process
Summary: WebKit2: Need a way to get a snapshot of the visible contents of a page from ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Jessie Berlin
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2011-04-20 16:28 PDT by Jessie Berlin
Modified: 2011-04-21 11:24 PDT (History)
6 users (show)

See Also:


Attachments
Patch (6.76 KB, patch)
2011-04-20 16:40 PDT, Jessie Berlin
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jessie Berlin 2011-04-20 16:28:43 PDT
<rdar://problem/8607239>
Comment 1 Jessie Berlin 2011-04-20 16:40:29 PDT
Created attachment 90443 [details]
Patch
Comment 2 Brian Weinstein 2011-04-20 17:11:18 PDT
Comment on attachment 90443 [details]
Patch

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

I'm going to let Sam review this, just a couple comments I had.

> Source/WebKit2/ChangeLog:22
> +        with a scale factor of 1.

Is this correct if the view is currently scaled when we ask for the snapshot? The visible contents might be at a scale factor of 2, would we expect the snapshot to show that?

> Source/WebKit2/UIProcess/WebPageProxy.cpp:3032
> +    process()->sendSync(Messages::WebPage::VisibleContentsSnapshot(), Messages::WebPage::VisibleContentsSnapshot::Reply(snapshotHandle), m_pageID, 1);

A constant would be nice for the 1 here.

> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:854
> +    RefPtr<WebImage> snapshotImage = scaledSnapshotInDocumentCoordinates(contentRect, 1, ImageOptionsShareable);

Do we want the 1 here? Or do we want the current scale factor of the frame? (Repeat of question in ChangeLog).
Comment 3 Jessie Berlin 2011-04-21 09:26:17 PDT
(In reply to comment #2)
> (From update of attachment 90443 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=90443&action=review
> 
> I'm going to let Sam review this, just a couple comments I had.

Thanks for the feedback!

> 
> > Source/WebKit2/ChangeLog:22
> > +        with a scale factor of 1.
> 
> Is this correct if the view is currently scaled when we ask for the snapshot? The visible contents might be at a scale factor of 2, would we expect the snapshot to show that?

That is already taken into account when the snapshot is made of that rect. The scale factor is any additional scaling that is desired.

> 
> > Source/WebKit2/UIProcess/WebPageProxy.cpp:3032
> > +    process()->sendSync(Messages::WebPage::VisibleContentsSnapshot(), Messages::WebPage::VisibleContentsSnapshot::Reply(snapshotHandle), m_pageID, 1);
> 
> A constant would be nice for the 1 here.

Changed to be:

   // Do not wait for more than a second (arbitrary) for the WebProcess to get the snapshot so
    // that the UI Process is not permanently stuck waiting on a potentially crashing Web Process.
    static const double visibleContentsSnapshotSyncMessageTimeout = 1.0;
    process()->sendSync(Messages::WebPage::VisibleContentsSnapshot(), Messages::WebPage::VisibleContentsSnapshot::Reply(snapshotHandle), m_pageID, visibleContentsSnapshotSyncMessageTimeout);


> 
> > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:854
> > +    RefPtr<WebImage> snapshotImage = scaledSnapshotInDocumentCoordinates(contentRect, 1, ImageOptionsShareable);
> 
> Do we want the 1 here? Or do we want the current scale factor of the frame? (Repeat of question in ChangeLog).

See earlier response. I will update the Changelog comment to say that using a scale factor of one preserves any scaling already done on the web page (e.g. by zooming in or out).
Comment 4 Sam Weinig 2011-04-21 10:17:23 PDT
Comment on attachment 90443 [details]
Patch

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

> Source/WebKit2/UIProcess/API/C/WKPagePrivate.h:69
> +WK_EXPORT WKImageRef WKPageVisibleContentsSnapshot(WKPageRef pageRef);

This function name needs to Create in its name to indicate the ownership model.  I think WKPageCreateSnapshotOfVisibleContent() to match the one in the bundle, would be good.

We usually leave the Ref off the parameter name in the header.
Comment 5 Jessie Berlin 2011-04-21 10:31:22 PDT
(In reply to comment #4)
> (From update of attachment 90443 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=90443&action=review
> 
> > Source/WebKit2/UIProcess/API/C/WKPagePrivate.h:69
> > +WK_EXPORT WKImageRef WKPageVisibleContentsSnapshot(WKPageRef pageRef);
> 
> This function name needs to Create in its name to indicate the ownership model.  I think WKPageCreateSnapshotOfVisibleContent() to match the one in the bundle, would be good.

Done (and changed all the other instances of visibleContentsSnapshot to createSnapshotOfVisibleContent).

> 
> We usually leave the Ref off the parameter name in the header.

I was wondering what our official style was for that. Fixed.
Comment 6 Jessie Berlin 2011-04-21 10:45:19 PDT
Comment on attachment 90443 [details]
Patch

Committed in http://trac.webkit.org/changeset/84519
Comment 7 WebKit Review Bot 2011-04-21 11:24:35 PDT
http://trac.webkit.org/changeset/84519 might have broken Qt Linux ARMv7 Release and Qt Windows 32-bit Debug