<h3 dir="auto">Preflight Checklist</h3>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the <a href="https://github.com/electron/electron/blob/master/CONTRIBUTING.md">Contributing Guidelines</a> for this project.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow the <a href="https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md">Code of Conduct</a> that this project adheres to.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the issue tracker for an issue that matches the one I want to file, without success.</li>
</ul>
<h3 dir="auto">Issue Details</h3>
<ul dir="auto">
<li><strong>Electron Version:</strong>
<ul dir="auto">
<li>8.x - 12.0.0-beta14</li>
</ul>
</li>
<li><strong>Operating System:</strong>
<ul dir="auto">
<li>Windows 10 (Build 18363)</li>
</ul>
</li>
<li><strong>Last Known Working Electron version:</strong>
<ul dir="auto">
<li>N/A</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">BrowserView should fill the available space in BrowserWindow when application window size is changed when it has been set to autoresize view according to BrowserWindow width/height.</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">BrowserView does fill the available space, but leaves small gaps to the right/bottom side of the view. Gap size is relative to how much the size is enlarged. This happens only in Windows. On Linux there are no gaps and changing window size works without<br>
issues.</p>
<h3 dir="auto">To Reproduce</h3>
<p dir="auto">Gist for Electron Fiddle: <a href="https://gist.github.com/4c1a403df092cded0d8ff85640a9c19f">https://gist.github.com/4c1a403df092cded0d8ff85640a9c19f</a></p>
<h3 dir="auto">Screenshots</h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/66526/104361211-d8382180-551a-11eb-9579-d808fc0437a2.png"><img src="https://user-images.githubusercontent.com/66526/104361211-d8382180-551a-11eb-9579-d808fc0437a2.png" alt="image" style="max-width: 100%;"></a></p>
<details open="" class="details-reset border rounded-2">
  <summary class="px-3 py-2">
    <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-device-camera-video">
    <path d="M16 3.75v8.5a.75.75 0 0 1-1.136.643L11 10.575v.675A1.75 1.75 0 0 1 9.25 13h-7.5A1.75 1.75 0 0 1 0 11.25v-6.5C0 3.784.784 3 1.75 3h7.5c.966 0 1.75.784 1.75 1.75v.675l3.864-2.318A.75.75 0 0 1 16 3.75Zm-6.5 1a.25.25 0 0 0-.25-.25h-7.5a.25.25 0 0 0-.25.25v6.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-6.5ZM11 8.825l3.5 2.1v-5.85l-3.5 2.1Z"></path>
</svg>
    <span aria-label="Video description 2021-01-12.21-38-28.mp4" class="m-1">2021-01-12.21-38-28.mp4</span>
    <span class="dropdown-caret"></span>
  </summary>

  <video src="https://user-images.githubusercontent.com/66526/104364196-f142d180-551e-11eb-9349-798f658f9e30.mp4" data-canonical-src="https://user-images.githubusercontent.com/66526/104364196-f142d180-551e-11eb-9349-798f658f9e30.mp4" controls="controls" muted="muted" class="d-block rounded-bottom-2 border-top width-fit" style="max-height:640px; min-height: 200px">

  </video>
</details>
<h3 dir="auto">Preflight Checklist</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have read the <a href="https://github.com/electron/electron/blob/master/CONTRIBUTING.md">Contributing Guidelines</a> for this project.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow the <a href="https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md">Code of Conduct</a> that this project adheres to.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the issue tracker for an issue that matches the one I want to file, without success.</li>
</ul>
<h3 dir="auto">Issue Details</h3>
<ul dir="auto">
<li><strong>Electron Version:</strong> confirmed in 8.0.1, 7.1.2, 5.0.7, 4.0.0</li>
<li><strong>Operating System:</strong> Windows 10</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">I have a <code class="notranslate">BrowserView</code> that is configured to resize with the window. I have a <code class="notranslate">resize</code> handler on the <code class="notranslate">BrowserWindow</code> that in some cases calls <code class="notranslate">setBounds</code>/<code class="notranslate">setSize</code> to change the size of the window.</p>
<p dir="auto">I expect the <code class="notranslate">BrowserView</code> to resize with the window.</p>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">The <code class="notranslate">BrowserView</code> doesn't resize correctly and shrinks.</p>
<h3 dir="auto">To Reproduce</h3>
<p dir="auto">Download the quickstart app. Replace main.js with:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const { app, BrowserWindow, BrowserView } = require('electron')

async function createWindow() {
  const mainWindow = new BrowserWindow({ backgroundColor: &quot;#000&quot; });
  const view = new BrowserView();
  mainWindow.setBrowserView(view);

  const contentBounds = mainWindow.getContentBounds();
  view.setBounds({ x: 0, y: 0, width: contentBounds.width, height: contentBounds.height });
  view.setAutoResize({ width: true, height: true });

  await view.webContents.loadURL(&quot;https://google.com&quot;);

  mainWindow.once(&quot;maximize&quot;, () =&gt; {
    mainWindow.once(&quot;resize&quot;, () =&gt; {
      mainWindow.setSize(1000, 1000);
      setTimeout(() =&gt; {
        console.log(mainWindow.getBounds()); // logs what it used to be at {x: 914, y: 62, width: 800, height: 600}
        console.log(view.getBounds()); // bounds are not resized correctly: {x: 0, y: 0, width: 0, height: 145}
      }, 1000);
    });
  });
}

app.on('ready', createWindow)"><pre class="notranslate"><code class="notranslate">const { app, BrowserWindow, BrowserView } = require('electron')

async function createWindow() {
  const mainWindow = new BrowserWindow({ backgroundColor: "#000" });
  const view = new BrowserView();
  mainWindow.setBrowserView(view);

  const contentBounds = mainWindow.getContentBounds();
  view.setBounds({ x: 0, y: 0, width: contentBounds.width, height: contentBounds.height });
  view.setAutoResize({ width: true, height: true });

  await view.webContents.loadURL("https://google.com");

  mainWindow.once("maximize", () =&gt; {
    mainWindow.once("resize", () =&gt; {
      mainWindow.setSize(1000, 1000);
      setTimeout(() =&gt; {
        console.log(mainWindow.getBounds()); // logs what it used to be at {x: 914, y: 62, width: 800, height: 600}
        console.log(view.getBounds()); // bounds are not resized correctly: {x: 0, y: 0, width: 0, height: 145}
      }, 1000);
    });
  });
}

app.on('ready', createWindow)
</code></pre></div>
<p dir="auto">Run <code class="notranslate">npm start</code>, maximize the window to set up the <code class="notranslate">resize</code> handler, and then unmaximize it.</p>
<p dir="auto">Observe all the black space in the window where you would expect to see the browser view (google).</p>
<p dir="auto">Another thing to note is how the window size doesn't increase to 1000x1000 and stays whatever size it was. It does look like the BrowserView size increases, and it ends up out of sync with the window.</p>
<p dir="auto">Maybe the issue isn't about the BrowserView, but more about the window size not increasing.</p>
<h3 dir="auto">Gif</h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/6374473/74377426-7a023c00-4da9-11ea-919a-708560c81d78.gif"><img src="https://user-images.githubusercontent.com/6374473/74377426-7a023c00-4da9-11ea-919a-708560c81d78.gif" alt="browserview_resize_issue" data-animated-image="" style="max-width: 100%;"></a></p>