Offscreen invalidate and sizing fix #7062

Merged
merged 5 commits into from Sep 19, 2016

Projects

None yet

4 participants

@gerhardberger
Member

This PR adds an invalidate method to webContents to manually request a new frame in offscreen mode.

And also fixes the issue that a browser did not resize properly in offscreen mode.

@zeke
Member
zeke commented Sep 2, 2016

Hi @gerhardberger. What is the use case for this new method?

@gerhardberger
Member

@zeke, it generates a 'paint' event on-demand with the current frame. This can be used when you need the latest frame but no change happens on the page, e.g. you start rendering to a new place and you want an initial frame.

atom/browser/native_window.cc
+
+ // In offscreen mode call RenderWidgetHostView's SetSize explicitly
+ const auto view = web_contents()->GetRenderWidgetHostView();
+ if (view) {
@zcbenz
zcbenz Sep 16, 2016 Contributor

IsOffScreen should be checked here.

@gerhardberger
gerhardberger Sep 16, 2016 edited Member

I thought about that, but couldn't come up with a proper way to get the atom::api::WebContents in NativeWindow.

But this SetSize call only happens in OSR mode, because in a normal rendering mode having a different size other than the one we wanted to set after we set it should not happen.

@zcbenz
zcbenz Sep 16, 2016 Contributor

How about subscribing to window resize events in RenderWidgetHostView? It is provided by NativeWindowObserver.

@gerhardberger
gerhardberger Sep 16, 2016 Member

Great I didn't notice that, thanks! I moved the call to OffscreenRenderWidgetHostView.

@zcbenz
zcbenz approved these changes Sep 19, 2016 View changes
@zcbenz zcbenz merged commit a260647 into electron:master Sep 19, 2016

0 of 2 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details
@danburzo
Contributor

This is great! I was doing a stopPainting()/startPainting() combo to force a paint event.

The use-case (for me, at least) is you want to grab a PNG representation of the page after a certain client event is emitted, and since the Buffer is volatile, I'm not sure how you'd have done it previously (other than triggering a paint event).

@aluxian-huginn aluxian-huginn referenced this pull request in Aluxian/Messenger-for-Desktop Sep 22, 2016
Closed

Update dependency: electron v1.4.1 #648

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment