Skip to content
New issue

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

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

Already on GitHub? # to your account

Resizing views on Electron 32 #47

Open
aadcg opened this issue Nov 12, 2024 · 0 comments
Open

Resizing views on Electron 32 #47

aadcg opened this issue Nov 12, 2024 · 0 comments

Comments

@aadcg
Copy link
Member

aadcg commented Nov 12, 2024

It used to be trivial to resize a view bound to a window via the deprecated setAutoResize. The new API that replaces BrowserView, WebContentsView, doesn't implement it.

It can be done via listeners but the current naive implementation (see add-bounded-view) doesn't sanitize those when the view is removed. Anyway, it isn't hard to imagine a situation where a window holds 10 views (tabs).

(node:151252) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 
11 resize listeners added to [BrowserWindow]. 
MaxListeners is 10. 
Use emitter.setMaxListeners() to increase limit

While it is trivial to silence these warning (as per below), let's keep it as a remainder.

modified   source/server.js
@@ -13,11 +13,15 @@ if (process.argv.length != 3) {
 const path = require('node:path')
 const nodejs_net = require('node:net');
 const fs = require('node:fs');
+const emitter = require('node:events');
 // The architecture of protocol handling resorts to a tmp file, meaning that the
 // main JS location may differ from the location of the current file.
 const SynchronousSocket = require(path.resolve('node_modules/synchronous-socket'));
 const { app, ipcMain, BrowserWindow, WebContentsView, webContents, protocol, net } = require('electron')
 
+emitter.setMaxListeners(0)
+
 app.on('ready', () => {
     const server = nodejs_net.createServer((socket) => {
         socket.on('data', (data) => {

Hopefully, Electron will fix the issue, see electron/electron#43802.

aadcg added a commit that referenced this issue Nov 12, 2024
aadcg added a commit that referenced this issue Nov 21, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

1 participant