<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>
<p dir="auto">Back in Electron 5 I reported issue <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="454833050" data-permission-text="Title is private" data-url="https://github.com/electron/electron/issues/18733" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/18733/hovercard" href="https://github.com/electron/electron/issues/18733">#18733</a>. It was automatically closed lately, however it still affects Electron versions up to 11 (but not, as far as I can tell, version 12). Anyway the instructions said I should reopen it if it still affects a supported version, so here it is.</p>
<p dir="auto">Much discussion is on that thread. <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/dsanders11/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/dsanders11">@dsanders11</a> diagnosed the problem there.</p>
<h3 dir="auto">Issue Details</h3>
<ul dir="auto">
<li><strong>Electron Version:</strong>
<ul dir="auto">
<li>5 through 11 (not 12)</li>
</ul>
</li>
<li><strong>Operating System:</strong>
<ul dir="auto">
<li>Windows 10</li>
</ul>
</li>
<li><strong>Last known Working Electron versions:</strong>
<ul dir="auto">
<li>5.0.0.beta8 is OK, 5.0.0.beta9 crashes.</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">The following code, when run in a renderer process, should not crash.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="let decoder = new TextDecoder(&quot;utf8&quot;);
let msg = &quot;a&quot;.repeat(4096);		// Exact minimum size that crashes for me, i.e. 4095 does not.
let buf = Buffer.from(msg);
decoder.decode(buf);"><pre class="notranslate"><span class="pl-k">let</span> <span class="pl-s1">decoder</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">TextDecoder</span><span class="pl-kos">(</span><span class="pl-s">"utf8"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-s1">msg</span> <span class="pl-c1">=</span> <span class="pl-s">"a"</span><span class="pl-kos">.</span><span class="pl-en">repeat</span><span class="pl-kos">(</span><span class="pl-c1">4096</span><span class="pl-kos">)</span><span class="pl-kos">;</span>		<span class="pl-c">// Exact minimum size that crashes for me, i.e. 4095 does not.</span>
<span class="pl-k">let</span> <span class="pl-s1">buf</span> <span class="pl-c1">=</span> <span class="pl-v">Buffer</span><span class="pl-kos">.</span><span class="pl-en">from</span><span class="pl-kos">(</span><span class="pl-s1">msg</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">decoder</span><span class="pl-kos">.</span><span class="pl-en">decode</span><span class="pl-kos">(</span><span class="pl-s1">buf</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">It does crash in Electron 11, but not Electron 12.</p>
<h3 dir="auto">To Reproduce</h3>
<p dir="auto"><a href="https://github.com/fohristiwhirl/electron_crash_test">https://github.com/fohristiwhirl/electron_crash_test</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="git clone https://github.com/fohristiwhirl/electron_crash_test -b master
cd electron_crash_test
electron ."><pre class="notranslate"><code class="notranslate">git clone https://github.com/fohristiwhirl/electron_crash_test -b master
cd electron_crash_test
electron .
</code></pre></div>
<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>7.0.0</li>
</ul>
</li>
<li><strong>Operating System:</strong>
<ul dir="auto">
<li>Windows 8.1</li>
</ul>
</li>
<li><strong>Last Known Working Electron version:</strong>
<ul dir="auto">
<li>3.0.3 (we're in process of upgrading from this version to the latest, so it is unclear as to when exactly the undesired behavior was introduced)</li>
</ul>
</li>
</ul>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">Expecting no crash when the following code is executed:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="const makeArray = (n, min = 1, max = Number.MAX_SAFE_INTEGER) =&gt; [...Array(n).keys()].map(i =&gt; (i + min) % max);
const encodeBase64 = (array) =&gt; btoa(String.fromCharCode(...array));

let buffer = Buffer.from(encodeBase64(makeArray(1024 * 4, 0, 256)), 'base64');
let blob = new Blob([buffer], { type: 'image/png' });"><pre class="notranslate"><code class="notranslate">const makeArray = (n, min = 1, max = Number.MAX_SAFE_INTEGER) =&gt; [...Array(n).keys()].map(i =&gt; (i + min) % max);
const encodeBase64 = (array) =&gt; btoa(String.fromCharCode(...array));

let buffer = Buffer.from(encodeBase64(makeArray(1024 * 4, 0, 256)), 'base64');
let blob = new Blob([buffer], { type: 'image/png' });
</code></pre></div>
<h3 dir="auto">Actual Behavior</h3>
<p dir="auto">The renderer process crashes while executing <code class="notranslate">new Blob([buffer], { type: 'image/png' })</code> statement. The Electron app window is blanked out, and if the Developer Tools is open, the following pop-up message is displayed: "DevTools was disconnected from the page". No Developer Tools Console messages. No messages in the OS console, either.</p>
<h3 dir="auto">To Reproduce</h3>
<p dir="auto">Clone the electron-quick-start repository, and insert the JavaScript code above into renderer.js file. Don't forget to set nodeIntegration = true for the main window, otherwise Buffer won't be found.</p>
<p dir="auto">Electron Fiddle gist of the same: <a href="https://gist.github.com/70e141736d51fb0a6936c110b6f7c9f5">https://gist.github.com/70e141736d51fb0a6936c110b6f7c9f5</a></p>
<h3 dir="auto">Additional Information</h3>
<p dir="auto">This behavior is related to <code class="notranslate">Buffer.from('...', 'base64')</code> - that is, Base64 decoding - because providing the Blob constructor a buffer created by other means seems to work fine.</p>
<p dir="auto">Also, the Base64-encoded string in the code above is just a simple way to reproduce the problem. The crash occurs when legitimate Base64-encoded images are processed as well.</p>