Skip to content

webview contents don't get properly resized if window is resized when webview is hidden #5110

Closed
@elisee

Description

@elisee
  • Electron version: 0.37.5
  • Operating system: Windows 10

Hi! Here's a minimal Electron app to reproduce the bug: electron-webview-resize-bug.zip

  1. Run the app
  2. Click the button to hide the webview
  3. Resize window
  4. Click the button again to show webview
  5. Bug: Notice the webview hasn't been resized (if you resize the window now then the bug disappears)

GIF demo:
webview-resize-bug-demo

Actual use case where I hit the bug: tabbed UI with hidden <webview>s for non-active tabs.


Bonus bug found while creating the testcase:

  1. Remove the <script>...</script> tag in index.html
  2. Launch the app
  3. Bug: The webview doesn't show up at all.
  4. Try reloading with Ctrl+R, still doesn't show up
  5. Open devtools with Ctrl+Shift+I.
  6. Try realoding with Ctrl+R, notice the webview shows up.

The absence of a script / not having the devtools open seems to prevent the webview from showing? ¯_(ツ)_/¯

Activity

xywz

xywz commented on Apr 11, 2016

@xywz

Can confirm.

The bonus bug is a duplicate of #1117.

christoth

christoth commented on Apr 12, 2016

@christoth
Contributor

webview has issues being hidden or using display: none;. It causes the behaviour you're seeing here as well as reloading the current page when un-hidden, as opposed to just becoming visible again.

The webview and child browserplugin object occupy the correct dimensions in your testcase, it's just the browserplugin is not rendering to fill its updated dimensions, cause because the webview was hidden.

If the best workaround, is to set the webview CSS to { width: 0px; height: 0px; flex: 0 1; }. This will effectively hide it, and not cause the adverse side effects of display: none;/hidden
electron-webview-resize-bug-workaround.zip

I will update the webview documentation to make note of this behaviour and the workaround.

evertonfraga

evertonfraga commented on Oct 7, 2016

@evertonfraga

Just to make sure: any news on this subject?

thanks

craxal

craxal commented on Sep 25, 2017

@craxal

I notice something similar happens when you change the zoom level of the shell and the webview's contents. When zooming in, while the webview element itself fills it's parent content, the content with the webview contracts.

image

sofianguy

sofianguy commented on Jan 30, 2018

@sofianguy
Contributor

Thanks for contributing!

This is an old version that we are no longer releasing bug fixes for. We prefer to only keep issues that are on our immediate radar.

If you are still having the same issue in an up-to-date version, feel free to reach out and we'll reopen.

21 remaining items

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @evertonfraga@ckerr@mhuggins@elisee@zcbenz

        Issue actions

          `webview` contents don't get properly resized if window is resized when webview is hidden · Issue #5110 · electron/electron