Bug 133667 - Don't snapshot offscreen plugins that would normally be considered primary plugins after they are moved in view
Summary: Don't snapshot offscreen plugins that would normally be considered primary pl...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Plug-ins (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 133786
  Show dependency treegraph
 
Reported: 2014-06-09 17:03 PDT by Roger Fong
Modified: 2014-06-11 23:03 PDT (History)
8 users (show)

See Also:


Attachments
patch (9.68 KB, patch)
2014-06-09 17:33 PDT, Roger Fong
thorton: review+
Details | Formatted Diff | Diff
patch (9.96 KB, patch)
2014-06-11 12:14 PDT, Roger Fong
commit-queue: commit-queue-
Details | Formatted Diff | Diff
patch (9.95 KB, patch)
2014-06-11 12:19 PDT, Roger Fong
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Fong 2014-06-09 17:03:16 PDT
We've run into an issue where some sites (namely youtube) start their plugins offscreen and then move them into view after clicking a video link.
The issue is that by the time the user clicks the video the offscreen plugin has already been snapshotted.
We should make sure to not snapshot said plugin if 
The plugin is the right size to be a primary plugin ADN
1) The maximum number of snapshot retries has been reached and no good snapshot has yet been found
OR
2) The plugin is still trying to snapshot properly and in the process is moved into view.

<rdar://problem/16743250>
Comment 1 Roger Fong 2014-06-09 17:33:04 PDT
Created attachment 232752 [details]
patch
Comment 2 Tim Horton 2014-06-10 15:06:28 PDT
Comment on attachment 232752 [details]
patch

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

> Source/WebKit2/WebProcess/Plugins/PluginView.cpp:1687
> +    WebCore::HTMLPlugInImageElement* plugInImageElement = toHTMLPlugInImageElement(m_pluginElement.get());

I think there's no need for the WebCore:: here. Is this always safe or should you check the type?

> Source/WebKit2/WebProcess/Plugins/PluginView.cpp:1706
> +        snapshotFound = snapshotImage && !isAlmostSolidColor(toBitmapImage(snapshotImage.get()));
>  
>  #if PLATFORM(COCOA)
>          unsigned maximumSnapshotRetries = frame() ? frame()->settings().maximumPlugInSnapshotAttempts() : 0;
> -        if (snapshotImage && isAlmostSolidColor(toBitmapImage(snapshotImage.get())) && m_countSnapshotRetries < maximumSnapshotRetries) {
> +        if (snapshotImage && isAlmostSolidColor(toBitmapImage(snapshotImage.get())) && m_countSnapshotRetries < maximumSnapshotRetries && !plugInCameOnScreen) {

why are we checking isAlmostSolidColor twice in quick succession here? can the if() use snapshotFound?

> Source/WebKit2/WebProcess/Plugins/PluginView.h:278
> +    bool m_didPlugInStartOffScreen;

maybe pack this better, next to other bools? I dunno.

> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:4466
> +bool WebPage::plugInIntersectsSearchRect(HTMLPlugInImageElement* plugInImageElement)

should this (and plugInIsPrimarySize) take references?

> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:4485
> +    if (plugInRectRelativeToTopDocument.intersects(searchRect))
> +        return true;
> +    return false;

Maybe just "return plugInRectRelativeToTopDocument.intersects(searchRect);"?

> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:4488
> +bool WebPage::plugInIsPrimarySize(WebCore::HTMLPlugInImageElement *plugInImageElement, unsigned &candidatePlugInArea)

star on the wrong side.
Comment 3 Roger Fong 2014-06-11 12:14:32 PDT
Created attachment 232882 [details]
patch

With Tim's changes.
Using commit queue to land.
Comment 4 WebKit Commit Bot 2014-06-11 12:15:49 PDT
Comment on attachment 232882 [details]
patch

Rejecting attachment 232882 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.appspot.com', '--bot-id=webkit-cq-02', 'validate-changelog', '--check-oops', '--non-interactive', 232882, '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

Timothy Horton found in /Volumes/Data/EWS/WebKit/Source/WebKit2/ChangeLog does not appear to be a valid reviewer according to contributors.json.
/Volumes/Data/EWS/WebKit/Source/WebKit2/ChangeLog neither lists a valid reviewer nor contains the string "Unreviewed" or "Rubber stamp" (case insensitive).

Full output: http://webkit-queues.appspot.com/results/5021336309071872
Comment 5 Roger Fong 2014-06-11 12:19:53 PDT
Created attachment 232886 [details]
patch
Comment 6 WebKit Commit Bot 2014-06-11 12:59:55 PDT
Comment on attachment 232886 [details]
patch

Clearing flags on attachment: 232886

Committed r169820: <http://trac.webkit.org/changeset/169820>
Comment 7 WebKit Commit Bot 2014-06-11 12:59:58 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Csaba Osztrogonác 2014-06-11 14:48:46 PDT
(In reply to comment #6)
> (From update of attachment 232886 [details])
> Clearing flags on attachment: 232886
> 
> Committed r169820: <http://trac.webkit.org/changeset/169820>

It broke the !ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC) builds:

/home/webkit/WebKit/Source/WebKit2/WebProcess/Plugins/PluginView.cpp: In member function 'void WebKit::PluginView::pluginSnapshotTimerFired()':
/home/webkit/WebKit/Source/WebKit2/WebProcess/Plugins/PluginView.cpp:1693:40: error: 'class WebKit::WebPage' has no member named 'plugInIntersectsSearchRect'
/home/webkit/WebKit/Source/WebKit2/WebProcess/Plugins/PluginView.cpp:1707:96: error: 'isAlmostSolidColor' was not declared in this scope
/home/webkit/WebKit/Source/WebKit2/WebProcess/Plugins/PluginView.cpp:1721:20: error: 'class WebKit::WebPage' has no member named 'plugInIsPrimarySize'
Comment 9 Gyuyoung Kim 2014-06-11 23:03:55 PDT
(In reply to comment #8)
> (In reply to comment #6)
> > (From update of attachment 232886 [details] [details])
> > Clearing flags on attachment: 232886
> > 
> > Committed r169820: <http://trac.webkit.org/changeset/169820>
> 
> It broke the !ENABLE(PRIMARY_SNAPSHOTTED_PLUGIN_HEURISTIC) builds:
> 
> /home/webkit/WebKit/Source/WebKit2/WebProcess/Plugins/PluginView.cpp: In member function 'void WebKit::PluginView::pluginSnapshotTimerFired()':
> /home/webkit/WebKit/Source/WebKit2/WebProcess/Plugins/PluginView.cpp:1693:40: error: 'class WebKit::WebPage' has no member named 'plugInIntersectsSearchRect'
> /home/webkit/WebKit/Source/WebKit2/WebProcess/Plugins/PluginView.cpp:1707:96: error: 'isAlmostSolidColor' was not declared in this scope
> /home/webkit/WebKit/Source/WebKit2/WebProcess/Plugins/PluginView.cpp:1721:20: error: 'class WebKit::WebPage' has no member named 'plugInIsPrimarySize'

I file a bug to fix this error.
https://bugs.webkit.org/show_bug.cgi?id=133786