webContent has not "destory" method.
In other words, if I want to destroy the webcontent from id then I couldn't do anything.
And I have killed the process for webContent but the pId was became 0 and I can see webContent(not destroyed) in webContents.getAllWebContents().
Could you help me ?
webContents.getAllWebContents().forEach((wc: WebContents) => {
const url: string = wc.getURL();
const pId: number = wc.getOSProcessId();
if ('about:blank' === url) {
if (0 !== wc.getOSProcessId()) {
process.kill(pId);
}
}
});
#how to destroy webContent with webContentId?
57 messages · Page 1 of 1 (latest)
for what purpose?
Hi
Thank you for your reply.
I am working on the web browser project based on electronjs.
In my project, I have made the task manager for control tabs.
npm
Process manager UI for Electron applications, it works on any electron version. Latest version: 2.0.1, last published: 2 months ago. Start using ksy-electron-process-manager in your project by running npm i ksy-electron-process-manager. There are no other projects in the npm registry using ksy-electron-process-manager.
This package is what I have posted.
To destroy webContent, I have to call process.kill method.
But webContent.getAllWebContents then the killed webContent is still exitance.
Thus, I think webContent.destory must be existed.
What do you think ?
webContent is part of BrowserWindow
yeah
use destroy of browserwindow
Then all process will be existed.
If browserwindow has many browserView then how are you going ?
with browserview api
if you able to attach browserview to browserwindow
you able to detach it
yeah, but there might be the undestroyed webContent even if I called browser.removeBrowserView(view).
Do you think it's right code ?
if you able to use it why not
but destroying webcontent may also destroy its owner
Absolutely, webContent doesn't have destroy method.
It's the sample code by some guys.
yeah,but if I call the destroy method then it would occur an errror.
what error?
Typescript types don't list the destroy method as being available, but it is 🙂
and you must set the active browserwindow to null or another view before calling destroy
you mistype
what do you mean ?
destory
oh, really sorry.
Thank you so much, 🙂
why destroy method doesn't exist in documentation ?
because it is not supposed to be used
so in generally, we shouldn't use destroy method, shouldn't it?
no
then what do you mean ?
no, you shouldnt use it
There is the point I want to destroy webContent by id.
in this case, we can call directly destroy method, I think.
What do you think ?
use close of browserwindow
yah, I have already used it.
But there is the case that electron.js don't release webContent when I have set this.browserView = null; and this.window.win.removeBrowserView(view.browserView);
So I had to call process.kill to clear the unused webContent.
but closest i find where webcontents.close exists is electron v22
ok.