New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offscreen invalidate and sizing fix #7062

Merged
merged 5 commits into from Sep 19, 2016

Conversation

Projects
None yet
4 participants
@gerhardberger
Member

gerhardberger commented Sep 1, 2016

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

This comment has been minimized.

Member

zeke commented Sep 2, 2016

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

@gerhardberger

This comment has been minimized.

Member

gerhardberger commented Sep 2, 2016

@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.

// In offscreen mode call RenderWidgetHostView's SetSize explicitly
const auto view = web_contents()->GetRenderWidgetHostView();
if (view) {

This comment has been minimized.

@zcbenz

zcbenz Sep 16, 2016

Contributor

IsOffScreen should be checked here.

This comment has been minimized.

@gerhardberger

gerhardberger Sep 16, 2016

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.

This comment has been minimized.

@zcbenz

zcbenz Sep 16, 2016

Contributor

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

This comment has been minimized.

@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

@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

This comment has been minimized.

Contributor

danburzo commented Sep 22, 2016

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).

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