Skip to content

[Bug]: No way to close a browserView #37378

Closed

Description

@t57ser

Preflight Checklist

Electron Version

23.1.0

What operating system are you using?

Windows

Operating System Version

10.0.19042

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

There should be a way to close a browserView.

Actual Behavior

Neither window.close() nor webContents.close() has any effect.
You can play a video on youtube and hear the sound continue after .removeBrowserView is called. So that does not change the behavior either. Also calling window.close() in the devtools has no effect.

const electron = require( "electron" )

electron.app.whenReady().then(()=>{
	let main = new electron.BrowserWindow({
		"height" : 700,
		"width" : 800,
		show: true,
	});

	let view = new electron.BrowserView({});
	view.webContents.loadURL("https://www.youtube.com");
	main.addBrowserView(view);
	view.setBounds({x: 0, y: 0, width: 800, height: 700})
	view.webContents.openDevTools({ mode: "detach" });

	setTimeout(() => {
		console.log("calling webContents.close()")
		//main.removeBrowserView(view);
		//view.webContents.close();
		view.webContents.executeJavaScript("window.close()");
	}, 5000);
})

Testcase Gist URL

No response

Additional Information

No response

Activity

  1. added
    bug/regression ↩️
    status/confirmed
    has-repro-comment
    on Feb 23, 2023
  2. dsanders11 commented on Feb 23, 2023

    @dsanders11
    Member

    Can confirm that YouTube video continues to play after view.webContents.close(). It looks like this regressed in v23.1.0, likely due to #37205.

    cc @codebytere

  3. self-assigned this
    on Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🪲bug/regression ↩️component/BrowserViewhas-repro-commentstatus/confirmed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions