Bug 98326

Summary: [WK2] Have plugins render initially offscreen to capture snapshot
Product: WebKit Reporter: Jon Lee <jonlee>
Component: WebKit Misc.Assignee: Jon Lee <jonlee>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, beidson, cpu, eric, mitz, simon.fraser, webkit-bug-importer, webkit.review.bot
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.8   
Bug Depends on:    
Bug Blocks: 98318    
Attachments:
Description Flags
Patch
none
Patch
none
Patch simon.fraser: review+

Jon Lee
Reported 2012-10-03 16:42:52 PDT
Once a timer fires after the plugin initializes, make a snapshot of the plugin offscreen to display as a placeholder.
Attachments
Patch (7.62 KB, patch)
2012-10-08 14:42 PDT, Jon Lee
no flags
Patch (8.01 KB, patch)
2012-10-09 10:51 PDT, Jon Lee
no flags
Patch (14.15 KB, patch)
2012-10-09 12:12 PDT, Jon Lee
simon.fraser: review+
Radar WebKit Bug Importer
Comment 1 2012-10-03 16:43:33 PDT
Jon Lee
Comment 2 2012-10-08 14:42:33 PDT
Brian Weinstein
Comment 3 2012-10-09 09:14:23 PDT
Comment on attachment 167616 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=167616&action=review > Source/WebKit2/WebProcess/Plugins/PluginView.cpp:271 > + , m_pluginSnapshotTimer(this, &PluginView::pluginSnapshotTimerFired, 3) Should this be a named constant? > Source/WebKit2/WebProcess/Plugins/PluginView.cpp:1381 > +{ Do you want to do something like: ASSERT_UNUSED(timer, timer == m_pluginSnapshotTimer?
Jon Lee
Comment 4 2012-10-09 09:43:10 PDT
Comment on attachment 167616 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=167616&action=review >> Source/WebKit2/WebProcess/Plugins/PluginView.cpp:271 >> + , m_pluginSnapshotTimer(this, &PluginView::pluginSnapshotTimerFired, 3) > > Should this be a named constant? Done. >> Source/WebKit2/WebProcess/Plugins/PluginView.cpp:1381 >> +{ > > Do you want to do something like: ASSERT_UNUSED(timer, timer == m_pluginSnapshotTimer? Done.
Jon Lee
Comment 5 2012-10-09 10:51:35 PDT
Simon Fraser (smfr)
Comment 6 2012-10-09 11:09:17 PDT
Comment on attachment 167782 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=167782&action=review > Source/WebKit2/WebProcess/Plugins/PluginView.cpp:292 > + // Null out the plug-in element explicitly so we'll crash earlier if we try to use > + // the plug-in view after it's been destroyed. > + m_pluginElement = nullptr; There doesn't seem to be much point in doing this in the destructor. > Source/WebKit2/WebProcess/Plugins/PluginView.h:235 > + // The snapshot is used in two scenarios: > + // 1) If plugin snapshotting is enabled, this snapshot represents the poster image. > + // 2) Otherwise, it represents the first image displayed when the plugin is run, to avoid > + // side effects should the plugin perform DOM manipulation on initialization. > RefPtr<ShareableBitmap> m_snapshot; > + RefPtr<WebCore::Image> m_snapshotImage; This comment is ambiguous now; is it referring to m_snapshot, or m_snapshotImage. Do we still need both of these? Can they be renamed to make their purposes more obvious?
Jon Lee
Comment 7 2012-10-09 11:51:24 PDT
(In reply to comment #6) > (From update of attachment 167782 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=167782&action=review > > > Source/WebKit2/WebProcess/Plugins/PluginView.cpp:292 > > + // Null out the plug-in element explicitly so we'll crash earlier if we try to use > > + // the plug-in view after it's been destroyed. > > + m_pluginElement = nullptr; > > There doesn't seem to be much point in doing this in the destructor. This already existed, and seems to have been added as a sanity check, so I will leave this in. > > > Source/WebKit2/WebProcess/Plugins/PluginView.h:235 > > + // The snapshot is used in two scenarios: > > + // 1) If plugin snapshotting is enabled, this snapshot represents the poster image. > > + // 2) Otherwise, it represents the first image displayed when the plugin is run, to avoid > > + // side effects should the plugin perform DOM manipulation on initialization. > > RefPtr<ShareableBitmap> m_snapshot; > > + RefPtr<WebCore::Image> m_snapshotImage; > > This comment is ambiguous now; is it referring to m_snapshot, or m_snapshotImage. Do we still need both of these? Can they be renamed to make their purposes more obvious? Yes, I believe I can get rid of the image variable and make this all happen locally. For readability, this means that instead of giving an Image* to WebCore, I will be using PassRefPtr<Image> instead. Unfortunately, there is still a naming issue, because there is m_snapshot, and m_pluginSnapshotTimer, which at first glance would appear related. I am appending comments to explain that they are unrelated, and will rename m_snapshot to m_transientPaintingSnapshot. New patch forthcoming.
Jon Lee
Comment 8 2012-10-09 12:12:24 PDT
Created attachment 167813 [details] Patch Rename m_snapshot to m_transientPaintingSnapshot, refactor pluginSnapshotTimerFired to use local variables.
Jon Lee
Comment 9 2012-10-09 14:23:33 PDT
Note You need to log in before you can comment on or make changes to this bug.