Closed
Description
There should be a documented way to close a WebContents and allow it to be garbage collected.
I'd prefer not to document the existing webContents.destroy()
method if possible as it's quite aggressive and makes the underlying WebContents object unusable after being called. Ideally, I'd like to have a webContents.close()
method that returns the object to the state that it was in prior to loadURL()
being called, and marks it as available for GC once references are dropped.
i.e. this should work:
const bv = new BrowserView
bv.webContents.loadURL("https://example.com")
// ... later ...
bv.webContents.close()
// If the reference to `bv` were dropped here, both `bv` and the webContents would be available for collection
// ... but if the reference is retained, the WebContents should be re-usable at a later date:
bv.webContents.loadURL("https://example.com")
Ref #23578.